Skip to content

Commit 61c57d5

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
rtla/osnoise: Add support to adjust the tracing_thresh
osnoise uses the tracing_thresh parameter to define the delta between two reads of the time to be considered a noise. Add support to get and set the tracing_thresh from osnoise tools. Link: https://lkml.kernel.org/r/715ad2a53fd40e41bab8c3f1214c1a94e12fb595.1646247211.git.bristot@kernel.org Cc: Daniel Bristot de Oliveira <bristot@kernel.org> Cc: Clark Williams <williams@redhat.com> Cc: Juri Lelli <juri.lelli@redhat.com> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 78cbc65 commit 61c57d5

2 files changed

Lines changed: 91 additions & 0 deletions

File tree

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)