Lines Matching +full:exit +full:- +full:latency +full:- +full:us

1 // SPDX-License-Identifier: GPL-2.0
86 * timerlat_free_histogram - free runtime data
94 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_free_histogram()
95 if (data->hist[cpu].irq) in timerlat_free_histogram()
96 free(data->hist[cpu].irq); in timerlat_free_histogram()
98 if (data->hist[cpu].thread) in timerlat_free_histogram()
99 free(data->hist[cpu].thread); in timerlat_free_histogram()
101 if (data->hist[cpu].user) in timerlat_free_histogram()
102 free(data->hist[cpu].user); in timerlat_free_histogram()
107 if (data->hist) in timerlat_free_histogram()
108 free(data->hist); in timerlat_free_histogram()
114 * timerlat_alloc_histogram - alloc runtime data
126 data->entries = entries; in timerlat_alloc_histogram()
127 data->bucket_size = bucket_size; in timerlat_alloc_histogram()
128 data->nr_cpus = nr_cpus; in timerlat_alloc_histogram()
131 data->hist = calloc(1, sizeof(*data->hist) * nr_cpus); in timerlat_alloc_histogram()
132 if (!data->hist) in timerlat_alloc_histogram()
137 data->hist[cpu].irq = calloc(1, sizeof(*data->hist->irq) * (entries + 1)); in timerlat_alloc_histogram()
138 if (!data->hist[cpu].irq) in timerlat_alloc_histogram()
141 data->hist[cpu].thread = calloc(1, sizeof(*data->hist->thread) * (entries + 1)); in timerlat_alloc_histogram()
142 if (!data->hist[cpu].thread) in timerlat_alloc_histogram()
145 data->hist[cpu].user = calloc(1, sizeof(*data->hist->user) * (entries + 1)); in timerlat_alloc_histogram()
146 if (!data->hist[cpu].user) in timerlat_alloc_histogram()
152 data->hist[cpu].min_irq = ~0; in timerlat_alloc_histogram()
153 data->hist[cpu].min_thread = ~0; in timerlat_alloc_histogram()
154 data->hist[cpu].min_user = ~0; in timerlat_alloc_histogram()
165 * timerlat_hist_update - record a new timerlat occurent on cpu, updating data
170 unsigned long long latency) in timerlat_hist_update() argument
172 struct timerlat_hist_params *params = tool->params; in timerlat_hist_update()
173 struct timerlat_hist_data *data = tool->data; in timerlat_hist_update()
174 int entries = data->entries; in timerlat_hist_update()
178 if (params->output_divisor) in timerlat_hist_update()
179 latency = latency / params->output_divisor; in timerlat_hist_update()
181 bucket = latency / data->bucket_size; in timerlat_hist_update()
184 hist = data->hist[cpu].irq; in timerlat_hist_update()
185 data->hist[cpu].irq_count++; in timerlat_hist_update()
186 update_min(&data->hist[cpu].min_irq, &latency); in timerlat_hist_update()
187 update_sum(&data->hist[cpu].sum_irq, &latency); in timerlat_hist_update()
188 update_max(&data->hist[cpu].max_irq, &latency); in timerlat_hist_update()
190 hist = data->hist[cpu].thread; in timerlat_hist_update()
191 data->hist[cpu].thread_count++; in timerlat_hist_update()
192 update_min(&data->hist[cpu].min_thread, &latency); in timerlat_hist_update()
193 update_sum(&data->hist[cpu].sum_thread, &latency); in timerlat_hist_update()
194 update_max(&data->hist[cpu].max_thread, &latency); in timerlat_hist_update()
196 hist = data->hist[cpu].user; in timerlat_hist_update()
197 data->hist[cpu].user_count++; in timerlat_hist_update()
198 update_min(&data->hist[cpu].min_user, &latency); in timerlat_hist_update()
199 update_sum(&data->hist[cpu].sum_user, &latency); in timerlat_hist_update()
200 update_max(&data->hist[cpu].max_user, &latency); in timerlat_hist_update()
210 * timerlat_hist_handler - this is the handler for timerlat tracer events
217 unsigned long long context, latency; in timerlat_hist_handler() local
219 int cpu = record->cpu; in timerlat_hist_handler()
224 tep_get_field_val(s, event, "timer_latency", record, &latency, 1); in timerlat_hist_handler()
226 timerlat_hist_update(tool, cpu, context, latency); in timerlat_hist_handler()
232 * timerlat_hist_header - print the header of the tracer to the output
236 struct timerlat_hist_params *params = tool->params; in timerlat_hist_header()
237 struct timerlat_hist_data *data = tool->data; in timerlat_hist_header()
238 struct trace_seq *s = tool->trace.seq; in timerlat_hist_header()
242 if (params->no_header) in timerlat_hist_header()
245 get_duration(tool->start_time, duration, sizeof(duration)); in timerlat_hist_header()
248 params->output_divisor == 1 ? "nanoseconds" : "microseconds", in timerlat_hist_header()
249 params->output_divisor == 1 ? "ns" : "us"); in timerlat_hist_header()
253 if (!params->no_index) in timerlat_hist_header()
256 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_hist_header()
257 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_hist_header()
260 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_hist_header()
263 if (!params->no_irq) in timerlat_hist_header()
264 trace_seq_printf(s, " IRQ-%03d", cpu); in timerlat_hist_header()
266 if (!params->no_thread) in timerlat_hist_header()
267 trace_seq_printf(s, " Thr-%03d", cpu); in timerlat_hist_header()
269 if (params->user_hist) in timerlat_hist_header()
270 trace_seq_printf(s, " Usr-%03d", cpu); in timerlat_hist_header()
280 * timerlat_print_summary - print the summary of the hist data to the output
289 if (params->no_summary) in timerlat_print_summary()
292 if (!params->no_index) in timerlat_print_summary()
293 trace_seq_printf(trace->seq, "count:"); in timerlat_print_summary()
295 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_summary()
296 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_summary()
299 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_summary()
302 if (!params->no_irq) in timerlat_print_summary()
303 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
304 data->hist[cpu].irq_count); in timerlat_print_summary()
306 if (!params->no_thread) in timerlat_print_summary()
307 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
308 data->hist[cpu].thread_count); in timerlat_print_summary()
310 if (params->user_hist) in timerlat_print_summary()
311 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
312 data->hist[cpu].user_count); in timerlat_print_summary()
314 trace_seq_printf(trace->seq, "\n"); in timerlat_print_summary()
316 if (!params->no_index) in timerlat_print_summary()
317 trace_seq_printf(trace->seq, "min: "); in timerlat_print_summary()
319 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_summary()
320 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_summary()
323 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_summary()
326 if (!params->no_irq) { in timerlat_print_summary()
327 if (data->hist[cpu].irq_count) in timerlat_print_summary()
328 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
329 data->hist[cpu].min_irq); in timerlat_print_summary()
331 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
334 if (!params->no_thread) { in timerlat_print_summary()
335 if (data->hist[cpu].thread_count) in timerlat_print_summary()
336 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
337 data->hist[cpu].min_thread); in timerlat_print_summary()
339 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
342 if (params->user_hist) { in timerlat_print_summary()
343 if (data->hist[cpu].user_count) in timerlat_print_summary()
344 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
345 data->hist[cpu].min_user); in timerlat_print_summary()
347 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
350 trace_seq_printf(trace->seq, "\n"); in timerlat_print_summary()
352 if (!params->no_index) in timerlat_print_summary()
353 trace_seq_printf(trace->seq, "avg: "); in timerlat_print_summary()
355 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_summary()
356 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_summary()
359 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_summary()
362 if (!params->no_irq) { in timerlat_print_summary()
363 if (data->hist[cpu].irq_count) in timerlat_print_summary()
364 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
365 data->hist[cpu].sum_irq / data->hist[cpu].irq_count); in timerlat_print_summary()
367 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
370 if (!params->no_thread) { in timerlat_print_summary()
371 if (data->hist[cpu].thread_count) in timerlat_print_summary()
372 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
373 data->hist[cpu].sum_thread / data->hist[cpu].thread_count); in timerlat_print_summary()
375 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
378 if (params->user_hist) { in timerlat_print_summary()
379 if (data->hist[cpu].user_count) in timerlat_print_summary()
380 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
381 data->hist[cpu].sum_user / data->hist[cpu].user_count); in timerlat_print_summary()
383 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
386 trace_seq_printf(trace->seq, "\n"); in timerlat_print_summary()
388 if (!params->no_index) in timerlat_print_summary()
389 trace_seq_printf(trace->seq, "max: "); in timerlat_print_summary()
391 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_summary()
392 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_summary()
395 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_summary()
398 if (!params->no_irq) { in timerlat_print_summary()
399 if (data->hist[cpu].irq_count) in timerlat_print_summary()
400 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
401 data->hist[cpu].max_irq); in timerlat_print_summary()
403 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
406 if (!params->no_thread) { in timerlat_print_summary()
407 if (data->hist[cpu].thread_count) in timerlat_print_summary()
408 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
409 data->hist[cpu].max_thread); in timerlat_print_summary()
411 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
414 if (params->user_hist) { in timerlat_print_summary()
415 if (data->hist[cpu].user_count) in timerlat_print_summary()
416 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
417 data->hist[cpu].max_user); in timerlat_print_summary()
419 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
422 trace_seq_printf(trace->seq, "\n"); in timerlat_print_summary()
423 trace_seq_do_printf(trace->seq); in timerlat_print_summary()
424 trace_seq_reset(trace->seq); in timerlat_print_summary()
428 * timerlat_print_stats - print data for all CPUs
433 struct timerlat_hist_data *data = tool->data; in timerlat_print_stats()
434 struct trace_instance *trace = &tool->trace; in timerlat_print_stats()
440 for (bucket = 0; bucket < data->entries; bucket++) { in timerlat_print_stats()
443 if (!params->no_index) in timerlat_print_stats()
444 trace_seq_printf(trace->seq, "%-6d", in timerlat_print_stats()
445 bucket * data->bucket_size); in timerlat_print_stats()
447 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_stats()
448 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_stats()
451 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_stats()
454 if (!params->no_irq) { in timerlat_print_stats()
455 total += data->hist[cpu].irq[bucket]; in timerlat_print_stats()
456 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
457 data->hist[cpu].irq[bucket]); in timerlat_print_stats()
460 if (!params->no_thread) { in timerlat_print_stats()
461 total += data->hist[cpu].thread[bucket]; in timerlat_print_stats()
462 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
463 data->hist[cpu].thread[bucket]); in timerlat_print_stats()
466 if (params->user_hist) { in timerlat_print_stats()
467 total += data->hist[cpu].user[bucket]; in timerlat_print_stats()
468 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
469 data->hist[cpu].user[bucket]); in timerlat_print_stats()
474 if (total == 0 && !params->with_zeros) { in timerlat_print_stats()
475 trace_seq_reset(trace->seq); in timerlat_print_stats()
479 trace_seq_printf(trace->seq, "\n"); in timerlat_print_stats()
480 trace_seq_do_printf(trace->seq); in timerlat_print_stats()
481 trace_seq_reset(trace->seq); in timerlat_print_stats()
484 if (!params->no_index) in timerlat_print_stats()
485 trace_seq_printf(trace->seq, "over: "); in timerlat_print_stats()
487 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_stats()
488 if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus)) in timerlat_print_stats()
491 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_stats()
494 if (!params->no_irq) in timerlat_print_stats()
495 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
496 data->hist[cpu].irq[data->entries]); in timerlat_print_stats()
498 if (!params->no_thread) in timerlat_print_stats()
499 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
500 data->hist[cpu].thread[data->entries]); in timerlat_print_stats()
502 if (params->user_hist) in timerlat_print_stats()
503 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
504 data->hist[cpu].user[data->entries]); in timerlat_print_stats()
506 trace_seq_printf(trace->seq, "\n"); in timerlat_print_stats()
507 trace_seq_do_printf(trace->seq); in timerlat_print_stats()
508 trace_seq_reset(trace->seq); in timerlat_print_stats()
514 * timerlat_hist_usage - prints timerlat top usage message
522 …" usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-a us] [-p us] [-i us] [-T us] [-s us] … in timerlat_hist_usage()
523 …" [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] [-H… in timerlat_hist_usage()
524 " [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\", in timerlat_hist_usage()
525 …" [--no-index] [--with-zeros] [--dma-latency us] [-C[=cgroup_name]] [--no-aa] [--dump-task] [-u]… in timerlat_hist_usage()
527 " -h/--help: print this menu", in timerlat_hist_usage()
528 " -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit", in timerlat_hist_usage()
529 " -p/--period us: timerlat period in us", in timerlat_hist_usage()
530 " -i/--irq us: stop trace if the irq latency is higher than the argument in us", in timerlat_hist_usage()
531 " -T/--thread us: stop trace if the thread latency is higher than the argument in us", in timerlat_hist_usage()
532 …" -s/--stack us: save the stack trace at the IRQ if a thread latency is higher than the argument… in timerlat_hist_usage()
533 " -c/--cpus cpus: run the tracer only on the given cpus", in timerlat_hist_usage()
534 " -H/--house-keeping cpus: run rtla control threads only on the given cpus", in timerlat_hist_usage()
535 …" -C/--cgroup[=cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be … in timerlat_hist_usage()
536 " -d/--duration time[m|h|d]: duration of the session in seconds", in timerlat_hist_usage()
537 …" --dump-tasks: prints the task running on all CPUs if stop conditions are met (depends on !-… in timerlat_hist_usage()
538 " -D/--debug: print debug info", in timerlat_hist_usage()
539 " -t/--trace[=file]: save the stopped trace to [file|timerlat_trace.txt]", in timerlat_hist_usage()
540 …" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed", in timerlat_hist_usage()
541 " --filter <filter>: enable a trace event filter to the previous -e event", in timerlat_hist_usage()
542 " --trigger <trigger>: enable a trace event trigger to the previous -e event", in timerlat_hist_usage()
543 " -n/--nano: display data in nanoseconds", in timerlat_hist_usage()
544 " --no-aa: disable auto-analysis, reducing rtla timerlat cpu usage", in timerlat_hist_usage()
545 " -b/--bucket-size N: set the histogram bucket size (default 1)", in timerlat_hist_usage()
546 " -E/--entries N: set the number of entries of the histogram (default 256)", in timerlat_hist_usage()
547 " --no-irq: ignore IRQ latencies", in timerlat_hist_usage()
548 " --no-thread: ignore thread latencies", in timerlat_hist_usage()
549 " --no-header: do not print header", in timerlat_hist_usage()
550 " --no-summary: do not print summary", in timerlat_hist_usage()
551 " --no-index: do not print index", in timerlat_hist_usage()
552 " --with-zeros: print zero only entries", in timerlat_hist_usage()
553 " --dma-latency us: set /dev/cpu_dma_latency latency <us> to reduce exit from idle latency", in timerlat_hist_usage()
554 " -P/--priority o:prio|r:prio|f:prio|d:runtime:period : set scheduling parameters", in timerlat_hist_usage()
555 " o:prio - use SCHED_OTHER with prio", in timerlat_hist_usage()
556 " r:prio - use SCHED_RR with prio", in timerlat_hist_usage()
557 " f:prio - use SCHED_FIFO with prio", in timerlat_hist_usage()
558 " d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period", in timerlat_hist_usage()
560 " -u/--user-threads: use rtla user-space threads instead of in-kernel timerlat threads", in timerlat_hist_usage()
567 fprintf(stderr, "rtla timerlat hist: a per-cpu histogram of the timer latency (version %s)\n", in timerlat_hist_usage()
574 exit(EXIT_FAILURE); in timerlat_hist_usage()
576 exit(EXIT_SUCCESS); in timerlat_hist_usage()
580 * timerlat_hist_parse_args - allocs, parse and fill the cmd line parameters
593 exit(1); in timerlat_hist_parse_args()
596 params->dma_latency = -1; in timerlat_hist_parse_args()
599 params->output_divisor = 1000; in timerlat_hist_parse_args()
600 params->bucket_size = 1; in timerlat_hist_parse_args()
601 params->entries = 256; in timerlat_hist_parse_args()
608 {"bucket-size", required_argument, 0, 'b'}, in timerlat_hist_parse_args()
612 {"house-keeping", required_argument, 0, 'H'}, in timerlat_hist_parse_args()
621 {"user-threads", no_argument, 0, 'u'}, in timerlat_hist_parse_args()
623 {"no-irq", no_argument, 0, '0'}, in timerlat_hist_parse_args()
624 {"no-thread", no_argument, 0, '1'}, in timerlat_hist_parse_args()
625 {"no-header", no_argument, 0, '2'}, in timerlat_hist_parse_args()
626 {"no-summary", no_argument, 0, '3'}, in timerlat_hist_parse_args()
627 {"no-index", no_argument, 0, '4'}, in timerlat_hist_parse_args()
628 {"with-zeros", no_argument, 0, '5'}, in timerlat_hist_parse_args()
631 {"dma-latency", required_argument, 0, '8'}, in timerlat_hist_parse_args()
632 {"no-aa", no_argument, 0, '9'}, in timerlat_hist_parse_args()
633 {"dump-task", no_argument, 0, '\1'}, in timerlat_hist_parse_args()
644 if (c == -1) in timerlat_hist_parse_args()
652 params->stop_total_us = auto_thresh; in timerlat_hist_parse_args()
653 params->stop_us = auto_thresh; in timerlat_hist_parse_args()
656 params->print_stack = auto_thresh; in timerlat_hist_parse_args()
659 params->trace_output = "timerlat_trace.txt"; in timerlat_hist_parse_args()
663 retval = parse_cpu_set(optarg, &params->monitored_cpus); in timerlat_hist_parse_args()
665 timerlat_hist_usage("\nInvalid -c cpu list\n"); in timerlat_hist_parse_args()
666 params->cpus = optarg; in timerlat_hist_parse_args()
669 params->cgroup = 1; in timerlat_hist_parse_args()
672 params->cgroup_name = NULL; in timerlat_hist_parse_args()
675 params->cgroup_name = ++optarg; in timerlat_hist_parse_args()
679 params->bucket_size = get_llong_from_str(optarg); in timerlat_hist_parse_args()
680 if ((params->bucket_size == 0) || (params->bucket_size >= 1000000)) in timerlat_hist_parse_args()
687 params->duration = parse_seconds_duration(optarg); in timerlat_hist_parse_args()
688 if (!params->duration) in timerlat_hist_parse_args()
689 timerlat_hist_usage("Invalid -D duration\n"); in timerlat_hist_parse_args()
695 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
698 if (params->events) in timerlat_hist_parse_args()
699 tevent->next = params->events; in timerlat_hist_parse_args()
701 params->events = tevent; in timerlat_hist_parse_args()
704 params->entries = get_llong_from_str(optarg); in timerlat_hist_parse_args()
705 if ((params->entries < 10) || (params->entries > 9999999)) in timerlat_hist_parse_args()
713 params->hk_cpus = 1; in timerlat_hist_parse_args()
714 retval = parse_cpu_set(optarg, &params->hk_cpu_set); in timerlat_hist_parse_args()
717 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
721 params->stop_us = get_llong_from_str(optarg); in timerlat_hist_parse_args()
724 params->output_divisor = 1; in timerlat_hist_parse_args()
727 params->timerlat_period_us = get_llong_from_str(optarg); in timerlat_hist_parse_args()
728 if (params->timerlat_period_us > 1000000) in timerlat_hist_parse_args()
732 retval = parse_prio(optarg, &params->sched_param); in timerlat_hist_parse_args()
733 if (retval == -1) in timerlat_hist_parse_args()
734 timerlat_hist_usage("Invalid -P priority"); in timerlat_hist_parse_args()
735 params->set_sched = 1; in timerlat_hist_parse_args()
738 params->print_stack = get_llong_from_str(optarg); in timerlat_hist_parse_args()
741 params->stop_total_us = get_llong_from_str(optarg); in timerlat_hist_parse_args()
746 params->trace_output = &optarg[1]; in timerlat_hist_parse_args()
748 params->trace_output = "timerlat_trace.txt"; in timerlat_hist_parse_args()
751 params->user_hist = 1; in timerlat_hist_parse_args()
754 params->no_irq = 1; in timerlat_hist_parse_args()
757 params->no_thread = 1; in timerlat_hist_parse_args()
760 params->no_header = 1; in timerlat_hist_parse_args()
763 params->no_summary = 1; in timerlat_hist_parse_args()
766 params->no_index = 1; in timerlat_hist_parse_args()
769 params->with_zeros = 1; in timerlat_hist_parse_args()
772 if (params->events) { in timerlat_hist_parse_args()
773 retval = trace_event_add_trigger(params->events, optarg); in timerlat_hist_parse_args()
776 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
779 timerlat_hist_usage("--trigger requires a previous -e\n"); in timerlat_hist_parse_args()
783 if (params->events) { in timerlat_hist_parse_args()
784 retval = trace_event_add_filter(params->events, optarg); in timerlat_hist_parse_args()
787 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
790 timerlat_hist_usage("--filter requires a previous -e\n"); in timerlat_hist_parse_args()
794 params->dma_latency = get_llong_from_str(optarg); in timerlat_hist_parse_args()
795 if (params->dma_latency < 0 || params->dma_latency > 10000) { in timerlat_hist_parse_args()
796 err_msg("--dma-latency needs to be >= 0 and < 10000"); in timerlat_hist_parse_args()
797 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
801 params->no_aa = 1; in timerlat_hist_parse_args()
804 params->dump_tasks = 1; in timerlat_hist_parse_args()
813 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
816 if (params->no_irq && params->no_thread) in timerlat_hist_parse_args()
817 timerlat_hist_usage("no-irq and no-thread set, there is nothing to do here"); in timerlat_hist_parse_args()
819 if (params->no_index && !params->with_zeros) in timerlat_hist_parse_args()
820 timerlat_hist_usage("no-index set with with-zeros is not set - it does not make sense"); in timerlat_hist_parse_args()
825 if (!params->stop_us && !params->stop_total_us) in timerlat_hist_parse_args()
826 params->no_aa = 1; in timerlat_hist_parse_args()
832 * timerlat_hist_apply_config - apply the hist configs to the initialized tool
839 if (!params->sleep_time) in timerlat_hist_apply_config()
840 params->sleep_time = 1; in timerlat_hist_apply_config()
842 if (params->cpus) { in timerlat_hist_apply_config()
843 retval = osnoise_set_cpus(tool->context, params->cpus); in timerlat_hist_apply_config()
850 CPU_SET(i, &params->monitored_cpus); in timerlat_hist_apply_config()
853 if (params->stop_us) { in timerlat_hist_apply_config()
854 retval = osnoise_set_stop_us(tool->context, params->stop_us); in timerlat_hist_apply_config()
856 err_msg("Failed to set stop us\n"); in timerlat_hist_apply_config()
861 if (params->stop_total_us) { in timerlat_hist_apply_config()
862 retval = osnoise_set_stop_total_us(tool->context, params->stop_total_us); in timerlat_hist_apply_config()
864 err_msg("Failed to set stop total us\n"); in timerlat_hist_apply_config()
869 if (params->timerlat_period_us) { in timerlat_hist_apply_config()
870 retval = osnoise_set_timerlat_period_us(tool->context, params->timerlat_period_us); in timerlat_hist_apply_config()
877 if (params->print_stack) { in timerlat_hist_apply_config()
878 retval = osnoise_set_print_stack(tool->context, params->print_stack); in timerlat_hist_apply_config()
885 if (params->hk_cpus) { in timerlat_hist_apply_config()
886 retval = sched_setaffinity(getpid(), sizeof(params->hk_cpu_set), in timerlat_hist_apply_config()
887 &params->hk_cpu_set); in timerlat_hist_apply_config()
888 if (retval == -1) { in timerlat_hist_apply_config()
892 } else if (params->cpus) { in timerlat_hist_apply_config()
894 * Even if the user do not set a house-keeping CPU, try to in timerlat_hist_apply_config()
900 auto_house_keeping(&params->monitored_cpus); in timerlat_hist_apply_config()
908 retval = osnoise_set_workload(tool->context, !params->user_hist); in timerlat_hist_apply_config()
909 if (retval < -1) { in timerlat_hist_apply_config()
917 return -1; in timerlat_hist_apply_config()
921 * timerlat_init_hist - initialize a timerlat hist tool with parameters
935 tool->data = timerlat_alloc_histogram(nr_cpus, params->entries, params->bucket_size); in timerlat_init_hist()
936 if (!tool->data) in timerlat_init_hist()
939 tool->params = params; in timerlat_init_hist()
941 tep_register_event_handler(tool->trace.tep, -1, "ftrace", "timerlat", in timerlat_init_hist()
958 * exit immediately in stop_hist()
960 tracefs_iterate_stop(hist_inst->inst); in stop_hist()
969 * timerlat_hist_set_signals - handles the signal to stop the tool
975 if (params->duration) { in timerlat_hist_set_signals()
977 alarm(params->duration); in timerlat_hist_set_signals()
989 int dma_latency_fd = -1; in timerlat_hist_main()
996 exit(1); in timerlat_hist_main()
1010 trace = &tool->trace; in timerlat_hist_main()
1024 if (params->set_sched) { in timerlat_hist_main()
1025 retval = set_comm_sched_attr("timerlat/", &params->sched_param); in timerlat_hist_main()
1032 if (params->cgroup && !params->user_hist) { in timerlat_hist_main()
1033 retval = set_comm_cgroup("timerlat/", params->cgroup_name); in timerlat_hist_main()
1040 if (params->dma_latency >= 0) { in timerlat_hist_main()
1041 dma_latency_fd = set_cpu_dma_latency(params->dma_latency); in timerlat_hist_main()
1048 if (params->trace_output) { in timerlat_hist_main()
1055 if (params->events) { in timerlat_hist_main()
1056 retval = trace_events_enable(&record->trace, params->events); in timerlat_hist_main()
1062 if (!params->no_aa) { in timerlat_hist_main()
1067 retval = timerlat_aa_init(aa, params->dump_tasks); in timerlat_hist_main()
1073 retval = enable_timerlat(&aa->trace); in timerlat_hist_main()
1087 if (params->trace_output) in timerlat_hist_main()
1088 trace_instance_start(&record->trace); in timerlat_hist_main()
1089 if (!params->no_aa) in timerlat_hist_main()
1090 trace_instance_start(&aa->trace); in timerlat_hist_main()
1093 tool->start_time = time(NULL); in timerlat_hist_main()
1096 if (params->user_hist) { in timerlat_hist_main()
1102 params_u.set = &params->monitored_cpus; in timerlat_hist_main()
1103 if (params->set_sched) in timerlat_hist_main()
1104 params_u.sched_param = &params->sched_param; in timerlat_hist_main()
1108 params_u.cgroup_name = params->cgroup_name; in timerlat_hist_main()
1112 err_msg("Error creating timerlat user-space threads\n"); in timerlat_hist_main()
1116 sleep(params->sleep_time); in timerlat_hist_main()
1118 retval = tracefs_iterate_raw_events(trace->tep, in timerlat_hist_main()
1119 trace->inst, in timerlat_hist_main()
1129 if (trace_is_off(&tool->trace, &record->trace)) in timerlat_hist_main()
1132 /* is there still any user-threads ? */ in timerlat_hist_main()
1133 if (params->user_hist) { in timerlat_hist_main()
1135 debug_msg("timerlat user-space threads stopped!\n"); in timerlat_hist_main()
1140 if (params->user_hist && !params_u.stopped_running) { in timerlat_hist_main()
1149 if (trace_is_off(&tool->trace, &record->trace) && !stop_tracing) { in timerlat_hist_main()
1152 if (!params->no_aa) in timerlat_hist_main()
1153 timerlat_auto_analysis(params->stop_us, params->stop_total_us); in timerlat_hist_main()
1155 if (params->trace_output) { in timerlat_hist_main()
1156 printf(" Saving trace to %s\n", params->trace_output); in timerlat_hist_main()
1157 save_trace_to_file(record->trace.inst, params->trace_output); in timerlat_hist_main()
1165 trace_events_destroy(&record->trace, params->events); in timerlat_hist_main()
1166 params->events = NULL; in timerlat_hist_main()
1168 timerlat_free_histogram(tool->data); in timerlat_hist_main()
1174 exit(return_value); in timerlat_hist_main()