Lines Matching +full:de +full:- +full:noise
1 // SPDX-License-Identifier: GPL-2.0
3 * OS Noise Tracer: computes the OS Noise suffered by a running thread.
7 * Copyright (C) 2008-2009 Jon Masters, Red Hat, Inc. <jcm@redhat.com>
8 * Copyright (C) 2013-2016 Steven Rostedt, Red Hat, Inc. <srostedt@redhat.com>
12 * DE OLIVEIRA, Daniel Bristot, et al. Demystifying the real-time linux
13 * scheduling latency. In: 32nd Euromicro Conference on Real-Time Systems
14 * (ECRTS 2020). Schloss Dagstuhl-Leibniz-Zentrum fur Informatik, 2020.
16 * Copyright (C) 2021 Daniel Bristot de Oliveira, Red Hat, Inc. <bristot@redhat.com>
91 * osnoise_instance_registered - check if a tr is already registered
100 if (inst->tr == tr) in osnoise_instance_registered()
109 * osnoise_register_instance - register a new trace instance
126 return -ENOMEM; in osnoise_register_instance()
128 INIT_LIST_HEAD_RCU(&inst->list); in osnoise_register_instance()
129 inst->tr = tr; in osnoise_register_instance()
130 list_add_tail_rcu(&inst->list, &osnoise_instances); in osnoise_register_instance()
136 * osnoise_unregister_instance - unregister a registered trace instance
152 if (inst->tr == tr) { in osnoise_unregister_instance()
153 list_del_rcu(&inst->list); in osnoise_unregister_instance()
219 * Per-cpu runtime information.
224 * this_cpu_osn_var - Return the per-cpu osnoise_variables on its relative CPU
253 * this_cpu_tmr_var - Return the per-cpu timerlat_variables on its relative CPU
261 * tlat_var_reset - Reset the values of the given timerlat_variables
276 if (tlat_var->kthread) in tlat_var_reset()
277 hrtimer_cancel(&tlat_var->timer); in tlat_var_reset()
287 * osn_var_reset - Reset the values of the given osnoise_variables
305 * osn_var_reset_all - Reset the value of all per-cpu osnoise_variables
324 u64 noise; /* noise */ member
325 u64 max_sample; /* max single noise sample */
384 if (!tlat_var->tracing_thread) { in timerlat_softirq_exit()
385 osn_var->softirq.arrival_time = 0; in timerlat_softirq_exit()
386 osn_var->softirq.delta_start = 0; in timerlat_softirq_exit()
399 if (!tlat_var->tracing_thread) { in timerlat_thread_exit()
400 osn_var->thread.delta_start = 0; in timerlat_thread_exit()
401 osn_var->thread.arrival_time = 0; in timerlat_thread_exit()
431 seq_puts(s, "# _-------=> irqs-off\n"); in print_osnoise_headers()
432 seq_puts(s, "# / _------=> need-resched\n"); in print_osnoise_headers()
433 seq_puts(s, "# | / _-----=> need-resched-lazy\n"); in print_osnoise_headers()
434 seq_puts(s, "# || / _----=> hardirq/softirq\n"); in print_osnoise_headers()
435 seq_puts(s, "# ||| / _---=> preempt-depth\n"); in print_osnoise_headers()
436 seq_puts(s, "# |||| / _--=> preempt-lazy-depth\n"); in print_osnoise_headers()
437 seq_puts(s, "# ||||| / _-=> migrate-disable\n"); in print_osnoise_headers()
446 seq_puts(s, " NOISE %% OF CPU NOISE +-----------------------------+\n"); in print_osnoise_headers()
448 seq_puts(s, "# TASK-PID CPU# ||||||| TIMESTAMP IN US "); in print_osnoise_headers()
460 seq_puts(s, "# _-----=> irqs-off\n"); in print_osnoise_headers()
461 seq_puts(s, "# / _----=> need-resched\n"); in print_osnoise_headers()
462 seq_puts(s, "# | / _---=> hardirq/softirq\n"); in print_osnoise_headers()
463 seq_puts(s, "# || / _--=> preempt-depth\n"); in print_osnoise_headers()
464 seq_puts(s, "# ||| / _-=> migrate-disable "); in print_osnoise_headers()
470 seq_puts(s, " NOISE %% OF CPU NOISE +-----------------------------+\n"); in print_osnoise_headers()
472 seq_puts(s, "# TASK-PID CPU# ||||| TIMESTAMP IN US "); in print_osnoise_headers()
481 * osnoise_taint - report an osnoise error.
489 buffer = inst->tr->array_buffer.buffer; \
511 entry->runtime = sample->runtime; in __trace_osnoise_sample()
512 entry->noise = sample->noise; in __trace_osnoise_sample()
513 entry->max_sample = sample->max_sample; in __trace_osnoise_sample()
514 entry->hw_count = sample->hw_count; in __trace_osnoise_sample()
515 entry->nmi_count = sample->nmi_count; in __trace_osnoise_sample()
516 entry->irq_count = sample->irq_count; in __trace_osnoise_sample()
517 entry->softirq_count = sample->softirq_count; in __trace_osnoise_sample()
518 entry->thread_count = sample->thread_count; in __trace_osnoise_sample()
534 buffer = inst->tr->array_buffer.buffer; in trace_osnoise_sample()
547 seq_puts(s, "# _-------=> irqs-off\n"); in print_timerlat_headers()
548 seq_puts(s, "# / _------=> need-resched\n"); in print_timerlat_headers()
549 seq_puts(s, "# | / _-----=> need-resched-lazy\n"); in print_timerlat_headers()
550 seq_puts(s, "# || / _----=> hardirq/softirq\n"); in print_timerlat_headers()
551 seq_puts(s, "# ||| / _---=> preempt-depth\n"); in print_timerlat_headers()
552 seq_puts(s, "# |||| / _--=> preempt-lazy-depth\n"); in print_timerlat_headers()
553 seq_puts(s, "# ||||| / _-=> migrate-disable\n"); in print_timerlat_headers()
556 seq_puts(s, "# TASK-PID CPU# ||||||| TIMESTAMP ID "); in print_timerlat_headers()
564 seq_puts(s, "# _-----=> irqs-off\n"); in print_timerlat_headers()
565 seq_puts(s, "# / _----=> need-resched\n"); in print_timerlat_headers()
566 seq_puts(s, "# | / _---=> hardirq/softirq\n"); in print_timerlat_headers()
567 seq_puts(s, "# || / _--=> preempt-depth\n"); in print_timerlat_headers()
568 seq_puts(s, "# ||| / _-=> migrate-disable\n"); in print_timerlat_headers()
571 seq_puts(s, "# TASK-PID CPU# ||||| TIMESTAMP ID "); in print_timerlat_headers()
590 entry->seqnum = sample->seqnum; in __trace_timerlat_sample()
591 entry->context = sample->context; in __trace_timerlat_sample()
592 entry->timer_latency = sample->timer_latency; in __trace_timerlat_sample()
608 buffer = inst->tr->array_buffer.buffer; in trace_timerlat_sample()
631 * timerlat_save_stack - save a stack trace without printing
643 size = ARRAY_SIZE(fstack->calls); in timerlat_save_stack()
645 nr_entries = stack_trace_save(fstack->calls, size, skip); in timerlat_save_stack()
647 fstack->stack_size = nr_entries * sizeof(unsigned long); in timerlat_save_stack()
648 fstack->nr_entries = nr_entries; in timerlat_save_stack()
668 memcpy(&entry->caller, fstack->calls, size); in __timerlat_dump_stack()
669 entry->size = fstack->nr_entries; in __timerlat_dump_stack()
676 * timerlat_dump_stack - dump a stack trace previously saved
693 size = fstack->stack_size; in timerlat_dump_stack()
697 buffer = inst->tr->array_buffer.buffer; in timerlat_dump_stack()
715 #define time_sub(a, b) ((a) - (b))
718 * cond_move_irq_delta_start - Forward the delta_start of a running IRQ
728 if (osn_var->irq.delta_start) in cond_move_irq_delta_start()
729 osn_var->irq.delta_start += duration; in cond_move_irq_delta_start()
734 * cond_move_softirq_delta_start - Forward the delta_start of a running softirq.
744 if (osn_var->softirq.delta_start) in cond_move_softirq_delta_start()
745 osn_var->softirq.delta_start += duration; in cond_move_softirq_delta_start()
752 * cond_move_thread_delta_start - Forward the delta_start of a running thread
762 if (osn_var->thread.delta_start) in cond_move_thread_delta_start()
763 osn_var->thread.delta_start += duration; in cond_move_thread_delta_start()
767 * get_int_safe_duration - Get the duration of a window
775 * - Know if a given window is being measured.
776 * - Account its duration.
777 * - Discount the interference.
782 * ---> interrupt!
783 * delta_start -= int duration;
784 * <---
785 * duration = now - delta_start;
800 int_counter = local_read(&osn_var->int_counter); in get_int_safe_duration()
805 duration = (now - *delta_start); in get_int_safe_duration()
809 } while (int_counter != local_read(&osn_var->int_counter)); in get_int_safe_duration()
825 * set_int_safe_time - Save the current time on *time, aware of interference
838 int_counter = local_read(&osn_var->int_counter); in set_int_safe_time()
846 } while (int_counter != local_read(&osn_var->int_counter)); in set_int_safe_time()
853 * copy_int_safe_time - Copy *src into *desc aware of interference
861 int_counter = local_read(&osn_var->int_counter); in copy_int_safe_time()
869 } while (int_counter != local_read(&osn_var->int_counter)); in copy_int_safe_time()
876 * trace_osnoise_callback - NMI entry/exit callback
880 * occurrence, compute the noise caused by the NMI, and to remove the noise
888 if (!osn_var->sampling) in trace_osnoise_callback()
897 osn_var->nmi.delta_start = time_get(); in trace_osnoise_callback()
898 local_inc(&osn_var->int_counter); in trace_osnoise_callback()
900 duration = time_get() - osn_var->nmi.delta_start; in trace_osnoise_callback()
902 trace_nmi_noise(osn_var->nmi.delta_start, duration); in trace_osnoise_callback()
911 osn_var->nmi.count++; in trace_osnoise_callback()
915 * osnoise_trace_irq_entry - Note the starting of an IRQ
917 * Save the starting time of an IRQ. As IRQs are non-preemptive to other IRQs,
918 * it is safe to use a single variable (ons_var->irq) to save the statistics.
927 if (!osn_var->sampling) in osnoise_trace_irq_entry()
933 osn_var->irq.arrival_time = time_get(); in osnoise_trace_irq_entry()
934 set_int_safe_time(osn_var, &osn_var->irq.delta_start); in osnoise_trace_irq_entry()
935 osn_var->irq.count++; in osnoise_trace_irq_entry()
937 local_inc(&osn_var->int_counter); in osnoise_trace_irq_entry()
941 * osnoise_irq_exit - Note the end of an IRQ, sava data and trace
943 * Computes the duration of the IRQ noise, and trace it. Also discounts the
944 * interference from other sources of noise could be currently being accounted.
951 if (!osn_var->sampling) in osnoise_trace_irq_exit()
954 duration = get_int_safe_duration(osn_var, &osn_var->irq.delta_start); in osnoise_trace_irq_exit()
955 trace_irq_noise(id, desc, osn_var->irq.arrival_time, duration); in osnoise_trace_irq_exit()
956 osn_var->irq.arrival_time = 0; in osnoise_trace_irq_exit()
962 * trace_irqentry_callback - Callback to the irq:irq_entry traceevent
973 * trace_irqexit_callback - Callback to the irq:irq_exit traceevent
980 osnoise_trace_irq_exit(irq, action->name); in trace_irqexit_callback()
1000 * hook_irq_events - Hook IRQ handling events
1028 return -EINVAL; in hook_irq_events()
1032 * unhook_irq_events - Unhook IRQ handling events
1046 * trace_softirq_entry_callback - Note the starting of a softirq
1048 * Save the starting time of a softirq. As softirqs are non-preemptive to
1049 * other softirqs, it is safe to use a single variable (ons_var->softirq)
1058 if (!osn_var->sampling) in trace_softirq_entry_callback()
1064 osn_var->softirq.arrival_time = time_get(); in trace_softirq_entry_callback()
1065 set_int_safe_time(osn_var, &osn_var->softirq.delta_start); in trace_softirq_entry_callback()
1066 osn_var->softirq.count++; in trace_softirq_entry_callback()
1068 local_inc(&osn_var->int_counter); in trace_softirq_entry_callback()
1072 * trace_softirq_exit_callback - Note the end of an softirq
1074 * Computes the duration of the softirq noise, and trace it. Also discounts the
1075 * interference from other sources of noise could be currently being accounted.
1082 if (!osn_var->sampling) in trace_softirq_exit_callback()
1089 duration = get_int_safe_duration(osn_var, &osn_var->softirq.delta_start); in trace_softirq_exit_callback()
1090 trace_softirq_noise(vec_nr, osn_var->softirq.arrival_time, duration); in trace_softirq_exit_callback()
1092 osn_var->softirq.arrival_time = 0; in trace_softirq_exit_callback()
1096 * hook_softirq_events - Hook softirq handling events
1118 return -EINVAL; in hook_softirq_events()
1122 * unhook_softirq_events - Unhook softirq handling events
1146 * thread_entry - Record the starting of a thread noise window
1154 if (!osn_var->sampling) in thread_entry()
1160 osn_var->thread.arrival_time = time_get(); in thread_entry()
1162 set_int_safe_time(osn_var, &osn_var->thread.delta_start); in thread_entry()
1164 osn_var->thread.count++; in thread_entry()
1165 local_inc(&osn_var->int_counter); in thread_entry()
1169 * thread_exit - Report the end of a thread noise window
1171 * It computes the total noise from a thread, tracing if needed.
1178 if (!osn_var->sampling) in thread_exit()
1185 duration = get_int_safe_duration(osn_var, &osn_var->thread.delta_start); in thread_exit()
1187 trace_thread_noise(t, osn_var->thread.arrival_time, duration); in thread_exit()
1189 osn_var->thread.arrival_time = 0; in thread_exit()
1194 * osnoise_stop_exception - Stop tracing and the tracer.
1203 tr = inst->tr; in osnoise_stop_exception()
1204 trace_array_printk_buf(tr->array_buffer.buffer, _THIS_IP_, in osnoise_stop_exception()
1220 * trace_sched_migrate_callback - sched:sched_migrate_task trace event handler
1223 * timerlat user-space thread migration.
1231 if (osn_var->pid == p->pid && dest_cpu != cpu) { in trace_sched_migrate_callback()
1232 per_cpu_ptr(&per_cpu_timerlat_var, cpu)->uthread_migrate = 1; in trace_sched_migrate_callback()
1233 osnoise_taint("timerlat user-thread migrated\n"); in trace_sched_migrate_callback()
1234 osnoise_stop_exception("timerlat user-thread migrated", cpu); in trace_sched_migrate_callback()
1243 * Timerlat thread migration check is only required when running timerlat in user-space. in register_migration_monitor()
1265 * trace_sched_switch - sched:sched_switch trace event handler
1268 * used to record the beginning and to report the end of a thread noise window.
1279 if ((p->pid != osn_var->pid) || !workload) in trace_sched_switch_callback()
1282 if ((n->pid != osn_var->pid) || !workload) in trace_sched_switch_callback()
1287 * hook_thread_events - Hook the instrumentation for thread noise
1289 * Hook the osnoise tracer callbacks to handle the noise from other
1298 return -EINVAL; in hook_thread_events()
1308 return -EINVAL; in hook_thread_events()
1312 * unhook_thread_events - unhook the instrumentation for thread noise
1314 * Unook the osnoise tracer callbacks to handle the noise from other
1324 * save_osn_sample_stats - Save the osnoise_sample statistics
1333 s->nmi_count = osn_var->nmi.count; in save_osn_sample_stats()
1334 s->irq_count = osn_var->irq.count; in save_osn_sample_stats()
1335 s->softirq_count = osn_var->softirq.count; in save_osn_sample_stats()
1336 s->thread_count = osn_var->thread.count; in save_osn_sample_stats()
1340 * diff_osn_sample_stats - Compute the osnoise_sample statistics
1349 s->nmi_count = osn_var->nmi.count - s->nmi_count; in diff_osn_sample_stats()
1350 s->irq_count = osn_var->irq.count - s->irq_count; in diff_osn_sample_stats()
1351 s->softirq_count = osn_var->softirq.count - s->softirq_count; in diff_osn_sample_stats()
1352 s->thread_count = osn_var->thread.count - s->thread_count; in diff_osn_sample_stats()
1356 * osnoise_stop_tracing - Stop tracing and the tracer.
1365 tr = inst->tr; in osnoise_stop_tracing()
1366 trace_array_printk_buf(tr->array_buffer.buffer, _THIS_IP_, in osnoise_stop_tracing()
1378 * osnoise_has_tracing_on - Check if there is at least one instance on
1387 trace_is_on += tracer_tracing_is_on(inst->tr); in osnoise_has_tracing_on()
1394 * notify_new_max_latency - Notify a new max latency via fsnotify interface.
1403 tr = inst->tr; in notify_new_max_latency()
1404 if (tracer_tracing_is_on(tr) && tr->max_latency < latency) { in notify_new_max_latency()
1405 tr->max_latency = latency; in notify_new_max_latency()
1413 * run_osnoise - Sample the time and look for osnoise
1426 s64 noise = 0, max_noise = 0; in run_osnoise() local
1434 int ret = -1; in run_osnoise()
1445 osn_var->pid = current->pid; in run_osnoise()
1469 osn_var->sampling = true; in run_osnoise()
1495 noise = time_sub(sample, last_sample); in run_osnoise()
1500 if (noise < 0) { in run_osnoise()
1501 osnoise_taint("negative noise!"); in run_osnoise()
1520 if (noise >= threshold) { in run_osnoise()
1521 int interference = int_count - last_int_count; in run_osnoise()
1523 if (noise > max_noise) in run_osnoise()
1524 max_noise = noise; in run_osnoise()
1529 sum_noise += noise; in run_osnoise()
1531 trace_sample_threshold(last_sample, noise, interference); in run_osnoise()
1534 if (noise > stop_in) in run_osnoise()
1541 * This will eventually cause unwarranted noise as PREEMPT_RCU in run_osnoise()
1563 * For the non-preemptive kernel config: let threads runs, if in run_osnoise()
1579 osn_var->sampling = false; in run_osnoise()
1596 * Save noise info. in run_osnoise()
1598 s.noise = time_to_us(sum_noise); in run_osnoise()
1611 if (s.noise > osnoise_data.stop_tracing_total) in run_osnoise()
1624 * osnoise_sleep - sleep until the next period
1635 interval = osnoise_data.sample_period - osnoise_data.sample_runtime; in osnoise_sleep()
1658 * osnoise_migration_pending - checks if the task needs to migrate
1660 * osnoise/timerlat threads are per-cpu. If there is a pending request to
1668 if (!current->migration_pending) in osnoise_migration_pending()
1684 this_cpu_osn_var()->kthread = NULL; in osnoise_migration_pending()
1692 * osnoise_main - The osnoise detection kernel thread
1709 raw_spin_lock_irqsave(¤t->pi_lock, flags); in osnoise_main()
1710 current->flags &= ~(PF_NO_SETAFFINITY); in osnoise_main()
1711 raw_spin_unlock_irqrestore(¤t->pi_lock, flags); in osnoise_main()
1733 * timerlat_irq - hrtimer handler for timerlat.
1750 now = ktime_to_ns(hrtimer_cb_get_time(&tlat->timer)); in timerlat_irq()
1755 tlat->tracing_thread = true; in timerlat_irq()
1757 osn_var->thread.arrival_time = time_get(); in timerlat_irq()
1780 if (!IS_ENABLED(CONFIG_PREEMPT_RT) && osn_var->softirq.delta_start) { in timerlat_irq()
1781 copy_int_safe_time(osn_var, &osn_var->thread.delta_start, in timerlat_irq()
1782 &osn_var->softirq.delta_start); in timerlat_irq()
1784 copy_int_safe_time(osn_var, &osn_var->softirq.delta_start, in timerlat_irq()
1785 &osn_var->irq.delta_start); in timerlat_irq()
1787 copy_int_safe_time(osn_var, &osn_var->thread.delta_start, in timerlat_irq()
1788 &osn_var->irq.delta_start); in timerlat_irq()
1794 diff = now - tlat->abs_period; in timerlat_irq()
1796 tlat->count++; in timerlat_irq()
1797 s.seqnum = tlat->count; in timerlat_irq()
1821 wake_up_process(tlat->kthread); in timerlat_irq()
1827 wake_up_process(tlat->kthread); in timerlat_irq()
1836 * wait_next_period - Wait for the next period for timerlat
1843 now = hrtimer_cb_get_time(&tlat->timer); in wait_next_period()
1844 next_abs_period = ns_to_ktime(tlat->abs_period + rel_period); in wait_next_period()
1849 tlat->abs_period = (u64) ktime_to_ns(next_abs_period); in wait_next_period()
1855 next_abs_period = ns_to_ktime(tlat->abs_period + rel_period); in wait_next_period()
1856 tlat->abs_period = (u64) ktime_to_ns(next_abs_period); in wait_next_period()
1861 hrtimer_start(&tlat->timer, next_abs_period, HRTIMER_MODE_ABS_PINNED_HARD); in wait_next_period()
1867 * timerlat_main- Timerlat main
1892 raw_spin_lock_irqsave(¤t->pi_lock, flags); in timerlat_main()
1893 current->flags &= ~(PF_NO_SETAFFINITY); in timerlat_main()
1894 raw_spin_unlock_irqrestore(¤t->pi_lock, flags); in timerlat_main()
1896 tlat->count = 0; in timerlat_main()
1897 tlat->tracing_thread = false; in timerlat_main()
1899 hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD); in timerlat_main()
1900 tlat->timer.function = timerlat_irq; in timerlat_main()
1901 tlat->kthread = current; in timerlat_main()
1902 osn_var->pid = current->pid; in timerlat_main()
1906 tlat->abs_period = hrtimer_cb_get_time(&tlat->timer); in timerlat_main()
1910 osn_var->sampling = 1; in timerlat_main()
1914 now = ktime_to_ns(hrtimer_cb_get_time(&tlat->timer)); in timerlat_main()
1915 diff = now - tlat->abs_period; in timerlat_main()
1917 s.seqnum = tlat->count; in timerlat_main()
1927 tlat->tracing_thread = false; in timerlat_main()
1938 hrtimer_cancel(&tlat->timer); in timerlat_main()
1950 * stop_kthread - stop a workload thread
1967 kill_pid(kthread->thread_pid, SIGKILL, 1); in stop_kthread()
1983 * stop_per_cpu_kthread - Stop per-cpu threads
2001 * start_kthread - Start a workload tread
2031 return -ENOMEM; in start_kthread()
2041 * start_per_cpu_kthread - Kick off per-cpu osnoise sampling kthreads
2117 * osnoise_cpu_init - CPU hotplug online callback function
2126 * osnoise_cpu_die - CPU hotplug offline callback function
2221 * osnoise_options_write - Write function for "options" entry
2239 return -EINVAL; in osnoise_options_write()
2242 return -EFAULT; in osnoise_options_write()
2256 return -EINVAL; in osnoise_options_write()
2281 retval = -EINVAL; in osnoise_options_write()
2297 * osnoise_cpus_read - Read function for reading the "cpus" file
2303 * Prints the "cpus" output into the user-provided buffer.
2317 count = -ENOMEM; in osnoise_cpus_read()
2323 count = -EINVAL; in osnoise_cpus_read()
2338 * osnoise_cpus_write - Write function for "cpus" entry
2362 return -EINVAL; in osnoise_cpus_write()
2365 return -EFAULT; in osnoise_cpus_write()
2368 return -ENOMEM; in osnoise_cpus_write()
2411 long cpu = (long) inode->i_cdev; in timerlat_fd_open()
2421 return -EINVAL; in timerlat_fd_open()
2429 * The osn_var->pid holds the single access to this file. in timerlat_fd_open()
2431 if (osn_var->pid) { in timerlat_fd_open()
2434 return -EBUSY; in timerlat_fd_open()
2438 * timerlat tracer is a per-cpu tracer. Check if the user-space too in timerlat_fd_open()
2444 if (current->nr_cpus_allowed > 1 || cpu != smp_processor_id()) { in timerlat_fd_open()
2447 return -EPERM; in timerlat_fd_open()
2453 file->private_data = inode->i_cdev; in timerlat_fd_open()
2457 osn_var->kthread = current; in timerlat_fd_open()
2458 osn_var->pid = current->pid; in timerlat_fd_open()
2466 tlat->count = 0; in timerlat_fd_open()
2468 hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD); in timerlat_fd_open()
2469 tlat->timer.function = timerlat_irq; in timerlat_fd_open()
2476 * timerlat_fd_read - Read function for "timerlat_fd" file
2482 * Prints 1 on timerlat, the number of interferences on osnoise, -1 on error.
2488 long cpu = (long) file->private_data; in timerlat_fd_read()
2500 * While in user-space, the thread is migratable. There is nothing in timerlat_fd_read()
2505 if (tlat->uthread_migrate) { in timerlat_fd_read()
2507 return -EINVAL; in timerlat_fd_read()
2510 per_cpu_ptr(&per_cpu_timerlat_var, cpu)->uthread_migrate = 1; in timerlat_fd_read()
2514 return -EINVAL; in timerlat_fd_read()
2520 * The timerlat in user-space runs in a different order: in timerlat_fd_read()
2527 if (likely(osn_var->sampling)) { in timerlat_fd_read()
2528 now = ktime_to_ns(hrtimer_cb_get_time(&tlat->timer)); in timerlat_fd_read()
2529 diff = now - tlat->abs_period; in timerlat_fd_read()
2537 s.seqnum = tlat->count; in timerlat_fd_read()
2545 tlat->tracing_thread = false; in timerlat_fd_read()
2550 tlat->tracing_thread = false; in timerlat_fd_read()
2551 tlat->kthread = current; in timerlat_fd_read()
2554 tlat->abs_period = hrtimer_cb_get_time(&tlat->timer); in timerlat_fd_read()
2556 osn_var->sampling = 1; in timerlat_fd_read()
2563 now = ktime_to_ns(hrtimer_cb_get_time(&tlat->timer)); in timerlat_fd_read()
2564 diff = now - tlat->abs_period; in timerlat_fd_read()
2572 s.seqnum = tlat->count; in timerlat_fd_read()
2595 long cpu = (long) file->private_data; in timerlat_fd_release()
2603 if (tlat_var->kthread) in timerlat_fd_release()
2604 hrtimer_cancel(&tlat_var->timer); in timerlat_fd_release()
2607 osn_var->sampling = 0; in timerlat_fd_release()
2608 osn_var->pid = 0; in timerlat_fd_release()
2613 if (osn_var->kthread) { in timerlat_fd_release()
2614 put_task_struct(osn_var->kthread); in timerlat_fd_release()
2615 osn_var->kthread = NULL; in timerlat_fd_release()
2720 return -ENOMEM; in init_timerlat_stack_tracefs()
2747 return -ENOMEM; in osnoise_create_cpu_timerlat_fd()
2761 d_inode(timerlat_fd)->i_cdev = (void *)(cpu); in osnoise_create_cpu_timerlat_fd()
2768 return -ENOMEM; in osnoise_create_cpu_timerlat_fd()
2772 * init_timerlat_tracefs - A function to initialize the timerlat interface files
2782 return -ENOMEM; in init_timerlat_tracefs()
2798 * init_tracefs - A function to initialize the tracefs interface files
2812 return -ENOMEM; in init_tracefs()
2855 return -ENOMEM; in init_tracefs()
2863 * Trace is already hooked, we are re-enabling from in osnoise_hook_events()
2871 return -EINVAL; in osnoise_hook_events()
2887 return -EINVAL; in osnoise_hook_events()
2898 * osnoise_workload_start - start the workload and hook to events
2944 * osnoise_workload_stop - stop the workload and unhook the events
3012 return -EBUSY; in osnoise_tracer_init()
3014 tr->max_latency = 0; in osnoise_tracer_init()
3079 return -EBUSY; in timerlat_tracer_init()
3088 tr->max_latency = 0; in timerlat_tracer_init()