Commit 20f463fb authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 3ef4ea3d 75016ca3
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -14,6 +14,25 @@

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

**-e**, **--event** *sys:event*

        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.

**--filter** *<filter>*

        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.

**--trigger** *<trigger>*
        Enable a trace event trigger to the previous **-e** *sys:event*.
        If the *hist:* trigger is activated, the output histogram will be automatically saved to a file named *system_event_hist.txt*.
        For example, the command:

        rtla <command> <mode> -t -e osnoise:irq_noise --trigger="hist:key=desc,duration/1000:sort=desc,duration/1000:vals=hitcount"

        Will automatically save the content of the histogram associated to *osnoise:irq_noise* event in *osnoise_irq_noise_hist.txt*.

        For further information about event trigger see https://www.kernel.org/doc/html/latest/trace/events.html#event-triggers.

**-P**, **--priority** *o:prio|r:prio|f:prio|d:runtime:period*

        Set scheduling parameters to the osnoise tracer threads, the format to set the priority are:
+10 −0
Original line number Diff line number Diff line
**-a**, **--auto** *us*

        Set the automatic trace mode. This mode sets some commonly used options
        while debugging the system. It is equivalent to use **-s** *us* **-T 1 -t**.

**-p**, **--period** *us*

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

        Stop the trace if the total sample is higher than the argument in microseconds.
        If **-T** is set, it will also save the trace to the output.

**-T**, **--threshold** *us*

        Specify the minimum delta between two time reads to be considered noise.
        The default threshold is *5 us*.
+12 −0
Original line number Diff line number Diff line
**-a**, **--auto** *us*

        Set the automatic trace mode. This mode sets some commonly used options
        while debugging the system. It is equivalent to use **-T** *us* **-s** *us*
        **-t**. By default, *timerlat* tracer uses FIFO:95 for *timerlat* threads,
        thus equilavent to **-P** *f:95*.

**-p**, **--period** *us*

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

        Save the stack trace at the *IRQ* if a *Thread* latency is higher than the
        argument in us.

**--dma-latency** *us*
        Set the /dev/cpu_dma_latency to *us*, aiming to bound exit from idle latencies.
        *cyclictest* sets this value to *0* by default, use **--dma-latency** *0* to have
        similar results.
+83 −0
Original line number Diff line number Diff line
@@ -655,6 +655,85 @@ void osnoise_put_print_stack(struct osnoise_context *context)
	context->orig_print_stack = OSNOISE_OPTION_INIT_VAL;
}

/*
 * osnoise_get_tracing_thresh - read and save the original "tracing_thresh"
 */
static long long
osnoise_get_tracing_thresh(struct osnoise_context *context)
{
	long long tracing_thresh;

	if (context->tracing_thresh != OSNOISE_OPTION_INIT_VAL)
		return context->tracing_thresh;

	if (context->orig_tracing_thresh != OSNOISE_OPTION_INIT_VAL)
		return context->orig_tracing_thresh;

	tracing_thresh = osnoise_read_ll_config("tracing_thresh");
	if (tracing_thresh < 0)
		goto out_err;

	context->orig_tracing_thresh = tracing_thresh;
	return tracing_thresh;

out_err:
	return OSNOISE_OPTION_INIT_VAL;
}

/*
 * osnoise_set_tracing_thresh - set "tracing_thresh"
 */
int osnoise_set_tracing_thresh(struct osnoise_context *context, long long tracing_thresh)
{
	long long curr_tracing_thresh = osnoise_get_tracing_thresh(context);
	int retval;

	if (curr_tracing_thresh == OSNOISE_OPTION_INIT_VAL)
		return -1;

	retval = osnoise_write_ll_config("tracing_thresh", tracing_thresh);
	if (retval < 0)
		return -1;

	context->tracing_thresh = tracing_thresh;

	return 0;
}

/*
 * osnoise_restore_tracing_thresh - restore the original "tracing_thresh"
 */
void osnoise_restore_tracing_thresh(struct osnoise_context *context)
{
	int retval;

	if (context->orig_tracing_thresh == OSNOISE_OPTION_INIT_VAL)
		return;

	if (context->orig_tracing_thresh == context->tracing_thresh)
		goto out_done;

	retval = osnoise_write_ll_config("tracing_thresh", context->orig_tracing_thresh);
	if (retval < 0)
		err_msg("Could not restore original tracing_thresh\n");

out_done:
	context->tracing_thresh = OSNOISE_OPTION_INIT_VAL;
}

/*
 * osnoise_put_tracing_thresh - restore original values and cleanup data
 */
void osnoise_put_tracing_thresh(struct osnoise_context *context)
{
	osnoise_restore_tracing_thresh(context);

	if (context->orig_tracing_thresh == OSNOISE_OPTION_INIT_VAL)
		return;

	context->orig_tracing_thresh = OSNOISE_OPTION_INIT_VAL;
}

/*
 * enable_osnoise - enable osnoise tracer in the trace_instance
 */
@@ -716,6 +795,9 @@ struct osnoise_context *osnoise_context_alloc(void)
	context->orig_print_stack	= OSNOISE_OPTION_INIT_VAL;
	context->print_stack		= OSNOISE_OPTION_INIT_VAL;

	context->orig_tracing_thresh	= OSNOISE_OPTION_INIT_VAL;
	context->tracing_thresh		= OSNOISE_OPTION_INIT_VAL;

	osnoise_get_context(context);

	return context;
@@ -741,6 +823,7 @@ void osnoise_put_context(struct osnoise_context *context)
	osnoise_put_stop_total_us(context);
	osnoise_put_timerlat_period_us(context);
	osnoise_put_print_stack(context);
	osnoise_put_tracing_thresh(context);

	free(context);
}
+8 −0
Original line number Diff line number Diff line
@@ -23,6 +23,10 @@ struct osnoise_context {
	long long		orig_timerlat_period_us;
	long long		timerlat_period_us;

	/* 0 as init value */
	long long		orig_tracing_thresh;
	long long		tracing_thresh;

	/* -1 as init value because 0 is disabled */
	long long		orig_stop_us;
	long long		stop_us;
@@ -67,6 +71,10 @@ int osnoise_set_timerlat_period_us(struct osnoise_context *context,
				   long long timerlat_period_us);
void osnoise_restore_timerlat_period_us(struct osnoise_context *context);

int osnoise_set_tracing_thresh(struct osnoise_context *context,
			       long long tracing_thresh);
void osnoise_restore_tracing_thresh(struct osnoise_context *context);

void osnoise_restore_print_stack(struct osnoise_context *context);
int osnoise_set_print_stack(struct osnoise_context *context,
			    long long print_stack);
Loading