@@ -16,6 +16,9 @@ enum timelat_state {
16
16
TIMERLAT_WAITING_THREAD ,
17
17
};
18
18
19
+ /* Used to fill spaces in the output */
20
+ static const char * spaces = " " ;
21
+
19
22
#define MAX_COMM 24
20
23
21
24
/*
@@ -274,14 +277,17 @@ static int timerlat_aa_nmi_handler(struct trace_seq *s, struct tep_record *recor
274
277
taa_data -> prev_irq_timstamp = start ;
275
278
276
279
trace_seq_reset (taa_data -> prev_irqs_seq );
277
- trace_seq_printf (taa_data -> prev_irqs_seq , "\t%24s \t\t\t%9.2f us\n" ,
278
- "nmi" , ns_to_usf (duration ));
280
+ trace_seq_printf (taa_data -> prev_irqs_seq , " %24s %.*s %9.2f us\n" ,
281
+ "nmi" ,
282
+ 24 , spaces ,
283
+ ns_to_usf (duration ));
279
284
return 0 ;
280
285
}
281
286
282
287
taa_data -> thread_nmi_sum += duration ;
283
- trace_seq_printf (taa_data -> nmi_seq , " %24s \t\t\t%9.2f us\n" ,
284
- "nmi" , ns_to_usf (duration ));
288
+ trace_seq_printf (taa_data -> nmi_seq , " %24s %.*s %9.2f us\n" ,
289
+ "nmi" ,
290
+ 24 , spaces , ns_to_usf (duration ));
285
291
286
292
return 0 ;
287
293
}
@@ -323,8 +329,10 @@ static int timerlat_aa_irq_handler(struct trace_seq *s, struct tep_record *recor
323
329
taa_data -> prev_irq_timstamp = start ;
324
330
325
331
trace_seq_reset (taa_data -> prev_irqs_seq );
326
- trace_seq_printf (taa_data -> prev_irqs_seq , "\t%24s:%-3llu \t\t%9.2f us\n" ,
327
- desc , vector , ns_to_usf (duration ));
332
+ trace_seq_printf (taa_data -> prev_irqs_seq , " %24s:%-3llu %.*s %9.2f us\n" ,
333
+ desc , vector ,
334
+ 15 , spaces ,
335
+ ns_to_usf (duration ));
328
336
return 0 ;
329
337
}
330
338
@@ -372,8 +380,10 @@ static int timerlat_aa_irq_handler(struct trace_seq *s, struct tep_record *recor
372
380
* IRQ interference.
373
381
*/
374
382
taa_data -> thread_irq_sum += duration ;
375
- trace_seq_printf (taa_data -> irqs_seq , " %24s:%-3llu \t %9.2f us\n" ,
376
- desc , vector , ns_to_usf (duration ));
383
+ trace_seq_printf (taa_data -> irqs_seq , " %24s:%-3llu %.*s %9.2f us\n" ,
384
+ desc , vector ,
385
+ 24 , spaces ,
386
+ ns_to_usf (duration ));
377
387
378
388
return 0 ;
379
389
}
@@ -408,8 +418,10 @@ static int timerlat_aa_softirq_handler(struct trace_seq *s, struct tep_record *r
408
418
409
419
taa_data -> thread_softirq_sum += duration ;
410
420
411
- trace_seq_printf (taa_data -> softirqs_seq , "\t%24s:%-3llu \t %9.2f us\n" ,
412
- softirq_name [vector ], vector , ns_to_usf (duration ));
421
+ trace_seq_printf (taa_data -> softirqs_seq , " %24s:%-3llu %.*s %9.2f us\n" ,
422
+ softirq_name [vector ], vector ,
423
+ 24 , spaces ,
424
+ ns_to_usf (duration ));
413
425
return 0 ;
414
426
}
415
427
@@ -452,8 +464,10 @@ static int timerlat_aa_thread_handler(struct trace_seq *s, struct tep_record *re
452
464
} else {
453
465
taa_data -> thread_thread_sum += duration ;
454
466
455
- trace_seq_printf (taa_data -> threads_seq , "\t%24s:%-3llu \t\t%9.2f us\n" ,
456
- comm , pid , ns_to_usf (duration ));
467
+ trace_seq_printf (taa_data -> threads_seq , " %24s:%-12llu %.*s %9.2f us\n" ,
468
+ comm , pid ,
469
+ 15 , spaces ,
470
+ ns_to_usf (duration ));
457
471
}
458
472
459
473
return 0 ;
@@ -482,7 +496,8 @@ static int timerlat_aa_stack_handler(struct trace_seq *s, struct tep_record *rec
482
496
function = tep_find_function (taa_ctx -> tool -> trace .tep , caller [i ]);
483
497
if (!function )
484
498
break ;
485
- trace_seq_printf (taa_data -> stack_seq , "\t\t-> %s\n" , function );
499
+ trace_seq_printf (taa_data -> stack_seq , " %.*s -> %s\n" ,
500
+ 14 , spaces , function );
486
501
}
487
502
}
488
503
return 0 ;
@@ -568,23 +583,24 @@ static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
568
583
exp_irq_ts = taa_data -> timer_irq_start_time - taa_data -> timer_irq_start_delay ;
569
584
if (exp_irq_ts < taa_data -> prev_irq_timstamp + taa_data -> prev_irq_duration ) {
570
585
if (taa_data -> prev_irq_timstamp < taa_data -> timer_irq_start_time )
571
- printf (" Previous IRQ interference: \t\t up to %9.2f us\n" ,
572
- ns_to_usf (taa_data -> prev_irq_duration ));
586
+ printf (" Previous IRQ interference: %.*s up to %9.2f us\n" ,
587
+ 16 , spaces ,
588
+ ns_to_usf (taa_data -> prev_irq_duration ));
573
589
}
574
590
575
591
/*
576
592
* The delay that the IRQ suffered before starting.
577
593
*/
578
- printf (" IRQ handler delay: % 16s %9.2f us (%.2f %%)\n" ,
579
- (ns_to_usf (taa_data -> timer_exit_from_idle ) > 10 ) ? "(exit from idle)" : "" ,
580
- ns_to_usf (taa_data -> timer_irq_start_delay ),
581
- ns_to_per (total , taa_data -> timer_irq_start_delay ));
594
+ printf (" IRQ handler delay: %.*s % 16s %9.2f us (%.2f %%)\n" , 16 , spaces ,
595
+ (ns_to_usf (taa_data -> timer_exit_from_idle ) > 10 ) ? "(exit from idle)" : "" ,
596
+ ns_to_usf (taa_data -> timer_irq_start_delay ),
597
+ ns_to_per (total , taa_data -> timer_irq_start_delay ));
582
598
583
599
/*
584
600
* Timerlat IRQ.
585
601
*/
586
- printf (" IRQ latency: \t\t\t\t % 9.2f us\n" ,
587
- ns_to_usf (taa_data -> tlat_irq_latency ));
602
+ printf (" IRQ latency: %.*s % 9.2f us\n" , 40 , spaces ,
603
+ ns_to_usf (taa_data -> tlat_irq_latency ));
588
604
589
605
if (irq ) {
590
606
/*
@@ -595,29 +611,30 @@ static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
595
611
* so it will be displayed, it is the key.
596
612
*/
597
613
printf (" Blocking thread:\n" );
598
- printf (" % 24s:%-9llu\n" ,
599
- taa_data -> run_thread_comm , taa_data -> run_thread_pid );
614
+ printf (" %.*s % 24s:%-9llu\n" , 6 , spaces , taa_data -> run_thread_comm ,
615
+ taa_data -> run_thread_pid );
600
616
} else {
601
617
/*
602
618
* The duration of the IRQ handler that handled the timerlat IRQ.
603
619
*/
604
- printf (" Timerlat IRQ duration: \t\t %9.2f us (%.2f %%)\n" ,
605
- ns_to_usf (taa_data -> timer_irq_duration ),
606
- ns_to_per (total , taa_data -> timer_irq_duration ));
620
+ printf (" Timerlat IRQ duration: %.*s %9.2f us (%.2f %%)\n" ,
621
+ 30 , spaces ,
622
+ ns_to_usf (taa_data -> timer_irq_duration ),
623
+ ns_to_per (total , taa_data -> timer_irq_duration ));
607
624
608
625
/*
609
626
* The amount of time that the current thread postponed the scheduler.
610
627
*
611
628
* Recalling that it is net from NMI/IRQ/Softirq interference, so there
612
629
* is no need to compute values here.
613
630
*/
614
- printf (" Blocking thread: \t\t\t % 9.2f us (%.2f %%)\n" ,
615
- ns_to_usf (taa_data -> thread_blocking_duration ),
616
- ns_to_per (total , taa_data -> thread_blocking_duration ));
631
+ printf (" Blocking thread: %.*s % 9.2f us (%.2f %%)\n" , 36 , spaces ,
632
+ ns_to_usf (taa_data -> thread_blocking_duration ),
633
+ ns_to_per (total , taa_data -> thread_blocking_duration ));
617
634
618
- printf (" % 24s:%-9llu % 9.2f us\n" ,
619
- taa_data -> run_thread_comm , taa_data -> run_thread_pid ,
620
- ns_to_usf (taa_data -> thread_blocking_duration ));
635
+ printf (" %.*s % 24s:%-9llu %.*s % 9.2f us\n" , 6 , spaces ,
636
+ taa_data -> run_thread_comm , taa_data -> run_thread_pid ,
637
+ 12 , spaces , ns_to_usf (taa_data -> thread_blocking_duration ));
621
638
}
622
639
623
640
/*
@@ -629,9 +646,9 @@ static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
629
646
* NMIs can happen during the IRQ, so they are always possible.
630
647
*/
631
648
if (taa_data -> thread_nmi_sum )
632
- printf (" NMI interference \t\t\t % 9.2f us (%.2f %%)\n" ,
633
- ns_to_usf (taa_data -> thread_nmi_sum ),
634
- ns_to_per (total , taa_data -> thread_nmi_sum ));
649
+ printf (" NMI interference %.*s % 9.2f us (%.2f %%)\n" , 36 , spaces ,
650
+ ns_to_usf (taa_data -> thread_nmi_sum ),
651
+ ns_to_per (total , taa_data -> thread_nmi_sum ));
635
652
636
653
/*
637
654
* If it is an IRQ latency, the other factors can be skipped.
@@ -643,9 +660,9 @@ static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
643
660
* Prints the interference caused by IRQs to the thread latency.
644
661
*/
645
662
if (taa_data -> thread_irq_sum ) {
646
- printf (" IRQ interference \t\t\t % 9.2f us (%.2f %%)\n" ,
647
- ns_to_usf (taa_data -> thread_irq_sum ),
648
- ns_to_per (total , taa_data -> thread_irq_sum ));
663
+ printf (" IRQ interference %.*s % 9.2f us (%.2f %%)\n" , 36 , spaces ,
664
+ ns_to_usf (taa_data -> thread_irq_sum ),
665
+ ns_to_per (total , taa_data -> thread_irq_sum ));
649
666
650
667
trace_seq_do_printf (taa_data -> irqs_seq );
651
668
}
@@ -654,9 +671,9 @@ static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
654
671
* Prints the interference caused by Softirqs to the thread latency.
655
672
*/
656
673
if (taa_data -> thread_softirq_sum ) {
657
- printf (" Softirq interference \t\t\t % 9.2f us (%.2f %%)\n" ,
658
- ns_to_usf (taa_data -> thread_softirq_sum ),
659
- ns_to_per (total , taa_data -> thread_softirq_sum ));
674
+ printf (" Softirq interference %.*s % 9.2f us (%.2f %%)\n" , 32 , spaces ,
675
+ ns_to_usf (taa_data -> thread_softirq_sum ),
676
+ ns_to_per (total , taa_data -> thread_softirq_sum ));
660
677
661
678
trace_seq_do_printf (taa_data -> softirqs_seq );
662
679
}
@@ -670,9 +687,9 @@ static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
670
687
* timer handling latency.
671
688
*/
672
689
if (taa_data -> thread_thread_sum ) {
673
- printf (" Thread interference \t\t\t % 9.2f us (%.2f %%)\n" ,
674
- ns_to_usf (taa_data -> thread_thread_sum ),
675
- ns_to_per (total , taa_data -> thread_thread_sum ));
690
+ printf (" Thread interference %.*s % 9.2f us (%.2f %%)\n" , 33 , spaces ,
691
+ ns_to_usf (taa_data -> thread_thread_sum ),
692
+ ns_to_per (total , taa_data -> thread_thread_sum ));
676
693
677
694
trace_seq_do_printf (taa_data -> threads_seq );
678
695
}
@@ -682,8 +699,8 @@ static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
682
699
*/
683
700
print_total :
684
701
printf ("------------------------------------------------------------------------\n" );
685
- printf (" %s latency: \t\t\t % 9.2f us (100%%)\n" , irq ? "IRQ" : "Thread" ,
686
- ns_to_usf (total ));
702
+ printf (" %s latency: %.*s % 9.2f us (100%%)\n" , irq ? " IRQ" : "Thread" ,
703
+ 37 , spaces , ns_to_usf (total ));
687
704
}
688
705
689
706
static int timerlat_auto_analysis_collect_trace (struct timerlat_aa_context * taa_ctx )
0 commit comments