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, ¶ms->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, ¶ms->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, "%9d ", 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, "%9d ", 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, "%9d ", 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, ¶ms->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 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
328 data->hist[cpu].min_irq); in timerlat_print_summary()
330 if (!params->no_thread) in timerlat_print_summary()
331 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
332 data->hist[cpu].min_thread); in timerlat_print_summary()
334 if (params->user_hist) in timerlat_print_summary()
335 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
336 data->hist[cpu].min_user); in timerlat_print_summary()
338 trace_seq_printf(trace->seq, "\n"); in timerlat_print_summary()
340 if (!params->no_index) in timerlat_print_summary()
341 trace_seq_printf(trace->seq, "avg: "); in timerlat_print_summary()
343 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_summary()
344 if (params->cpus && !CPU_ISSET(cpu, ¶ms->monitored_cpus)) in timerlat_print_summary()
347 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_summary()
350 if (!params->no_irq) { in timerlat_print_summary()
351 if (data->hist[cpu].irq_count) in timerlat_print_summary()
352 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
353 data->hist[cpu].sum_irq / data->hist[cpu].irq_count); in timerlat_print_summary()
355 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
358 if (!params->no_thread) { in timerlat_print_summary()
359 if (data->hist[cpu].thread_count) in timerlat_print_summary()
360 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
361 data->hist[cpu].sum_thread / data->hist[cpu].thread_count); in timerlat_print_summary()
363 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
366 if (params->user_hist) { in timerlat_print_summary()
367 if (data->hist[cpu].user_count) in timerlat_print_summary()
368 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
369 data->hist[cpu].sum_user / data->hist[cpu].user_count); in timerlat_print_summary()
371 trace_seq_printf(trace->seq, " - "); in timerlat_print_summary()
374 trace_seq_printf(trace->seq, "\n"); in timerlat_print_summary()
376 if (!params->no_index) in timerlat_print_summary()
377 trace_seq_printf(trace->seq, "max: "); in timerlat_print_summary()
379 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_summary()
380 if (params->cpus && !CPU_ISSET(cpu, ¶ms->monitored_cpus)) in timerlat_print_summary()
383 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_summary()
386 if (!params->no_irq) in timerlat_print_summary()
387 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
388 data->hist[cpu].max_irq); in timerlat_print_summary()
390 if (!params->no_thread) in timerlat_print_summary()
391 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
392 data->hist[cpu].max_thread); in timerlat_print_summary()
394 if (params->user_hist) in timerlat_print_summary()
395 trace_seq_printf(trace->seq, "%9llu ", in timerlat_print_summary()
396 data->hist[cpu].max_user); in timerlat_print_summary()
398 trace_seq_printf(trace->seq, "\n"); in timerlat_print_summary()
399 trace_seq_do_printf(trace->seq); in timerlat_print_summary()
400 trace_seq_reset(trace->seq); in timerlat_print_summary()
404 * timerlat_print_stats - print data for all CPUs
409 struct timerlat_hist_data *data = tool->data; in timerlat_print_stats()
410 struct trace_instance *trace = &tool->trace; in timerlat_print_stats()
416 for (bucket = 0; bucket < data->entries; bucket++) { in timerlat_print_stats()
419 if (!params->no_index) in timerlat_print_stats()
420 trace_seq_printf(trace->seq, "%-6d", in timerlat_print_stats()
421 bucket * data->bucket_size); in timerlat_print_stats()
423 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_stats()
424 if (params->cpus && !CPU_ISSET(cpu, ¶ms->monitored_cpus)) in timerlat_print_stats()
427 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_stats()
430 if (!params->no_irq) { in timerlat_print_stats()
431 total += data->hist[cpu].irq[bucket]; in timerlat_print_stats()
432 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
433 data->hist[cpu].irq[bucket]); in timerlat_print_stats()
436 if (!params->no_thread) { in timerlat_print_stats()
437 total += data->hist[cpu].thread[bucket]; in timerlat_print_stats()
438 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
439 data->hist[cpu].thread[bucket]); in timerlat_print_stats()
442 if (params->user_hist) { in timerlat_print_stats()
443 total += data->hist[cpu].user[bucket]; in timerlat_print_stats()
444 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
445 data->hist[cpu].user[bucket]); in timerlat_print_stats()
450 if (total == 0 && !params->with_zeros) { in timerlat_print_stats()
451 trace_seq_reset(trace->seq); in timerlat_print_stats()
455 trace_seq_printf(trace->seq, "\n"); in timerlat_print_stats()
456 trace_seq_do_printf(trace->seq); in timerlat_print_stats()
457 trace_seq_reset(trace->seq); in timerlat_print_stats()
460 if (!params->no_index) in timerlat_print_stats()
461 trace_seq_printf(trace->seq, "over: "); in timerlat_print_stats()
463 for (cpu = 0; cpu < data->nr_cpus; cpu++) { in timerlat_print_stats()
464 if (params->cpus && !CPU_ISSET(cpu, ¶ms->monitored_cpus)) in timerlat_print_stats()
467 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) in timerlat_print_stats()
470 if (!params->no_irq) in timerlat_print_stats()
471 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
472 data->hist[cpu].irq[data->entries]); in timerlat_print_stats()
474 if (!params->no_thread) in timerlat_print_stats()
475 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
476 data->hist[cpu].thread[data->entries]); in timerlat_print_stats()
478 if (params->user_hist) in timerlat_print_stats()
479 trace_seq_printf(trace->seq, "%9d ", in timerlat_print_stats()
480 data->hist[cpu].user[data->entries]); in timerlat_print_stats()
482 trace_seq_printf(trace->seq, "\n"); in timerlat_print_stats()
483 trace_seq_do_printf(trace->seq); in timerlat_print_stats()
484 trace_seq_reset(trace->seq); in timerlat_print_stats()
490 * timerlat_hist_usage - prints timerlat top usage message
498 …" usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-a us] [-p us] [-i us] [-T us] [-s us] … in timerlat_hist_usage()
499 …" [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] [-H… in timerlat_hist_usage()
500 " [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\", in timerlat_hist_usage()
501 …" [--no-index] [--with-zeros] [--dma-latency us] [-C[=cgroup_name]] [--no-aa] [--dump-task] [-u]… in timerlat_hist_usage()
503 " -h/--help: print this menu", in timerlat_hist_usage()
504 " -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit", in timerlat_hist_usage()
505 " -p/--period us: timerlat period in us", in timerlat_hist_usage()
506 " -i/--irq us: stop trace if the irq latency is higher than the argument in us", in timerlat_hist_usage()
507 " -T/--thread us: stop trace if the thread latency is higher than the argument in us", in timerlat_hist_usage()
508 …" -s/--stack us: save the stack trace at the IRQ if a thread latency is higher than the argument… in timerlat_hist_usage()
509 " -c/--cpus cpus: run the tracer only on the given cpus", in timerlat_hist_usage()
510 " -H/--house-keeping cpus: run rtla control threads only on the given cpus", in timerlat_hist_usage()
511 …" -C/--cgroup[=cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be … in timerlat_hist_usage()
512 " -d/--duration time[m|h|d]: duration of the session in seconds", in timerlat_hist_usage()
513 …" --dump-tasks: prints the task running on all CPUs if stop conditions are met (depends on !-… in timerlat_hist_usage()
514 " -D/--debug: print debug info", in timerlat_hist_usage()
515 " -t/--trace[=file]: save the stopped trace to [file|timerlat_trace.txt]", in timerlat_hist_usage()
516 …" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed", in timerlat_hist_usage()
517 " --filter <filter>: enable a trace event filter to the previous -e event", in timerlat_hist_usage()
518 " --trigger <trigger>: enable a trace event trigger to the previous -e event", in timerlat_hist_usage()
519 " -n/--nano: display data in nanoseconds", in timerlat_hist_usage()
520 " --no-aa: disable auto-analysis, reducing rtla timerlat cpu usage", in timerlat_hist_usage()
521 " -b/--bucket-size N: set the histogram bucket size (default 1)", in timerlat_hist_usage()
522 " -E/--entries N: set the number of entries of the histogram (default 256)", in timerlat_hist_usage()
523 " --no-irq: ignore IRQ latencies", in timerlat_hist_usage()
524 " --no-thread: ignore thread latencies", in timerlat_hist_usage()
525 " --no-header: do not print header", in timerlat_hist_usage()
526 " --no-summary: do not print summary", in timerlat_hist_usage()
527 " --no-index: do not print index", in timerlat_hist_usage()
528 " --with-zeros: print zero only entries", in timerlat_hist_usage()
529 " --dma-latency us: set /dev/cpu_dma_latency latency <us> to reduce exit from idle latency", in timerlat_hist_usage()
530 " -P/--priority o:prio|r:prio|f:prio|d:runtime:period : set scheduling parameters", in timerlat_hist_usage()
531 " o:prio - use SCHED_OTHER with prio", in timerlat_hist_usage()
532 " r:prio - use SCHED_RR with prio", in timerlat_hist_usage()
533 " f:prio - use SCHED_FIFO with prio", in timerlat_hist_usage()
534 " d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period", in timerlat_hist_usage()
536 " -u/--user-threads: use rtla user-space threads instead of in-kernel timerlat threads", in timerlat_hist_usage()
543 fprintf(stderr, "rtla timerlat hist: a per-cpu histogram of the timer latency (version %s)\n", in timerlat_hist_usage()
550 exit(EXIT_FAILURE); in timerlat_hist_usage()
552 exit(EXIT_SUCCESS); in timerlat_hist_usage()
556 * timerlat_hist_parse_args - allocs, parse and fill the cmd line parameters
569 exit(1); in timerlat_hist_parse_args()
572 params->dma_latency = -1; in timerlat_hist_parse_args()
575 params->output_divisor = 1000; in timerlat_hist_parse_args()
576 params->bucket_size = 1; in timerlat_hist_parse_args()
577 params->entries = 256; in timerlat_hist_parse_args()
584 {"bucket-size", required_argument, 0, 'b'}, in timerlat_hist_parse_args()
588 {"house-keeping", required_argument, 0, 'H'}, in timerlat_hist_parse_args()
597 {"user-threads", no_argument, 0, 'u'}, in timerlat_hist_parse_args()
599 {"no-irq", no_argument, 0, '0'}, in timerlat_hist_parse_args()
600 {"no-thread", no_argument, 0, '1'}, in timerlat_hist_parse_args()
601 {"no-header", no_argument, 0, '2'}, in timerlat_hist_parse_args()
602 {"no-summary", no_argument, 0, '3'}, in timerlat_hist_parse_args()
603 {"no-index", no_argument, 0, '4'}, in timerlat_hist_parse_args()
604 {"with-zeros", no_argument, 0, '5'}, in timerlat_hist_parse_args()
607 {"dma-latency", required_argument, 0, '8'}, in timerlat_hist_parse_args()
608 {"no-aa", no_argument, 0, '9'}, in timerlat_hist_parse_args()
609 {"dump-task", no_argument, 0, '\1'}, in timerlat_hist_parse_args()
620 if (c == -1) in timerlat_hist_parse_args()
628 params->stop_total_us = auto_thresh; in timerlat_hist_parse_args()
629 params->stop_us = auto_thresh; in timerlat_hist_parse_args()
632 params->print_stack = auto_thresh; in timerlat_hist_parse_args()
635 params->trace_output = "timerlat_trace.txt"; in timerlat_hist_parse_args()
639 retval = parse_cpu_set(optarg, ¶ms->monitored_cpus); in timerlat_hist_parse_args()
641 timerlat_hist_usage("\nInvalid -c cpu list\n"); in timerlat_hist_parse_args()
642 params->cpus = optarg; in timerlat_hist_parse_args()
645 params->cgroup = 1; in timerlat_hist_parse_args()
648 params->cgroup_name = NULL; in timerlat_hist_parse_args()
651 params->cgroup_name = ++optarg; in timerlat_hist_parse_args()
655 params->bucket_size = get_llong_from_str(optarg); in timerlat_hist_parse_args()
656 if ((params->bucket_size == 0) || (params->bucket_size >= 1000000)) in timerlat_hist_parse_args()
663 params->duration = parse_seconds_duration(optarg); in timerlat_hist_parse_args()
664 if (!params->duration) in timerlat_hist_parse_args()
665 timerlat_hist_usage("Invalid -D duration\n"); in timerlat_hist_parse_args()
671 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
674 if (params->events) in timerlat_hist_parse_args()
675 tevent->next = params->events; in timerlat_hist_parse_args()
677 params->events = tevent; in timerlat_hist_parse_args()
680 params->entries = get_llong_from_str(optarg); in timerlat_hist_parse_args()
681 if ((params->entries < 10) || (params->entries > 9999999)) in timerlat_hist_parse_args()
689 params->hk_cpus = 1; in timerlat_hist_parse_args()
690 retval = parse_cpu_set(optarg, ¶ms->hk_cpu_set); in timerlat_hist_parse_args()
693 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
697 params->stop_us = get_llong_from_str(optarg); in timerlat_hist_parse_args()
700 params->output_divisor = 1; in timerlat_hist_parse_args()
703 params->timerlat_period_us = get_llong_from_str(optarg); in timerlat_hist_parse_args()
704 if (params->timerlat_period_us > 1000000) in timerlat_hist_parse_args()
708 retval = parse_prio(optarg, ¶ms->sched_param); in timerlat_hist_parse_args()
709 if (retval == -1) in timerlat_hist_parse_args()
710 timerlat_hist_usage("Invalid -P priority"); in timerlat_hist_parse_args()
711 params->set_sched = 1; in timerlat_hist_parse_args()
714 params->print_stack = get_llong_from_str(optarg); in timerlat_hist_parse_args()
717 params->stop_total_us = get_llong_from_str(optarg); in timerlat_hist_parse_args()
722 params->trace_output = &optarg[1]; in timerlat_hist_parse_args()
724 params->trace_output = "timerlat_trace.txt"; in timerlat_hist_parse_args()
727 params->user_hist = 1; in timerlat_hist_parse_args()
730 params->no_irq = 1; in timerlat_hist_parse_args()
733 params->no_thread = 1; in timerlat_hist_parse_args()
736 params->no_header = 1; in timerlat_hist_parse_args()
739 params->no_summary = 1; in timerlat_hist_parse_args()
742 params->no_index = 1; in timerlat_hist_parse_args()
745 params->with_zeros = 1; in timerlat_hist_parse_args()
748 if (params->events) { in timerlat_hist_parse_args()
749 retval = trace_event_add_trigger(params->events, optarg); in timerlat_hist_parse_args()
752 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
755 timerlat_hist_usage("--trigger requires a previous -e\n"); in timerlat_hist_parse_args()
759 if (params->events) { in timerlat_hist_parse_args()
760 retval = trace_event_add_filter(params->events, optarg); in timerlat_hist_parse_args()
763 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
766 timerlat_hist_usage("--filter requires a previous -e\n"); in timerlat_hist_parse_args()
770 params->dma_latency = get_llong_from_str(optarg); in timerlat_hist_parse_args()
771 if (params->dma_latency < 0 || params->dma_latency > 10000) { in timerlat_hist_parse_args()
772 err_msg("--dma-latency needs to be >= 0 and < 10000"); in timerlat_hist_parse_args()
773 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
777 params->no_aa = 1; in timerlat_hist_parse_args()
780 params->dump_tasks = 1; in timerlat_hist_parse_args()
789 exit(EXIT_FAILURE); in timerlat_hist_parse_args()
792 if (params->no_irq && params->no_thread) in timerlat_hist_parse_args()
793 timerlat_hist_usage("no-irq and no-thread set, there is nothing to do here"); in timerlat_hist_parse_args()
795 if (params->no_index && !params->with_zeros) in timerlat_hist_parse_args()
796 timerlat_hist_usage("no-index set with with-zeros is not set - it does not make sense"); in timerlat_hist_parse_args()
801 if (!params->stop_us && !params->stop_total_us) in timerlat_hist_parse_args()
802 params->no_aa = 1; in timerlat_hist_parse_args()
808 * timerlat_hist_apply_config - apply the hist configs to the initialized tool
815 if (!params->sleep_time) in timerlat_hist_apply_config()
816 params->sleep_time = 1; in timerlat_hist_apply_config()
818 if (params->cpus) { in timerlat_hist_apply_config()
819 retval = osnoise_set_cpus(tool->context, params->cpus); in timerlat_hist_apply_config()
826 CPU_SET(i, ¶ms->monitored_cpus); in timerlat_hist_apply_config()
829 if (params->stop_us) { in timerlat_hist_apply_config()
830 retval = osnoise_set_stop_us(tool->context, params->stop_us); in timerlat_hist_apply_config()
832 err_msg("Failed to set stop us\n"); in timerlat_hist_apply_config()
837 if (params->stop_total_us) { in timerlat_hist_apply_config()
838 retval = osnoise_set_stop_total_us(tool->context, params->stop_total_us); in timerlat_hist_apply_config()
840 err_msg("Failed to set stop total us\n"); in timerlat_hist_apply_config()
845 if (params->timerlat_period_us) { in timerlat_hist_apply_config()
846 retval = osnoise_set_timerlat_period_us(tool->context, params->timerlat_period_us); in timerlat_hist_apply_config()
853 if (params->print_stack) { in timerlat_hist_apply_config()
854 retval = osnoise_set_print_stack(tool->context, params->print_stack); in timerlat_hist_apply_config()
861 if (params->hk_cpus) { in timerlat_hist_apply_config()
862 retval = sched_setaffinity(getpid(), sizeof(params->hk_cpu_set), in timerlat_hist_apply_config()
863 ¶ms->hk_cpu_set); in timerlat_hist_apply_config()
864 if (retval == -1) { in timerlat_hist_apply_config()
868 } else if (params->cpus) { in timerlat_hist_apply_config()
870 * Even if the user do not set a house-keeping CPU, try to in timerlat_hist_apply_config()
876 auto_house_keeping(¶ms->monitored_cpus); in timerlat_hist_apply_config()
879 if (params->user_hist) { in timerlat_hist_apply_config()
880 retval = osnoise_set_workload(tool->context, 0); in timerlat_hist_apply_config()
890 return -1; in timerlat_hist_apply_config()
894 * timerlat_init_hist - initialize a timerlat hist tool with parameters
908 tool->data = timerlat_alloc_histogram(nr_cpus, params->entries, params->bucket_size); in timerlat_init_hist()
909 if (!tool->data) in timerlat_init_hist()
912 tool->params = params; in timerlat_init_hist()
914 tep_register_event_handler(tool->trace.tep, -1, "ftrace", "timerlat", in timerlat_init_hist()
931 * timerlat_hist_set_signals - handles the signal to stop the tool
937 if (params->duration) { in timerlat_hist_set_signals()
939 alarm(params->duration); in timerlat_hist_set_signals()
951 int dma_latency_fd = -1; in timerlat_hist_main()
958 exit(1); in timerlat_hist_main()
972 trace = &tool->trace; in timerlat_hist_main()
980 if (params->set_sched) { in timerlat_hist_main()
981 retval = set_comm_sched_attr("timerlat/", ¶ms->sched_param); in timerlat_hist_main()
988 if (params->cgroup && !params->user_hist) { in timerlat_hist_main()
989 retval = set_comm_cgroup("timerlat/", params->cgroup_name); in timerlat_hist_main()
996 if (params->dma_latency >= 0) { in timerlat_hist_main()
997 dma_latency_fd = set_cpu_dma_latency(params->dma_latency); in timerlat_hist_main()
1004 if (params->trace_output) { in timerlat_hist_main()
1011 if (params->events) { in timerlat_hist_main()
1012 retval = trace_events_enable(&record->trace, params->events); in timerlat_hist_main()
1018 if (!params->no_aa) { in timerlat_hist_main()
1023 retval = timerlat_aa_init(aa, params->dump_tasks); in timerlat_hist_main()
1029 retval = enable_timerlat(&aa->trace); in timerlat_hist_main()
1043 if (params->trace_output) in timerlat_hist_main()
1044 trace_instance_start(&record->trace); in timerlat_hist_main()
1045 if (!params->no_aa) in timerlat_hist_main()
1046 trace_instance_start(&aa->trace); in timerlat_hist_main()
1049 tool->start_time = time(NULL); in timerlat_hist_main()
1052 if (params->user_hist) { in timerlat_hist_main()
1058 params_u.set = ¶ms->monitored_cpus; in timerlat_hist_main()
1059 if (params->set_sched) in timerlat_hist_main()
1060 params_u.sched_param = ¶ms->sched_param; in timerlat_hist_main()
1064 params_u.cgroup_name = params->cgroup_name; in timerlat_hist_main()
1068 err_msg("Error creating timerlat user-space threads\n"); in timerlat_hist_main()
1072 sleep(params->sleep_time); in timerlat_hist_main()
1074 retval = tracefs_iterate_raw_events(trace->tep, in timerlat_hist_main()
1075 trace->inst, in timerlat_hist_main()
1085 if (trace_is_off(&tool->trace, &record->trace)) in timerlat_hist_main()
1088 /* is there still any user-threads ? */ in timerlat_hist_main()
1089 if (params->user_hist) { in timerlat_hist_main()
1091 debug_msg("timerlat user-space threads stopped!\n"); in timerlat_hist_main()
1096 if (params->user_hist && !params_u.stopped_running) { in timerlat_hist_main()
1105 if (trace_is_off(&tool->trace, &record->trace)) { in timerlat_hist_main()
1108 if (!params->no_aa) in timerlat_hist_main()
1109 timerlat_auto_analysis(params->stop_us, params->stop_total_us); in timerlat_hist_main()
1111 if (params->trace_output) { in timerlat_hist_main()
1112 printf(" Saving trace to %s\n", params->trace_output); in timerlat_hist_main()
1113 save_trace_to_file(record->trace.inst, params->trace_output); in timerlat_hist_main()
1121 trace_events_destroy(&record->trace, params->events); in timerlat_hist_main()
1122 params->events = NULL; in timerlat_hist_main()
1124 timerlat_free_histogram(tool->data); in timerlat_hist_main()
1130 exit(return_value); in timerlat_hist_main()