Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/rtla: Move top/hist params into common struct

The hist members were very similar between timerlat and top, so
just use one common hist struct.

output_divisor, quiet, and pretty printing are pretty generic
concepts that can go in the main struct even if not every
specific tool (currently) uses them.

Cc: John Kacur <jkacur@redhat.com>
Cc: Costa Shulyupin <costa.shul@redhat.com>
Link: https://lore.kernel.org/20250907022325.243930-3-crwood@redhat.com
Reviewed-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: Crystal Wood <crwood@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Crystal Wood and committed by
Steven Rostedt (Google)
5742bf62 34482388

+152 -163
+17
tools/tracing/rtla/src/common.h
··· 3 3 4 4 #include "utils.h" 5 5 6 + struct hist_params { 7 + char no_irq; 8 + char no_thread; 9 + char no_header; 10 + char no_summary; 11 + char no_index; 12 + char with_zeros; 13 + int bucket_size; 14 + int entries; 15 + }; 16 + 6 17 /* 7 18 * common_params - Parameters shared between timerlat_params and osnoise_params 8 19 */ ··· 38 27 char *cgroup_name; 39 28 int hk_cpus; 40 29 cpu_set_t hk_cpu_set; 30 + 31 + /* Other parameters */ 32 + struct hist_params hist; 33 + int output_divisor; 34 + int pretty_output; 35 + int quiet; 41 36 };
+1 -18
tools/tracing/rtla/src/osnoise.h
··· 15 15 unsigned long long runtime; 16 16 unsigned long long period; 17 17 long long threshold; 18 - union { 19 - struct { 20 - /* top only */ 21 - int quiet; 22 - int pretty_output; 23 - enum osnoise_mode mode; 24 - }; 25 - struct { 26 - /* hist only */ 27 - int output_divisor; 28 - char no_header; 29 - char no_summary; 30 - char no_index; 31 - char with_zeros; 32 - int bucket_size; 33 - int entries; 34 - }; 35 - }; 18 + enum osnoise_mode mode; 36 19 }; 37 20 38 21 /*
+31 -28
tools/tracing/rtla/src/osnoise_hist.c
··· 102 102 int bucket; 103 103 int *hist; 104 104 105 - if (params->output_divisor) 106 - duration = duration / params->output_divisor; 105 + if (params->common.output_divisor) 106 + duration = duration / params->common.output_divisor; 107 107 108 108 bucket = duration / data->bucket_size; 109 109 ··· 146 146 /* 147 147 * Set the size of the bucket. 148 148 */ 149 - bucket_size = params->output_divisor * params->bucket_size; 149 + bucket_size = params->common.output_divisor * params->common.hist.bucket_size; 150 150 snprintf(buff, sizeof(buff), "duration.buckets=%d", bucket_size); 151 151 152 152 data->trace_hist = tracefs_hist_alloc(tool->trace.tep, "osnoise", "sample_threshold", ··· 228 228 char duration[26]; 229 229 int cpu; 230 230 231 - if (params->no_header) 231 + if (params->common.hist.no_header) 232 232 return; 233 233 234 234 get_duration(tool->start_time, duration, sizeof(duration)); 235 235 trace_seq_printf(s, "# RTLA osnoise histogram\n"); 236 236 trace_seq_printf(s, "# Time unit is %s (%s)\n", 237 - params->output_divisor == 1 ? "nanoseconds" : "microseconds", 238 - params->output_divisor == 1 ? "ns" : "us"); 237 + params->common.output_divisor == 1 ? "nanoseconds" : "microseconds", 238 + params->common.output_divisor == 1 ? "ns" : "us"); 239 239 240 240 trace_seq_printf(s, "# Duration: %s\n", duration); 241 241 242 - if (!params->no_index) 242 + if (!params->common.hist.no_index) 243 243 trace_seq_printf(s, "Index"); 244 244 245 245 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 267 267 { 268 268 int cpu; 269 269 270 - if (params->no_summary) 270 + if (params->common.hist.no_summary) 271 271 return; 272 272 273 - if (!params->no_index) 273 + if (!params->common.hist.no_index) 274 274 trace_seq_printf(trace->seq, "count:"); 275 275 276 276 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 284 284 } 285 285 trace_seq_printf(trace->seq, "\n"); 286 286 287 - if (!params->no_index) 287 + if (!params->common.hist.no_index) 288 288 trace_seq_printf(trace->seq, "min: "); 289 289 290 290 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 299 299 } 300 300 trace_seq_printf(trace->seq, "\n"); 301 301 302 - if (!params->no_index) 302 + if (!params->common.hist.no_index) 303 303 trace_seq_printf(trace->seq, "avg: "); 304 304 305 305 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 317 317 } 318 318 trace_seq_printf(trace->seq, "\n"); 319 319 320 - if (!params->no_index) 320 + if (!params->common.hist.no_index) 321 321 trace_seq_printf(trace->seq, "max: "); 322 322 323 323 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 352 352 for (bucket = 0; bucket < data->entries; bucket++) { 353 353 total = 0; 354 354 355 - if (!params->no_index) 355 + if (!params->common.hist.no_index) 356 356 trace_seq_printf(trace->seq, "%-6d", 357 357 bucket * data->bucket_size); 358 358 ··· 367 367 trace_seq_printf(trace->seq, "%9d ", data->hist[cpu].samples[bucket]); 368 368 } 369 369 370 - if (total == 0 && !params->with_zeros) { 370 + if (total == 0 && !params->common.hist.with_zeros) { 371 371 trace_seq_reset(trace->seq); 372 372 continue; 373 373 } ··· 391 391 return; 392 392 } 393 393 394 - if (!params->no_index) 394 + if (!params->common.hist.no_index) 395 395 trace_seq_printf(trace->seq, "over: "); 396 396 397 397 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 490 490 exit(1); 491 491 492 492 /* display data in microseconds */ 493 - params->output_divisor = 1000; 494 - params->bucket_size = 1; 495 - params->entries = 256; 493 + params->common.output_divisor = 1000; 494 + params->common.hist.bucket_size = 1; 495 + params->common.hist.entries = 256; 496 496 497 497 while (1) { 498 498 static struct option long_options[] = { ··· 547 547 548 548 break; 549 549 case 'b': 550 - params->bucket_size = get_llong_from_str(optarg); 551 - if ((params->bucket_size == 0) || (params->bucket_size >= 1000000)) 550 + params->common.hist.bucket_size = get_llong_from_str(optarg); 551 + if (params->common.hist.bucket_size == 0 || 552 + params->common.hist.bucket_size >= 1000000) 552 553 osnoise_hist_usage("Bucket size needs to be > 0 and <= 1000000\n"); 553 554 break; 554 555 case 'c': ··· 589 588 params->common.events = tevent; 590 589 break; 591 590 case 'E': 592 - params->entries = get_llong_from_str(optarg); 593 - if ((params->entries < 10) || (params->entries > 9999999)) 591 + params->common.hist.entries = get_llong_from_str(optarg); 592 + if (params->common.hist.entries < 10 || 593 + params->common.hist.entries > 9999999) 594 594 osnoise_hist_usage("Entries must be > 10 and < 9999999\n"); 595 595 break; 596 596 case 'h': ··· 643 641 params->trace_output = "osnoise_trace.txt"; 644 642 break; 645 643 case '0': /* no header */ 646 - params->no_header = 1; 644 + params->common.hist.no_header = 1; 647 645 break; 648 646 case '1': /* no summary */ 649 - params->no_summary = 1; 647 + params->common.hist.no_summary = 1; 650 648 break; 651 649 case '2': /* no index */ 652 - params->no_index = 1; 650 + params->common.hist.no_index = 1; 653 651 break; 654 652 case '3': /* with zeros */ 655 - params->with_zeros = 1; 653 + params->common.hist.with_zeros = 1; 656 654 break; 657 655 case '4': /* trigger */ 658 656 if (params->common.events) { ··· 692 690 exit(EXIT_FAILURE); 693 691 } 694 692 695 - if (params->no_index && !params->with_zeros) 693 + if (params->common.hist.no_index && !params->common.hist.with_zeros) 696 694 osnoise_hist_usage("no-index set and with-zeros not set - it does not make sense"); 697 695 698 696 return params; ··· 731 729 if (!tool) 732 730 return NULL; 733 731 734 - tool->data = osnoise_alloc_histogram(nr_cpus, params->entries, params->bucket_size); 732 + tool->data = osnoise_alloc_histogram(nr_cpus, params->common.hist.entries, 733 + params->common.hist.bucket_size); 735 734 if (!tool->data) 736 735 goto out_err; 737 736
+10 -9
tools/tracing/rtla/src/osnoise_top.c
··· 125 125 { 126 126 struct osnoise_params *params = top->params; 127 127 struct trace_seq *s = top->trace.seq; 128 + bool pretty = params->common.pretty_output; 128 129 char duration[26]; 129 130 130 131 get_duration(top->start_time, duration, sizeof(duration)); 131 132 132 - if (params->pretty_output) 133 + if (pretty) 133 134 trace_seq_printf(s, "\033[2;37;40m"); 134 135 135 136 trace_seq_printf(s, " "); ··· 144 143 145 144 trace_seq_printf(s, " "); 146 145 147 - if (params->pretty_output) 146 + if (pretty) 148 147 trace_seq_printf(s, "\033[0;0;0m"); 149 148 trace_seq_printf(s, "\n"); 150 149 151 150 trace_seq_printf(s, "duration: %9s | time is in us\n", duration); 152 151 153 - if (params->pretty_output) 152 + if (pretty) 154 153 trace_seq_printf(s, "\033[2;30;47m"); 155 154 156 155 trace_seq_printf(s, "CPU Period Runtime "); ··· 165 164 trace_seq_printf(s, " IRQ Softirq Thread"); 166 165 167 166 eol: 168 - if (params->pretty_output) 167 + if (pretty) 169 168 trace_seq_printf(s, "\033[0;0;0m"); 170 169 trace_seq_printf(s, "\n"); 171 170 } ··· 233 232 if (nr_cpus == -1) 234 233 nr_cpus = sysconf(_SC_NPROCESSORS_CONF); 235 234 236 - if (!params->quiet) 235 + if (!params->common.quiet) 237 236 clear_terminal(trace->seq); 238 237 239 238 osnoise_top_header(top); ··· 447 446 params->common.set_sched = 1; 448 447 break; 449 448 case 'q': 450 - params->quiet = 1; 449 + params->common.quiet = 1; 451 450 break; 452 451 case 'r': 453 452 params->runtime = get_llong_from_str(optarg); ··· 535 534 } 536 535 } 537 536 538 - if (isatty(STDOUT_FILENO) && !params->quiet) 539 - params->pretty_output = 1; 537 + if (isatty(STDOUT_FILENO) && !params->common.quiet) 538 + params->common.pretty_output = 1; 540 539 541 540 return 0; 542 541 ··· 706 705 goto out_top; 707 706 } 708 707 709 - if (!params->quiet) 708 + if (!params->common.quiet) 710 709 osnoise_print_stats(params, tool); 711 710 712 711 if (osnoise_trace_is_off(tool, record))
+1 -21
tools/tracing/rtla/src/timerlat.h
··· 23 23 struct common_params common; 24 24 long long timerlat_period_us; 25 25 long long print_stack; 26 - int output_divisor; 27 26 int dma_latency; 28 27 int no_aa; 29 28 int dump_tasks; ··· 30 31 int kernel_workload; 31 32 int user_data; 32 33 int deepest_idle_state; 34 + int aa_only; 33 35 enum timerlat_tracing_mode mode; 34 36 35 37 struct actions threshold_actions; 36 38 struct actions end_actions; 37 - 38 - union { 39 - struct { 40 - /* top only */ 41 - int quiet; 42 - int aa_only; 43 - int pretty_output; 44 - }; 45 - struct { 46 - /* hist only */ 47 - char no_irq; 48 - char no_thread; 49 - char no_header; 50 - char no_summary; 51 - char no_index; 52 - char with_zeros; 53 - int bucket_size; 54 - int entries; 55 - }; 56 - }; 57 39 }; 58 40 59 41 int timerlat_apply_config(struct osnoise_tool *tool, struct timerlat_params *params);
+7 -7
tools/tracing/rtla/src/timerlat_bpf.c
··· 21 21 return 1; 22 22 23 23 /* Pass common options */ 24 - bpf->rodata->output_divisor = params->output_divisor; 25 - bpf->rodata->entries = params->entries; 24 + bpf->rodata->output_divisor = params->common.output_divisor; 25 + bpf->rodata->entries = params->common.hist.entries; 26 26 bpf->rodata->irq_threshold = params->common.stop_us; 27 27 bpf->rodata->thread_threshold = params->common.stop_total_us; 28 28 bpf->rodata->aa_only = params->aa_only; 29 29 30 - if (params->entries != 0) { 30 + if (params->common.hist.entries != 0) { 31 31 /* Pass histogram options */ 32 - bpf->rodata->bucket_size = params->bucket_size; 32 + bpf->rodata->bucket_size = params->common.hist.bucket_size; 33 33 34 34 /* Set histogram array sizes */ 35 - bpf_map__set_max_entries(bpf->maps.hist_irq, params->entries); 36 - bpf_map__set_max_entries(bpf->maps.hist_thread, params->entries); 37 - bpf_map__set_max_entries(bpf->maps.hist_user, params->entries); 35 + bpf_map__set_max_entries(bpf->maps.hist_irq, params->common.hist.entries); 36 + bpf_map__set_max_entries(bpf->maps.hist_thread, params->common.hist.entries); 37 + bpf_map__set_max_entries(bpf->maps.hist_user, params->common.hist.entries); 38 38 } else { 39 39 /* No entries, disable histogram */ 40 40 bpf_map__set_autocreate(bpf->maps.hist_irq, false);
+65 -62
tools/tracing/rtla/src/timerlat_hist.c
··· 141 141 int bucket; 142 142 int *hist; 143 143 144 - if (params->output_divisor) 145 - latency = latency / params->output_divisor; 144 + if (params->common.output_divisor) 145 + latency = latency / params->common.output_divisor; 146 146 147 147 bucket = latency / data->bucket_size; 148 148 ··· 288 288 char duration[26]; 289 289 int cpu; 290 290 291 - if (params->no_header) 291 + if (params->common.hist.no_header) 292 292 return; 293 293 294 294 get_duration(tool->start_time, duration, sizeof(duration)); 295 295 trace_seq_printf(s, "# RTLA timerlat histogram\n"); 296 296 trace_seq_printf(s, "# Time unit is %s (%s)\n", 297 - params->output_divisor == 1 ? "nanoseconds" : "microseconds", 298 - params->output_divisor == 1 ? "ns" : "us"); 297 + params->common.output_divisor == 1 ? "nanoseconds" : "microseconds", 298 + params->common.output_divisor == 1 ? "ns" : "us"); 299 299 300 300 trace_seq_printf(s, "# Duration: %s\n", duration); 301 301 302 - if (!params->no_index) 302 + if (!params->common.hist.no_index) 303 303 trace_seq_printf(s, "Index"); 304 304 305 305 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 309 309 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) 310 310 continue; 311 311 312 - if (!params->no_irq) 312 + if (!params->common.hist.no_irq) 313 313 trace_seq_printf(s, " IRQ-%03d", cpu); 314 314 315 - if (!params->no_thread) 315 + if (!params->common.hist.no_thread) 316 316 trace_seq_printf(s, " Thr-%03d", cpu); 317 317 318 318 if (params->user_data) ··· 350 350 { 351 351 int cpu; 352 352 353 - if (params->no_summary) 353 + if (params->common.hist.no_summary) 354 354 return; 355 355 356 - if (!params->no_index) 356 + if (!params->common.hist.no_index) 357 357 trace_seq_printf(trace->seq, "count:"); 358 358 359 359 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 363 363 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) 364 364 continue; 365 365 366 - if (!params->no_irq) 366 + if (!params->common.hist.no_irq) 367 367 trace_seq_printf(trace->seq, "%9llu ", 368 368 data->hist[cpu].irq_count); 369 369 370 - if (!params->no_thread) 370 + if (!params->common.hist.no_thread) 371 371 trace_seq_printf(trace->seq, "%9llu ", 372 372 data->hist[cpu].thread_count); 373 373 ··· 377 377 } 378 378 trace_seq_printf(trace->seq, "\n"); 379 379 380 - if (!params->no_index) 380 + if (!params->common.hist.no_index) 381 381 trace_seq_printf(trace->seq, "min: "); 382 382 383 383 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 387 387 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) 388 388 continue; 389 389 390 - if (!params->no_irq) 390 + if (!params->common.hist.no_irq) 391 391 format_summary_value(trace->seq, 392 392 data->hist[cpu].irq_count, 393 393 data->hist[cpu].min_irq, 394 394 false); 395 395 396 - if (!params->no_thread) 396 + if (!params->common.hist.no_thread) 397 397 format_summary_value(trace->seq, 398 398 data->hist[cpu].thread_count, 399 399 data->hist[cpu].min_thread, ··· 407 407 } 408 408 trace_seq_printf(trace->seq, "\n"); 409 409 410 - if (!params->no_index) 410 + if (!params->common.hist.no_index) 411 411 trace_seq_printf(trace->seq, "avg: "); 412 412 413 413 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 417 417 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) 418 418 continue; 419 419 420 - if (!params->no_irq) 420 + if (!params->common.hist.no_irq) 421 421 format_summary_value(trace->seq, 422 422 data->hist[cpu].irq_count, 423 423 data->hist[cpu].sum_irq, 424 424 true); 425 425 426 - if (!params->no_thread) 426 + if (!params->common.hist.no_thread) 427 427 format_summary_value(trace->seq, 428 428 data->hist[cpu].thread_count, 429 429 data->hist[cpu].sum_thread, ··· 437 437 } 438 438 trace_seq_printf(trace->seq, "\n"); 439 439 440 - if (!params->no_index) 440 + if (!params->common.hist.no_index) 441 441 trace_seq_printf(trace->seq, "max: "); 442 442 443 443 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 447 447 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) 448 448 continue; 449 449 450 - if (!params->no_irq) 450 + if (!params->common.hist.no_irq) 451 451 format_summary_value(trace->seq, 452 452 data->hist[cpu].irq_count, 453 453 data->hist[cpu].max_irq, 454 454 false); 455 455 456 - if (!params->no_thread) 456 + if (!params->common.hist.no_thread) 457 457 format_summary_value(trace->seq, 458 458 data->hist[cpu].thread_count, 459 459 data->hist[cpu].max_thread, ··· 479 479 struct timerlat_hist_cpu sum; 480 480 int cpu; 481 481 482 - if (params->no_summary) 482 + if (params->common.hist.no_summary) 483 483 return; 484 484 485 485 memset(&sum, 0, sizeof(sum)); ··· 512 512 update_max(&sum.max_user, &cpu_data->max_user); 513 513 } 514 514 515 - if (!params->no_index) 515 + if (!params->common.hist.no_index) 516 516 trace_seq_printf(trace->seq, "ALL: "); 517 517 518 - if (!params->no_irq) 518 + if (!params->common.hist.no_irq) 519 519 trace_seq_printf(trace->seq, " IRQ"); 520 520 521 - if (!params->no_thread) 521 + if (!params->common.hist.no_thread) 522 522 trace_seq_printf(trace->seq, " Thr"); 523 523 524 524 if (params->user_data) ··· 526 526 527 527 trace_seq_printf(trace->seq, "\n"); 528 528 529 - if (!params->no_index) 529 + if (!params->common.hist.no_index) 530 530 trace_seq_printf(trace->seq, "count:"); 531 531 532 - if (!params->no_irq) 532 + if (!params->common.hist.no_irq) 533 533 trace_seq_printf(trace->seq, "%9llu ", 534 534 sum.irq_count); 535 535 536 - if (!params->no_thread) 536 + if (!params->common.hist.no_thread) 537 537 trace_seq_printf(trace->seq, "%9llu ", 538 538 sum.thread_count); 539 539 ··· 543 543 544 544 trace_seq_printf(trace->seq, "\n"); 545 545 546 - if (!params->no_index) 546 + if (!params->common.hist.no_index) 547 547 trace_seq_printf(trace->seq, "min: "); 548 548 549 - if (!params->no_irq) 549 + if (!params->common.hist.no_irq) 550 550 format_summary_value(trace->seq, 551 551 sum.irq_count, 552 552 sum.min_irq, 553 553 false); 554 554 555 - if (!params->no_thread) 555 + if (!params->common.hist.no_thread) 556 556 format_summary_value(trace->seq, 557 557 sum.thread_count, 558 558 sum.min_thread, ··· 566 566 567 567 trace_seq_printf(trace->seq, "\n"); 568 568 569 - if (!params->no_index) 569 + if (!params->common.hist.no_index) 570 570 trace_seq_printf(trace->seq, "avg: "); 571 571 572 - if (!params->no_irq) 572 + if (!params->common.hist.no_irq) 573 573 format_summary_value(trace->seq, 574 574 sum.irq_count, 575 575 sum.sum_irq, 576 576 true); 577 577 578 - if (!params->no_thread) 578 + if (!params->common.hist.no_thread) 579 579 format_summary_value(trace->seq, 580 580 sum.thread_count, 581 581 sum.sum_thread, ··· 589 589 590 590 trace_seq_printf(trace->seq, "\n"); 591 591 592 - if (!params->no_index) 592 + if (!params->common.hist.no_index) 593 593 trace_seq_printf(trace->seq, "max: "); 594 594 595 - if (!params->no_irq) 595 + if (!params->common.hist.no_irq) 596 596 format_summary_value(trace->seq, 597 597 sum.irq_count, 598 598 sum.max_irq, 599 599 false); 600 600 601 - if (!params->no_thread) 601 + if (!params->common.hist.no_thread) 602 602 format_summary_value(trace->seq, 603 603 sum.thread_count, 604 604 sum.max_thread, ··· 631 631 for (bucket = 0; bucket < data->entries; bucket++) { 632 632 total = 0; 633 633 634 - if (!params->no_index) 634 + if (!params->common.hist.no_index) 635 635 trace_seq_printf(trace->seq, "%-6d", 636 636 bucket * data->bucket_size); 637 637 ··· 642 642 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) 643 643 continue; 644 644 645 - if (!params->no_irq) { 645 + if (!params->common.hist.no_irq) { 646 646 total += data->hist[cpu].irq[bucket]; 647 647 trace_seq_printf(trace->seq, "%9d ", 648 648 data->hist[cpu].irq[bucket]); 649 649 } 650 650 651 - if (!params->no_thread) { 651 + if (!params->common.hist.no_thread) { 652 652 total += data->hist[cpu].thread[bucket]; 653 653 trace_seq_printf(trace->seq, "%9d ", 654 654 data->hist[cpu].thread[bucket]); ··· 662 662 663 663 } 664 664 665 - if (total == 0 && !params->with_zeros) { 665 + if (total == 0 && !params->common.hist.with_zeros) { 666 666 trace_seq_reset(trace->seq); 667 667 continue; 668 668 } ··· 672 672 trace_seq_reset(trace->seq); 673 673 } 674 674 675 - if (!params->no_index) 675 + if (!params->common.hist.no_index) 676 676 trace_seq_printf(trace->seq, "over: "); 677 677 678 678 for (cpu = 0; cpu < data->nr_cpus; cpu++) { ··· 682 682 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) 683 683 continue; 684 684 685 - if (!params->no_irq) 685 + if (!params->common.hist.no_irq) 686 686 trace_seq_printf(trace->seq, "%9d ", 687 687 data->hist[cpu].irq[data->entries]); 688 688 689 - if (!params->no_thread) 689 + if (!params->common.hist.no_thread) 690 690 trace_seq_printf(trace->seq, "%9d ", 691 691 data->hist[cpu].thread[data->entries]); 692 692 ··· 804 804 params->deepest_idle_state = -2; 805 805 806 806 /* display data in microseconds */ 807 - params->output_divisor = 1000; 808 - params->bucket_size = 1; 809 - params->entries = 256; 807 + params->common.output_divisor = 1000; 808 + params->common.hist.bucket_size = 1; 809 + params->common.hist.entries = 256; 810 810 811 811 /* default to BPF mode */ 812 812 params->mode = TRACING_MODE_BPF; ··· 894 894 } 895 895 break; 896 896 case 'b': 897 - params->bucket_size = get_llong_from_str(optarg); 898 - if ((params->bucket_size == 0) || (params->bucket_size >= 1000000)) 897 + params->common.hist.bucket_size = get_llong_from_str(optarg); 898 + if (params->common.hist.bucket_size == 0 || 899 + params->common.hist.bucket_size >= 1000000) 899 900 timerlat_hist_usage("Bucket size needs to be > 0 and <= 1000000\n"); 900 901 break; 901 902 case 'D': ··· 920 919 params->common.events = tevent; 921 920 break; 922 921 case 'E': 923 - params->entries = get_llong_from_str(optarg); 924 - if ((params->entries < 10) || (params->entries > 9999999)) 925 - timerlat_hist_usage("Entries must be > 10 and < 9999999\n"); 922 + params->common.hist.entries = get_llong_from_str(optarg); 923 + if (params->common.hist.entries < 10 || 924 + params->common.hist.entries > 9999999) 925 + timerlat_hist_usage("Entries must be > 10 and < 9999999\n"); 926 926 break; 927 927 case 'h': 928 928 case '?': ··· 944 942 params->kernel_workload = 1; 945 943 break; 946 944 case 'n': 947 - params->output_divisor = 1; 945 + params->common.output_divisor = 1; 948 946 break; 949 947 case 'p': 950 948 params->timerlat_period_us = get_llong_from_str(optarg); ··· 981 979 params->user_data = 1; 982 980 break; 983 981 case '0': /* no irq */ 984 - params->no_irq = 1; 982 + params->common.hist.no_irq = 1; 985 983 break; 986 984 case '1': /* no thread */ 987 - params->no_thread = 1; 985 + params->common.hist.no_thread = 1; 988 986 break; 989 987 case '2': /* no header */ 990 - params->no_header = 1; 988 + params->common.hist.no_header = 1; 991 989 break; 992 990 case '3': /* no summary */ 993 - params->no_summary = 1; 991 + params->common.hist.no_summary = 1; 994 992 break; 995 993 case '4': /* no index */ 996 - params->no_index = 1; 994 + params->common.hist.no_index = 1; 997 995 break; 998 996 case '5': /* with zeros */ 999 - params->with_zeros = 1; 997 + params->common.hist.with_zeros = 1; 1000 998 break; 1001 999 case '6': /* trigger */ 1002 1000 if (params->common.events) { ··· 1069 1067 exit(EXIT_FAILURE); 1070 1068 } 1071 1069 1072 - if (params->no_irq && params->no_thread) 1070 + if (params->common.hist.no_irq && params->common.hist.no_thread) 1073 1071 timerlat_hist_usage("no-irq and no-thread set, there is nothing to do here"); 1074 1072 1075 - if (params->no_index && !params->with_zeros) 1073 + if (params->common.hist.no_index && !params->common.hist.with_zeros) 1076 1074 timerlat_hist_usage("no-index set with with-zeros is not set - it does not make sense"); 1077 1075 1078 1076 /* ··· 1129 1127 if (!tool) 1130 1128 return NULL; 1131 1129 1132 - tool->data = timerlat_alloc_histogram(nr_cpus, params->entries, params->bucket_size); 1130 + tool->data = timerlat_alloc_histogram(nr_cpus, params->common.hist.entries, 1131 + params->common.hist.bucket_size); 1133 1132 if (!tool->data) 1134 1133 goto out_err; 1135 1134
+20 -18
tools/tracing/rtla/src/timerlat_top.c
··· 132 132 struct timerlat_top_data *data = tool->data; 133 133 struct timerlat_top_cpu *cpu_data = &data->cpu_data[cpu]; 134 134 135 - if (params->output_divisor) 136 - latency = latency / params->output_divisor; 135 + if (params->common.output_divisor) 136 + latency = latency / params->common.output_divisor; 137 137 138 138 if (!thread) { 139 139 cpu_data->irq_count++; ··· 258 258 static void timerlat_top_header(struct timerlat_params *params, struct osnoise_tool *top) 259 259 { 260 260 struct trace_seq *s = top->trace.seq; 261 + bool pretty = params->common.pretty_output; 261 262 char duration[26]; 262 263 263 264 get_duration(top->start_time, duration, sizeof(duration)); 264 265 265 - if (params->pretty_output) 266 + if (pretty) 266 267 trace_seq_printf(s, "\033[2;37;40m"); 267 268 268 269 trace_seq_printf(s, " Timer Latency "); 269 270 if (params->user_data) 270 271 trace_seq_printf(s, " "); 271 272 272 - if (params->pretty_output) 273 + if (pretty) 273 274 trace_seq_printf(s, "\033[0;0;0m"); 274 275 trace_seq_printf(s, "\n"); 275 276 276 277 trace_seq_printf(s, "%-6s | IRQ Timer Latency (%s) | Thread Timer Latency (%s)", duration, 277 - params->output_divisor == 1 ? "ns" : "us", 278 - params->output_divisor == 1 ? "ns" : "us"); 278 + params->common.output_divisor == 1 ? "ns" : "us", 279 + params->common.output_divisor == 1 ? "ns" : "us"); 279 280 280 281 if (params->user_data) { 281 282 trace_seq_printf(s, " | Ret user Timer Latency (%s)", 282 - params->output_divisor == 1 ? "ns" : "us"); 283 + params->common.output_divisor == 1 ? "ns" : "us"); 283 284 } 284 285 285 286 trace_seq_printf(s, "\n"); 286 - if (params->pretty_output) 287 + if (pretty) 287 288 trace_seq_printf(s, "\033[2;30;47m"); 288 289 289 290 trace_seq_printf(s, "CPU COUNT | cur min avg max | cur min avg max"); 290 291 if (params->user_data) 291 292 trace_seq_printf(s, " | cur min avg max"); 292 293 293 - if (params->pretty_output) 294 + if (pretty) 294 295 trace_seq_printf(s, "\033[0;0;0m"); 295 296 trace_seq_printf(s, "\n"); 296 297 } ··· 450 449 if (nr_cpus == -1) 451 450 nr_cpus = sysconf(_SC_NPROCESSORS_CONF); 452 451 453 - if (!params->quiet) 452 + if (!params->common.quiet) 454 453 clear_terminal(trace->seq); 455 454 456 455 timerlat_top_reset_sum(&summary); ··· 564 563 params->deepest_idle_state = -2; 565 564 566 565 /* display data in microseconds */ 567 - params->output_divisor = 1000; 566 + params->common.output_divisor = 1000; 568 567 569 568 /* default to BPF mode */ 570 569 params->mode = TRACING_MODE_BPF; ··· 697 696 params->kernel_workload = true; 698 697 break; 699 698 case 'n': 700 - params->output_divisor = 1; 699 + params->common.output_divisor = 1; 701 700 break; 702 701 case 'p': 703 702 params->timerlat_period_us = get_llong_from_str(optarg); ··· 711 710 params->common.set_sched = 1; 712 711 break; 713 712 case 'q': 714 - params->quiet = 1; 713 + params->common.quiet = 1; 715 714 break; 716 715 case 's': 717 716 params->print_stack = get_llong_from_str(optarg); ··· 843 842 if (retval) 844 843 goto out_err; 845 844 846 - if (isatty(STDOUT_FILENO) && !params->quiet) 847 - params->pretty_output = 1; 845 + if (isatty(STDOUT_FILENO) && !params->common.quiet) 846 + params->common.pretty_output = 1; 848 847 849 848 return 0; 850 849 ··· 943 942 return retval; 944 943 } 945 944 946 - if (!params->quiet) 945 + if (!params->common.quiet) 947 946 timerlat_print_stats(params, top); 948 947 949 948 if (osnoise_trace_is_off(top, record)) { ··· 993 992 994 993 /* Pull and display data in a loop */ 995 994 while (!stop_tracing) { 996 - wait_retval = timerlat_bpf_wait(params->quiet ? -1 : params->common.sleep_time); 995 + wait_retval = timerlat_bpf_wait(params->common.quiet ? -1 : 996 + params->common.sleep_time); 997 997 998 998 retval = timerlat_top_bpf_pull_data(top); 999 999 if (retval) { ··· 1002 1000 return retval; 1003 1001 } 1004 1002 1005 - if (!params->quiet) 1003 + if (!params->common.quiet) 1006 1004 timerlat_print_stats(params, top); 1007 1005 1008 1006 if (wait_retval == 1) {