Lines Matching +full:duration +full:- +full:us

1 // SPDX-License-Identifier: GPL-2.0
35 int duration; member
91 * timerlat_free_histogram - free runtime data
99 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_free_histogram()
100 if (data->hist[cpu].irq) in timerlat_free_histogram()
101 free(data->hist[cpu].irq); in timerlat_free_histogram()
103 if (data->hist[cpu].thread) in timerlat_free_histogram()
104 free(data->hist[cpu].thread); in timerlat_free_histogram()
106 if (data->hist[cpu].user) in timerlat_free_histogram()
107 free(data->hist[cpu].user); in timerlat_free_histogram()
112 if (data->hist) in timerlat_free_histogram()
113 free(data->hist); in timerlat_free_histogram()
119 * timerlat_alloc_histogram - alloc runtime data
131 data->entries = entries; in timerlat_alloc_histogram()
132 data->bucket_size = bucket_size; in timerlat_alloc_histogram()
133 data->nr_cpus = nr_cpus; in timerlat_alloc_histogram()
136 data->hist = calloc(1, sizeof(*data->hist) * nr_cpus); in timerlat_alloc_histogram()
137 if (!data->hist) in timerlat_alloc_histogram()
142 data->hist[cpu].irq = calloc(1, sizeof(*data->hist->irq) * (entries + 1)); in timerlat_alloc_histogram()
143 if (!data->hist[cpu].irq) in timerlat_alloc_histogram()
146 data->hist[cpu].thread = calloc(1, sizeof(*data->hist->thread) * (entries + 1)); in timerlat_alloc_histogram()
147 if (!data->hist[cpu].thread) in timerlat_alloc_histogram()
150 data->hist[cpu].user = calloc(1, sizeof(*data->hist->user) * (entries + 1)); in timerlat_alloc_histogram()
151 if (!data->hist[cpu].user) in timerlat_alloc_histogram()
157 data->hist[cpu].min_irq = ~0; in timerlat_alloc_histogram()
158 data->hist[cpu].min_thread = ~0; in timerlat_alloc_histogram()
159 data->hist[cpu].min_user = ~0; in timerlat_alloc_histogram()
170 * timerlat_hist_update - record a new timerlat occurent on cpu, updating data
177 struct timerlat_hist_params *params = tool->params; in timerlat_hist_update()
178 struct timerlat_hist_data *data = tool->data; in timerlat_hist_update()
179 int entries = data->entries; in timerlat_hist_update()
183 if (params->output_divisor) in timerlat_hist_update()
184 latency = latency / params->output_divisor; in timerlat_hist_update()
186 bucket = latency / data->bucket_size; in timerlat_hist_update()
189 hist = data->hist[cpu].irq; in timerlat_hist_update()
190 data->hist[cpu].irq_count++; in timerlat_hist_update()
191 update_min(&data->hist[cpu].min_irq, &latency); in timerlat_hist_update()
192 update_sum(&data->hist[cpu].sum_irq, &latency); in timerlat_hist_update()
193 update_max(&data->hist[cpu].max_irq, &latency); in timerlat_hist_update()
195 hist = data->hist[cpu].thread; in timerlat_hist_update()
196 data->hist[cpu].thread_count++; in timerlat_hist_update()
197 update_min(&data->hist[cpu].min_thread, &latency); in timerlat_hist_update()
198 update_sum(&data->hist[cpu].sum_thread, &latency); in timerlat_hist_update()
199 update_max(&data->hist[cpu].max_thread, &latency); in timerlat_hist_update()
201 hist = data->hist[cpu].user; in timerlat_hist_update()
202 data->hist[cpu].user_count++; in timerlat_hist_update()
203 update_min(&data->hist[cpu].min_user, &latency); in timerlat_hist_update()
204 update_sum(&data->hist[cpu].sum_user, &latency); in timerlat_hist_update()
205 update_max(&data->hist[cpu].max_user, &latency); in timerlat_hist_update()
215 * timerlat_hist_handler - this is the handler for timerlat tracer events
224 int cpu = record->cpu; in timerlat_hist_handler()
237 * timerlat_hist_header - print the header of the tracer to the output
241 struct timerlat_hist_params *params = tool->params; in timerlat_hist_header()
242 struct timerlat_hist_data *data = tool->data; in timerlat_hist_header()
243 struct trace_seq *s = tool->trace.seq; in timerlat_hist_header()
244 char duration[26]; in timerlat_hist_header() local
247 if (params->no_header) in timerlat_hist_header()
250 get_duration(tool->start_time, duration, sizeof(duration)); in timerlat_hist_header()
253 params->output_divisor == 1 ? "nanoseconds" : "microseconds", in timerlat_hist_header()
254 params->output_divisor == 1 ? "ns" : "us"); in timerlat_hist_header()
256 trace_seq_printf(s, "# Duration: %s\n", duration); in timerlat_hist_header()
258 if (!params->no_index) in timerlat_hist_header()
261 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_hist_header()
262 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_hist_header()
265 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_hist_header()
268 if (!params->no_irq) in timerlat_hist_header()
269 trace_seq_printf(s, " IRQ-%03d", cpu); in timerlat_hist_header()
271 if (!params->no_thread) in timerlat_hist_header()
272 trace_seq_printf(s, " Thr-%03d", cpu); in timerlat_hist_header()
274 if (params->user_hist) in timerlat_hist_header()
275 trace_seq_printf(s, " Usr-%03d", cpu); in timerlat_hist_header()
285 * format_summary_value - format a line of summary value (min, max or avg)
296 trace_seq_printf(seq, "%9c ", '-'); in format_summary_value()
300 * timerlat_print_summary - print the summary of the hist data to the output
309 if (params->no_summary) in timerlat_print_summary()
312 if (!params->no_index) in timerlat_print_summary()
313 trace_seq_printf(trace->seq, "count:"); in timerlat_print_summary()
315 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_summary()
316 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_summary()
319 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_summary()
322 if (!params->no_irq) in timerlat_print_summary()
323 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
324 data->hist[cpu].irq_count); in timerlat_print_summary()
326 if (!params->no_thread) in timerlat_print_summary()
327 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
328 data->hist[cpu].thread_count); in timerlat_print_summary()
330 if (params->user_hist) in timerlat_print_summary()
331 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
332 data->hist[cpu].user_count); in timerlat_print_summary()
334 trace_seq_printf(trace->seq, "\n"); in timerlat_print_summary()
336 if (!params->no_index) in timerlat_print_summary()
337 trace_seq_printf(trace->seq, "min: "); in timerlat_print_summary()
339 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_summary()
340 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_summary()
343 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_summary()
346 if (!params->no_irq) in timerlat_print_summary()
347 format_summary_value(trace->seq, in timerlat_print_summary()
348 data->hist[cpu].irq_count, in timerlat_print_summary()
349 data->hist[cpu].min_irq, in timerlat_print_summary()
352 if (!params->no_thread) in timerlat_print_summary()
353 format_summary_value(trace->seq, in timerlat_print_summary()
354 data->hist[cpu].thread_count, in timerlat_print_summary()
355 data->hist[cpu].min_thread, in timerlat_print_summary()
358 if (params->user_hist) in timerlat_print_summary()
359 format_summary_value(trace->seq, in timerlat_print_summary()
360 data->hist[cpu].user_count, in timerlat_print_summary()
361 data->hist[cpu].min_user, in timerlat_print_summary()
364 trace_seq_printf(trace->seq, "\n"); in timerlat_print_summary()
366 if (!params->no_index) in timerlat_print_summary()
367 trace_seq_printf(trace->seq, "avg: "); in timerlat_print_summary()
369 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_summary()
370 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_summary()
373 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_summary()
376 if (!params->no_irq) in timerlat_print_summary()
377 format_summary_value(trace->seq, in timerlat_print_summary()
378 data->hist[cpu].irq_count, in timerlat_print_summary()
379 data->hist[cpu].sum_irq, in timerlat_print_summary()
382 if (!params->no_thread) in timerlat_print_summary()
383 format_summary_value(trace->seq, in timerlat_print_summary()
384 data->hist[cpu].thread_count, in timerlat_print_summary()
385 data->hist[cpu].sum_thread, in timerlat_print_summary()
388 if (params->user_hist) in timerlat_print_summary()
389 format_summary_value(trace->seq, in timerlat_print_summary()
390 data->hist[cpu].user_count, in timerlat_print_summary()
391 data->hist[cpu].sum_user, in timerlat_print_summary()
394 trace_seq_printf(trace->seq, "\n"); in timerlat_print_summary()
396 if (!params->no_index) in timerlat_print_summary()
397 trace_seq_printf(trace->seq, "max: "); in timerlat_print_summary()
399 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_summary()
400 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_summary()
403 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_summary()
406 if (!params->no_irq) in timerlat_print_summary()
407 format_summary_value(trace->seq, in timerlat_print_summary()
408 data->hist[cpu].irq_count, in timerlat_print_summary()
409 data->hist[cpu].max_irq, in timerlat_print_summary()
412 if (!params->no_thread) in timerlat_print_summary()
413 format_summary_value(trace->seq, in timerlat_print_summary()
414 data->hist[cpu].thread_count, in timerlat_print_summary()
415 data->hist[cpu].max_thread, in timerlat_print_summary()
418 if (params->user_hist) in timerlat_print_summary()
419 format_summary_value(trace->seq, in timerlat_print_summary()
420 data->hist[cpu].user_count, in timerlat_print_summary()
421 data->hist[cpu].max_user, in timerlat_print_summary()
424 trace_seq_printf(trace->seq, "\n"); in timerlat_print_summary()
425 trace_seq_do_printf(trace->seq); in timerlat_print_summary()
426 trace_seq_reset(trace->seq); in timerlat_print_summary()
438 if (params->no_summary) in timerlat_print_stats_all()
446 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_stats_all()
447 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_stats_all()
450 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_stats_all()
453 cpu_data = &data->hist[cpu]; in timerlat_print_stats_all()
455 sum.irq_count += cpu_data->irq_count; in timerlat_print_stats_all()
456 update_min(&sum.min_irq, &cpu_data->min_irq); in timerlat_print_stats_all()
457 update_sum(&sum.sum_irq, &cpu_data->sum_irq); in timerlat_print_stats_all()
458 update_max(&sum.max_irq, &cpu_data->max_irq); in timerlat_print_stats_all()
460 sum.thread_count += cpu_data->thread_count; in timerlat_print_stats_all()
461 update_min(&sum.min_thread, &cpu_data->min_thread); in timerlat_print_stats_all()
462 update_sum(&sum.sum_thread, &cpu_data->sum_thread); in timerlat_print_stats_all()
463 update_max(&sum.max_thread, &cpu_data->max_thread); in timerlat_print_stats_all()
465 sum.user_count += cpu_data->user_count; in timerlat_print_stats_all()
466 update_min(&sum.min_user, &cpu_data->min_user); in timerlat_print_stats_all()
467 update_sum(&sum.sum_user, &cpu_data->sum_user); in timerlat_print_stats_all()
468 update_max(&sum.max_user, &cpu_data->max_user); in timerlat_print_stats_all()
471 if (!params->no_index) in timerlat_print_stats_all()
472 trace_seq_printf(trace->seq, "ALL: "); in timerlat_print_stats_all()
474 if (!params->no_irq) in timerlat_print_stats_all()
475 trace_seq_printf(trace->seq, " IRQ"); in timerlat_print_stats_all()
477 if (!params->no_thread) in timerlat_print_stats_all()
478 trace_seq_printf(trace->seq, " Thr"); in timerlat_print_stats_all()
480 if (params->user_hist) in timerlat_print_stats_all()
481 trace_seq_printf(trace->seq, " Usr"); in timerlat_print_stats_all()
483 trace_seq_printf(trace->seq, "\n"); in timerlat_print_stats_all()
485 if (!params->no_index) in timerlat_print_stats_all()
486 trace_seq_printf(trace->seq, "count:"); in timerlat_print_stats_all()
488 if (!params->no_irq) in timerlat_print_stats_all()
489 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_stats_all()
492 if (!params->no_thread) in timerlat_print_stats_all()
493 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_stats_all()
496 if (params->user_hist) in timerlat_print_stats_all()
497 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_stats_all()
500 trace_seq_printf(trace->seq, "\n"); in timerlat_print_stats_all()
502 if (!params->no_index) in timerlat_print_stats_all()
503 trace_seq_printf(trace->seq, "min: "); in timerlat_print_stats_all()
505 if (!params->no_irq) in timerlat_print_stats_all()
506 format_summary_value(trace->seq, in timerlat_print_stats_all()
511 if (!params->no_thread) in timerlat_print_stats_all()
512 format_summary_value(trace->seq, in timerlat_print_stats_all()
517 if (params->user_hist) in timerlat_print_stats_all()
518 format_summary_value(trace->seq, in timerlat_print_stats_all()
523 trace_seq_printf(trace->seq, "\n"); in timerlat_print_stats_all()
525 if (!params->no_index) in timerlat_print_stats_all()
526 trace_seq_printf(trace->seq, "avg: "); in timerlat_print_stats_all()
528 if (!params->no_irq) in timerlat_print_stats_all()
529 format_summary_value(trace->seq, in timerlat_print_stats_all()
534 if (!params->no_thread) in timerlat_print_stats_all()
535 format_summary_value(trace->seq, in timerlat_print_stats_all()
540 if (params->user_hist) in timerlat_print_stats_all()
541 format_summary_value(trace->seq, in timerlat_print_stats_all()
546 trace_seq_printf(trace->seq, "\n"); in timerlat_print_stats_all()
548 if (!params->no_index) in timerlat_print_stats_all()
549 trace_seq_printf(trace->seq, "max: "); in timerlat_print_stats_all()
551 if (!params->no_irq) in timerlat_print_stats_all()
552 format_summary_value(trace->seq, in timerlat_print_stats_all()
557 if (!params->no_thread) in timerlat_print_stats_all()
558 format_summary_value(trace->seq, in timerlat_print_stats_all()
563 if (params->user_hist) in timerlat_print_stats_all()
564 format_summary_value(trace->seq, in timerlat_print_stats_all()
569 trace_seq_printf(trace->seq, "\n"); in timerlat_print_stats_all()
570 trace_seq_do_printf(trace->seq); in timerlat_print_stats_all()
571 trace_seq_reset(trace->seq); in timerlat_print_stats_all()
575 * timerlat_print_stats - print data for each CPUs
580 struct timerlat_hist_data *data = tool->data; in timerlat_print_stats()
581 struct trace_instance *trace = &tool->trace; in timerlat_print_stats()
587 for (bucket = 0; bucket < data->entries; bucket++) { in timerlat_print_stats()
590 if (!params->no_index) in timerlat_print_stats()
591 trace_seq_printf(trace->seq, "%-6d", in timerlat_print_stats()
592 bucket * data->bucket_size); in timerlat_print_stats()
594 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_stats()
595 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_stats()
598 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_stats()
601 if (!params->no_irq) { in timerlat_print_stats()
602 total += data->hist[cpu].irq[bucket]; in timerlat_print_stats()
603 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
604 data->hist[cpu].irq[bucket]); in timerlat_print_stats()
607 if (!params->no_thread) { in timerlat_print_stats()
608 total += data->hist[cpu].thread[bucket]; in timerlat_print_stats()
609 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
610 data->hist[cpu].thread[bucket]); in timerlat_print_stats()
613 if (params->user_hist) { in timerlat_print_stats()
614 total += data->hist[cpu].user[bucket]; in timerlat_print_stats()
615 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
616 data->hist[cpu].user[bucket]); in timerlat_print_stats()
621 if (total == 0 && !params->with_zeros) { in timerlat_print_stats()
622 trace_seq_reset(trace->seq); in timerlat_print_stats()
626 trace_seq_printf(trace->seq, "\n"); in timerlat_print_stats()
627 trace_seq_do_printf(trace->seq); in timerlat_print_stats()
628 trace_seq_reset(trace->seq); in timerlat_print_stats()
631 if (!params->no_index) in timerlat_print_stats()
632 trace_seq_printf(trace->seq, "over: "); in timerlat_print_stats()
634 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_stats()
635 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_stats()
638 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_stats()
641 if (!params->no_irq) in timerlat_print_stats()
642 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
643 data->hist[cpu].irq[data->entries]); in timerlat_print_stats()
645 if (!params->no_thread) in timerlat_print_stats()
646 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
647 data->hist[cpu].thread[data->entries]); in timerlat_print_stats()
649 if (params->user_hist) in timerlat_print_stats()
650 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
651 data->hist[cpu].user[data->entries]); in timerlat_print_stats()
653 trace_seq_printf(trace->seq, "\n"); in timerlat_print_stats()
654 trace_seq_do_printf(trace->seq); in timerlat_print_stats()
655 trace_seq_reset(trace->seq); in timerlat_print_stats()
662 * timerlat_hist_usage - prints timerlat top usage message
670 …" usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-a us] [-p us] [-i us] [-T us] [-s us] … in timerlat_hist_usage()
671 …" [-t[file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] [-H … in timerlat_hist_usage()
672 " [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\", in timerlat_hist_usage()
673 …" [--no-index] [--with-zeros] [--dma-latency us] [-C[=cgroup_name]] [--no-aa] [--dump-task] [-u| in timerlat_hist_usage()
674 " [--warm-up s] [--deepest-idle-state n]", in timerlat_hist_usage()
676 " -h/--help: print this menu", in timerlat_hist_usage()
677 " -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit", in timerlat_hist_usage()
678 " -p/--period us: timerlat period in us", in timerlat_hist_usage()
679 " -i/--irq us: stop trace if the irq latency is higher than the argument in us", in timerlat_hist_usage()
680 " -T/--thread us: stop trace if the thread latency is higher than the argument in us", in timerlat_hist_usage()
681 …" -s/--stack us: save the stack trace at the IRQ if a thread latency is higher than the argument… in timerlat_hist_usage()
682 " -c/--cpus cpus: run the tracer only on the given cpus", in timerlat_hist_usage()
683 " -H/--house-keeping cpus: run rtla control threads only on the given cpus", in timerlat_hist_usage()
684 …" -C/--cgroup[=cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be … in timerlat_hist_usage()
685 " -d/--duration time[m|h|d]: duration of the session in seconds", in timerlat_hist_usage()
686 …" --dump-tasks: prints the task running on all CPUs if stop conditions are met (depends on !-… in timerlat_hist_usage()
687 " -D/--debug: print debug info", in timerlat_hist_usage()
688 " -t/--trace[file]: save the stopped trace to [file|timerlat_trace.txt]", in timerlat_hist_usage()
689 …" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed", in timerlat_hist_usage()
690 " --filter <filter>: enable a trace event filter to the previous -e event", in timerlat_hist_usage()
691 " --trigger <trigger>: enable a trace event trigger to the previous -e event", in timerlat_hist_usage()
692 " -n/--nano: display data in nanoseconds", in timerlat_hist_usage()
693 " --no-aa: disable auto-analysis, reducing rtla timerlat cpu usage", in timerlat_hist_usage()
694 " -b/--bucket-size N: set the histogram bucket size (default 1)", in timerlat_hist_usage()
695 " -E/--entries N: set the number of entries of the histogram (default 256)", in timerlat_hist_usage()
696 " --no-irq: ignore IRQ latencies", in timerlat_hist_usage()
697 " --no-thread: ignore thread latencies", in timerlat_hist_usage()
698 " --no-header: do not print header", in timerlat_hist_usage()
699 " --no-summary: do not print summary", in timerlat_hist_usage()
700 " --no-index: do not print index", in timerlat_hist_usage()
701 " --with-zeros: print zero only entries", in timerlat_hist_usage()
702 " --dma-latency us: set /dev/cpu_dma_latency latency <us> to reduce exit from idle latency", in timerlat_hist_usage()
703 " -P/--priority o:prio|r:prio|f:prio|d:runtime:period : set scheduling parameters", in timerlat_hist_usage()
704 " o:prio - use SCHED_OTHER with prio", in timerlat_hist_usage()
705 " r:prio - use SCHED_RR with prio", in timerlat_hist_usage()
706 " f:prio - use SCHED_FIFO with prio", in timerlat_hist_usage()
707 " d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period", in timerlat_hist_usage()
709 " -u/--user-threads: use rtla user-space threads instead of kernel-space timerlat threads", in timerlat_hist_usage()
710 " -k/--kernel-threads: use timerlat kernel-space threads instead of rtla user-space threads", in timerlat_hist_usage()
711 " -U/--user-load: enable timerlat for user-defined user-space workload", in timerlat_hist_usage()
712 " --warm-up s: let the workload run for s seconds before collecting data", in timerlat_hist_usage()
713 " --trace-buffer-size kB: set the per-cpu trace buffer size in kB", in timerlat_hist_usage()
714 …" --deepest-idle-state n: only go down to idle state n on cpus used by timerlat to reduce exi… in timerlat_hist_usage()
721 fprintf(stderr, "rtla timerlat hist: a per-cpu histogram of the timer latency (version %s)\n", in timerlat_hist_usage()
734 * timerlat_hist_parse_args - allocs, parse and fill the cmd line parameters
750 params->dma_latency = -1; in timerlat_hist_parse_args()
753 params->deepest_idle_state = -2; in timerlat_hist_parse_args()
756 params->output_divisor = 1000; in timerlat_hist_parse_args()
757 params->bucket_size = 1; in timerlat_hist_parse_args()
758 params->entries = 256; in timerlat_hist_parse_args()
765 {"bucket-size", required_argument, 0, 'b'}, in timerlat_hist_parse_args()
768 {"duration", required_argument, 0, 'd'}, in timerlat_hist_parse_args()
769 {"house-keeping", required_argument, 0, 'H'}, in timerlat_hist_parse_args()
778 {"user-threads", no_argument, 0, 'u'}, in timerlat_hist_parse_args()
779 {"kernel-threads", no_argument, 0, 'k'}, in timerlat_hist_parse_args()
780 {"user-load", no_argument, 0, 'U'}, in timerlat_hist_parse_args()
782 {"no-irq", no_argument, 0, '0'}, in timerlat_hist_parse_args()
783 {"no-thread", no_argument, 0, '1'}, in timerlat_hist_parse_args()
784 {"no-header", no_argument, 0, '2'}, in timerlat_hist_parse_args()
785 {"no-summary", no_argument, 0, '3'}, in timerlat_hist_parse_args()
786 {"no-index", no_argument, 0, '4'}, in timerlat_hist_parse_args()
787 {"with-zeros", no_argument, 0, '5'}, in timerlat_hist_parse_args()
790 {"dma-latency", required_argument, 0, '8'}, in timerlat_hist_parse_args()
791 {"no-aa", no_argument, 0, '9'}, in timerlat_hist_parse_args()
792 {"dump-task", no_argument, 0, '\1'}, in timerlat_hist_parse_args()
793 {"warm-up", required_argument, 0, '\2'}, in timerlat_hist_parse_args()
794 {"trace-buffer-size", required_argument, 0, '\3'}, in timerlat_hist_parse_args()
795 {"deepest-idle-state", required_argument, 0, '\4'}, in timerlat_hist_parse_args()
806 if (c == -1) in timerlat_hist_parse_args()
814 params->stop_total_us = auto_thresh; in timerlat_hist_parse_args()
815 params->stop_us = auto_thresh; in timerlat_hist_parse_args()
818 params->print_stack = auto_thresh; in timerlat_hist_parse_args()
821 params->trace_output = "timerlat_trace.txt"; in timerlat_hist_parse_args()
825 retval = parse_cpu_set(optarg, &params->monitored_cpus); in timerlat_hist_parse_args()
827 timerlat_hist_usage("\nInvalid -c cpu list\n"); in timerlat_hist_parse_args()
828 params->cpus = optarg; in timerlat_hist_parse_args()
831 params->cgroup = 1; in timerlat_hist_parse_args()
834 params->cgroup_name = NULL; in timerlat_hist_parse_args()
837 params->cgroup_name = ++optarg; in timerlat_hist_parse_args()
841 params->bucket_size = get_llong_from_str(optarg); in timerlat_hist_parse_args()
842 if ((params->bucket_size == 0) || (params->bucket_size >= 1000000)) in timerlat_hist_parse_args()
849 params->duration = parse_seconds_duration(optarg); in timerlat_hist_parse_args()
850 if (!params->duration) in timerlat_hist_parse_args()
851 timerlat_hist_usage("Invalid -D duration\n"); in timerlat_hist_parse_args()
860 if (params->events) in timerlat_hist_parse_args()
861 tevent->next = params->events; in timerlat_hist_parse_args()
863 params->events = tevent; in timerlat_hist_parse_args()
866 params->entries = get_llong_from_str(optarg); in timerlat_hist_parse_args()
867 if ((params->entries < 10) || (params->entries > 9999999)) in timerlat_hist_parse_args()
875 params->hk_cpus = 1; in timerlat_hist_parse_args()
876 retval = parse_cpu_set(optarg, &params->hk_cpu_set); in timerlat_hist_parse_args()
883 params->stop_us = get_llong_from_str(optarg); in timerlat_hist_parse_args()
886 params->kernel_workload = 1; in timerlat_hist_parse_args()
889 params->output_divisor = 1; in timerlat_hist_parse_args()
892 params->timerlat_period_us = get_llong_from_str(optarg); in timerlat_hist_parse_args()
893 if (params->timerlat_period_us > 1000000) in timerlat_hist_parse_args()
897 retval = parse_prio(optarg, &params->sched_param); in timerlat_hist_parse_args()
898 if (retval == -1) in timerlat_hist_parse_args()
899 timerlat_hist_usage("Invalid -P priority"); in timerlat_hist_parse_args()
900 params->set_sched = 1; in timerlat_hist_parse_args()
903 params->print_stack = get_llong_from_str(optarg); in timerlat_hist_parse_args()
906 params->stop_total_us = get_llong_from_str(optarg); in timerlat_hist_parse_args()
911 params->trace_output = &optarg[1]; in timerlat_hist_parse_args()
913 params->trace_output = &optarg[0]; in timerlat_hist_parse_args()
914 } else if (optind < argc && argv[optind][0] != '-') in timerlat_hist_parse_args()
915 params->trace_output = argv[optind]; in timerlat_hist_parse_args()
917 params->trace_output = "timerlat_trace.txt"; in timerlat_hist_parse_args()
920 params->user_workload = 1; in timerlat_hist_parse_args()
921 /* fallback: -u implies in -U */ in timerlat_hist_parse_args()
923 params->user_hist = 1; in timerlat_hist_parse_args()
926 params->no_irq = 1; in timerlat_hist_parse_args()
929 params->no_thread = 1; in timerlat_hist_parse_args()
932 params->no_header = 1; in timerlat_hist_parse_args()
935 params->no_summary = 1; in timerlat_hist_parse_args()
938 params->no_index = 1; in timerlat_hist_parse_args()
941 params->with_zeros = 1; in timerlat_hist_parse_args()
944 if (params->events) { in timerlat_hist_parse_args()
945 retval = trace_event_add_trigger(params->events, optarg); in timerlat_hist_parse_args()
951 timerlat_hist_usage("--trigger requires a previous -e\n"); in timerlat_hist_parse_args()
955 if (params->events) { in timerlat_hist_parse_args()
956 retval = trace_event_add_filter(params->events, optarg); in timerlat_hist_parse_args()
962 timerlat_hist_usage("--filter requires a previous -e\n"); in timerlat_hist_parse_args()
966 params->dma_latency = get_llong_from_str(optarg); in timerlat_hist_parse_args()
967 if (params->dma_latency < 0 || params->dma_latency > 10000) { in timerlat_hist_parse_args()
968 err_msg("--dma-latency needs to be >= 0 and < 10000"); in timerlat_hist_parse_args()
973 params->no_aa = 1; in timerlat_hist_parse_args()
976 params->dump_tasks = 1; in timerlat_hist_parse_args()
979 params->warmup = get_llong_from_str(optarg); in timerlat_hist_parse_args()
982 params->buffer_size = get_llong_from_str(optarg); in timerlat_hist_parse_args()
985 params->deepest_idle_state = get_llong_from_str(optarg); in timerlat_hist_parse_args()
997 if (params->no_irq && params->no_thread) in timerlat_hist_parse_args()
998 timerlat_hist_usage("no-irq and no-thread set, there is nothing to do here"); in timerlat_hist_parse_args()
1000 if (params->no_index && !params->with_zeros) in timerlat_hist_parse_args()
1001 timerlat_hist_usage("no-index set with with-zeros is not set - it does not make sense"); in timerlat_hist_parse_args()
1006 if (!params->stop_us && !params->stop_total_us) in timerlat_hist_parse_args()
1007 params->no_aa = 1; in timerlat_hist_parse_args()
1009 if (params->kernel_workload && params->user_workload) in timerlat_hist_parse_args()
1010 timerlat_hist_usage("--kernel-threads and --user-threads are mutually exclusive!"); in timerlat_hist_parse_args()
1016 * timerlat_hist_apply_config - apply the hist configs to the initialized tool
1023 if (!params->sleep_time) in timerlat_hist_apply_config()
1024 params->sleep_time = 1; in timerlat_hist_apply_config()
1026 if (params->cpus) { in timerlat_hist_apply_config()
1027 retval = osnoise_set_cpus(tool->context, params->cpus); in timerlat_hist_apply_config()
1034 CPU_SET(i, &params->monitored_cpus); in timerlat_hist_apply_config()
1037 if (params->stop_us) { in timerlat_hist_apply_config()
1038 retval = osnoise_set_stop_us(tool->context, params->stop_us); in timerlat_hist_apply_config()
1040 err_msg("Failed to set stop us\n"); in timerlat_hist_apply_config()
1045 if (params->stop_total_us) { in timerlat_hist_apply_config()
1046 retval = osnoise_set_stop_total_us(tool->context, params->stop_total_us); in timerlat_hist_apply_config()
1048 err_msg("Failed to set stop total us\n"); in timerlat_hist_apply_config()
1053 if (params->timerlat_period_us) { in timerlat_hist_apply_config()
1054 retval = osnoise_set_timerlat_period_us(tool->context, params->timerlat_period_us); in timerlat_hist_apply_config()
1061 if (params->print_stack) { in timerlat_hist_apply_config()
1062 retval = osnoise_set_print_stack(tool->context, params->print_stack); in timerlat_hist_apply_config()
1069 if (params->hk_cpus) { in timerlat_hist_apply_config()
1070 retval = sched_setaffinity(getpid(), sizeof(params->hk_cpu_set), in timerlat_hist_apply_config()
1071 &params->hk_cpu_set); in timerlat_hist_apply_config()
1072 if (retval == -1) { in timerlat_hist_apply_config()
1076 } else if (params->cpus) { in timerlat_hist_apply_config()
1078 * Even if the user do not set a house-keeping CPU, try to in timerlat_hist_apply_config()
1084 auto_house_keeping(&params->monitored_cpus); in timerlat_hist_apply_config()
1088 * If the user did not specify a type of thread, try user-threads first. in timerlat_hist_apply_config()
1091 if (!params->kernel_workload && !params->user_hist) { in timerlat_hist_apply_config()
1094 debug_msg("User-space interface detected, setting user-threads\n"); in timerlat_hist_apply_config()
1095 params->user_workload = 1; in timerlat_hist_apply_config()
1096 params->user_hist = 1; in timerlat_hist_apply_config()
1098 debug_msg("User-space interface not detected, setting kernel-threads\n"); in timerlat_hist_apply_config()
1099 params->kernel_workload = 1; in timerlat_hist_apply_config()
1103 if (params->user_hist) { in timerlat_hist_apply_config()
1104 retval = osnoise_set_workload(tool->context, 0); in timerlat_hist_apply_config()
1114 return -1; in timerlat_hist_apply_config()
1118 * timerlat_init_hist - initialize a timerlat hist tool with parameters
1132 tool->data = timerlat_alloc_histogram(nr_cpus, params->entries, params->bucket_size); in timerlat_init_hist()
1133 if (!tool->data) in timerlat_init_hist()
1136 tool->params = params; in timerlat_init_hist()
1138 tep_register_event_handler(tool->trace.tep, -1, "ftrace", "timerlat", in timerlat_init_hist()
1155 * timerlat_hist_set_signals - handles the signal to stop the tool
1161 if (params->duration) { in timerlat_hist_set_signals()
1163 alarm(params->duration); in timerlat_hist_set_signals()
1175 int dma_latency_fd = -1; in timerlat_hist_main()
1197 trace = &tool->trace; in timerlat_hist_main()
1205 if (params->set_sched) { in timerlat_hist_main()
1206 retval = set_comm_sched_attr("timerlat/", &params->sched_param); in timerlat_hist_main()
1213 if (params->cgroup && !params->user_workload) { in timerlat_hist_main()
1214 retval = set_comm_cgroup("timerlat/", params->cgroup_name); in timerlat_hist_main()
1221 if (params->dma_latency >= 0) { in timerlat_hist_main()
1222 dma_latency_fd = set_cpu_dma_latency(params->dma_latency); in timerlat_hist_main()
1229 if (params->deepest_idle_state >= -1) { in timerlat_hist_main()
1231 err_msg("rtla built without libcpupower, --deepest-idle-state is not supported\n"); in timerlat_hist_main()
1238 if (params->cpus && !CPU_ISSET(i, &params->monitored_cpus)) in timerlat_hist_main()
1244 if (set_deepest_cpu_idle_state(i, params->deepest_idle_state) < 0) { in timerlat_hist_main()
1251 if (params->trace_output) { in timerlat_hist_main()
1258 if (params->events) { in timerlat_hist_main()
1259 retval = trace_events_enable(&record->trace, params->events); in timerlat_hist_main()
1264 if (params->buffer_size > 0) { in timerlat_hist_main()
1265 retval = trace_set_buffer_size(&record->trace, params->buffer_size); in timerlat_hist_main()
1271 if (!params->no_aa) { in timerlat_hist_main()
1276 retval = timerlat_aa_init(aa, params->dump_tasks); in timerlat_hist_main()
1282 retval = enable_timerlat(&aa->trace); in timerlat_hist_main()
1289 if (params->user_workload) { in timerlat_hist_main()
1295 params_u.set = &params->monitored_cpus; in timerlat_hist_main()
1296 if (params->set_sched) in timerlat_hist_main()
1297 params_u.sched_param = &params->sched_param; in timerlat_hist_main()
1301 params_u.cgroup_name = params->cgroup_name; in timerlat_hist_main()
1305 err_msg("Error creating timerlat user-space threads\n"); in timerlat_hist_main()
1308 if (params->warmup > 0) { in timerlat_hist_main()
1309 debug_msg("Warming up for %d seconds\n", params->warmup); in timerlat_hist_main()
1310 sleep(params->warmup); in timerlat_hist_main()
1322 if (params->trace_output) in timerlat_hist_main()
1323 trace_instance_start(&record->trace); in timerlat_hist_main()
1324 if (!params->no_aa) in timerlat_hist_main()
1325 trace_instance_start(&aa->trace); in timerlat_hist_main()
1328 tool->start_time = time(NULL); in timerlat_hist_main()
1332 sleep(params->sleep_time); in timerlat_hist_main()
1334 retval = tracefs_iterate_raw_events(trace->tep, in timerlat_hist_main()
1335 trace->inst, in timerlat_hist_main()
1345 if (trace_is_off(&tool->trace, &record->trace)) in timerlat_hist_main()
1348 /* is there still any user-threads ? */ in timerlat_hist_main()
1349 if (params->user_workload) { in timerlat_hist_main()
1351 debug_msg("timerlat user-space threads stopped!\n"); in timerlat_hist_main()
1357 if (params->user_workload && !params_u.stopped_running) { in timerlat_hist_main()
1366 if (trace_is_off(&tool->trace, &record->trace)) { in timerlat_hist_main()
1369 if (!params->no_aa) in timerlat_hist_main()
1370 timerlat_auto_analysis(params->stop_us, params->stop_total_us); in timerlat_hist_main()
1372 if (params->trace_output) { in timerlat_hist_main()
1373 printf(" Saving trace to %s\n", params->trace_output); in timerlat_hist_main()
1374 save_trace_to_file(record->trace.inst, params->trace_output); in timerlat_hist_main()
1382 if (params->deepest_idle_state >= -1) { in timerlat_hist_main()
1384 if (params->cpus && !CPU_ISSET(i, &params->monitored_cpus)) in timerlat_hist_main()
1389 trace_events_destroy(&record->trace, params->events); in timerlat_hist_main()
1390 params->events = NULL; in timerlat_hist_main()
1392 timerlat_free_histogram(tool->data); in timerlat_hist_main()