Skip to content

Commit 20f463f

Browse files
committed
Merge tag 'trace-rtla-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull RTLA tracing tool updates from Steven Rostedt: "Real Time Analysis Tool updatesfor 5.18: - Support for adjusting tracing_threashold - Add -a (auto) option to make it easier for users to debug in the field - Add -e option to add more events to the trace - Add --trigger option to add triggers to events - Add --filter option to filter events - Add support to save histograms to the file - Add --dma-latency to set /dev/cpu_dma_latency - Other fixes and cleanups" * tag 'trace-rtla-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: rtla: Tools main loop cleanup rtla/timerlat: Add --dma-latency option rtla/osnoise: Fix osnoise hist stop tracing message rtla: Check for trace off also in the trace instance rtla/trace: Save event histogram output to a file rtla: Add --filter support rtla/trace: Add trace event filter helpers rtla: Add --trigger support rtla/trace: Add trace event trigger helpers rtla: Add -e/--event support rtla/trace: Add trace events helpers rtla/timerlat: Add the automatic trace option rtla/osnoise: Add the automatic trace option rtla/osnoise: Add an option to set the threshold rtla/osnoise: Add support to adjust the tracing_thresh
2 parents 3ef4ea3 + 75016ca commit 20f463f

13 files changed

Lines changed: 903 additions & 28 deletions

File tree

Documentation/tools/rtla/common_options.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@
1414

1515
Save the stopped trace to [*file|osnoise_trace.txt*].
1616

17+
**-e**, **--event** *sys:event*
18+
19+
Enable an event in the trace (**-t**) session. The argument can be a specific event, e.g., **-e** *sched:sched_switch*, or all events of a system group, e.g., **-e** *sched*. Multiple **-e** are allowed. It is only active when **-t** or **-a** are set.
20+
21+
**--filter** *<filter>*
22+
23+
Filter the previous **-e** *sys:event* event with *<filter>*. For further information about event filtering see https://www.kernel.org/doc/html/latest/trace/events.html#event-filtering.
24+
25+
**--trigger** *<trigger>*
26+
Enable a trace event trigger to the previous **-e** *sys:event*.
27+
If the *hist:* trigger is activated, the output histogram will be automatically saved to a file named *system_event_hist.txt*.
28+
For example, the command:
29+
30+
rtla <command> <mode> -t -e osnoise:irq_noise --trigger="hist:key=desc,duration/1000:sort=desc,duration/1000:vals=hitcount"
31+
32+
Will automatically save the content of the histogram associated to *osnoise:irq_noise* event in *osnoise_irq_noise_hist.txt*.
33+
34+
For further information about event trigger see https://www.kernel.org/doc/html/latest/trace/events.html#event-triggers.
35+
1736
**-P**, **--priority** *o:prio|r:prio|f:prio|d:runtime:period*
1837

1938
Set scheduling parameters to the osnoise tracer threads, the format to set the priority are:

Documentation/tools/rtla/common_osnoise_options.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
**-a**, **--auto** *us*
2+
3+
Set the automatic trace mode. This mode sets some commonly used options
4+
while debugging the system. It is equivalent to use **-s** *us* **-T 1 -t**.
5+
16
**-p**, **--period** *us*
27

38
Set the *osnoise* tracer period in microseconds.
@@ -15,3 +20,8 @@
1520

1621
Stop the trace if the total sample is higher than the argument in microseconds.
1722
If **-T** is set, it will also save the trace to the output.
23+
24+
**-T**, **--threshold** *us*
25+
26+
Specify the minimum delta between two time reads to be considered noise.
27+
The default threshold is *5 us*.

Documentation/tools/rtla/common_timerlat_options.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
**-a**, **--auto** *us*
2+
3+
Set the automatic trace mode. This mode sets some commonly used options
4+
while debugging the system. It is equivalent to use **-T** *us* **-s** *us*
5+
**-t**. By default, *timerlat* tracer uses FIFO:95 for *timerlat* threads,
6+
thus equilavent to **-P** *f:95*.
7+
18
**-p**, **--period** *us*
29

310
Set the *timerlat* tracer period in microseconds.
@@ -14,3 +21,8 @@
1421

1522
Save the stack trace at the *IRQ* if a *Thread* latency is higher than the
1623
argument in us.
24+
25+
**--dma-latency** *us*
26+
Set the /dev/cpu_dma_latency to *us*, aiming to bound exit from idle latencies.
27+
*cyclictest* sets this value to *0* by default, use **--dma-latency** *0* to have
28+
similar results.

tools/tracing/rtla/src/osnoise.c

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,85 @@ void osnoise_put_print_stack(struct osnoise_context *context)
655655
context->orig_print_stack = OSNOISE_OPTION_INIT_VAL;
656656
}
657657

658+
/*
659+
* osnoise_get_tracing_thresh - read and save the original "tracing_thresh"
660+
*/
661+
static long long
662+
osnoise_get_tracing_thresh(struct osnoise_context *context)
663+
{
664+
long long tracing_thresh;
665+
666+
if (context->tracing_thresh != OSNOISE_OPTION_INIT_VAL)
667+
return context->tracing_thresh;
668+
669+
if (context->orig_tracing_thresh != OSNOISE_OPTION_INIT_VAL)
670+
return context->orig_tracing_thresh;
671+
672+
tracing_thresh = osnoise_read_ll_config("tracing_thresh");
673+
if (tracing_thresh < 0)
674+
goto out_err;
675+
676+
context->orig_tracing_thresh = tracing_thresh;
677+
return tracing_thresh;
678+
679+
out_err:
680+
return OSNOISE_OPTION_INIT_VAL;
681+
}
682+
683+
/*
684+
* osnoise_set_tracing_thresh - set "tracing_thresh"
685+
*/
686+
int osnoise_set_tracing_thresh(struct osnoise_context *context, long long tracing_thresh)
687+
{
688+
long long curr_tracing_thresh = osnoise_get_tracing_thresh(context);
689+
int retval;
690+
691+
if (curr_tracing_thresh == OSNOISE_OPTION_INIT_VAL)
692+
return -1;
693+
694+
retval = osnoise_write_ll_config("tracing_thresh", tracing_thresh);
695+
if (retval < 0)
696+
return -1;
697+
698+
context->tracing_thresh = tracing_thresh;
699+
700+
return 0;
701+
}
702+
703+
/*
704+
* osnoise_restore_tracing_thresh - restore the original "tracing_thresh"
705+
*/
706+
void osnoise_restore_tracing_thresh(struct osnoise_context *context)
707+
{
708+
int retval;
709+
710+
if (context->orig_tracing_thresh == OSNOISE_OPTION_INIT_VAL)
711+
return;
712+
713+
if (context->orig_tracing_thresh == context->tracing_thresh)
714+
goto out_done;
715+
716+
retval = osnoise_write_ll_config("tracing_thresh", context->orig_tracing_thresh);
717+
if (retval < 0)
718+
err_msg("Could not restore original tracing_thresh\n");
719+
720+
out_done:
721+
context->tracing_thresh = OSNOISE_OPTION_INIT_VAL;
722+
}
723+
724+
/*
725+
* osnoise_put_tracing_thresh - restore original values and cleanup data
726+
*/
727+
void osnoise_put_tracing_thresh(struct osnoise_context *context)
728+
{
729+
osnoise_restore_tracing_thresh(context);
730+
731+
if (context->orig_tracing_thresh == OSNOISE_OPTION_INIT_VAL)
732+
return;
733+
734+
context->orig_tracing_thresh = OSNOISE_OPTION_INIT_VAL;
735+
}
736+
658737
/*
659738
* enable_osnoise - enable osnoise tracer in the trace_instance
660739
*/
@@ -716,6 +795,9 @@ struct osnoise_context *osnoise_context_alloc(void)
716795
context->orig_print_stack = OSNOISE_OPTION_INIT_VAL;
717796
context->print_stack = OSNOISE_OPTION_INIT_VAL;
718797

798+
context->orig_tracing_thresh = OSNOISE_OPTION_INIT_VAL;
799+
context->tracing_thresh = OSNOISE_OPTION_INIT_VAL;
800+
719801
osnoise_get_context(context);
720802

721803
return context;
@@ -741,6 +823,7 @@ void osnoise_put_context(struct osnoise_context *context)
741823
osnoise_put_stop_total_us(context);
742824
osnoise_put_timerlat_period_us(context);
743825
osnoise_put_print_stack(context);
826+
osnoise_put_tracing_thresh(context);
744827

745828
free(context);
746829
}

tools/tracing/rtla/src/osnoise.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ struct osnoise_context {
2323
long long orig_timerlat_period_us;
2424
long long timerlat_period_us;
2525

26+
/* 0 as init value */
27+
long long orig_tracing_thresh;
28+
long long tracing_thresh;
29+
2630
/* -1 as init value because 0 is disabled */
2731
long long orig_stop_us;
2832
long long stop_us;
@@ -67,6 +71,10 @@ int osnoise_set_timerlat_period_us(struct osnoise_context *context,
6771
long long timerlat_period_us);
6872
void osnoise_restore_timerlat_period_us(struct osnoise_context *context);
6973

74+
int osnoise_set_tracing_thresh(struct osnoise_context *context,
75+
long long tracing_thresh);
76+
void osnoise_restore_tracing_thresh(struct osnoise_context *context);
77+
7078
void osnoise_restore_print_stack(struct osnoise_context *context);
7179
int osnoise_set_print_stack(struct osnoise_context *context,
7280
long long print_stack);

0 commit comments

Comments
 (0)