Skip to content

Commit 28d2160

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
rtla: Check for trace off also in the trace instance
With the addition of --trigger option, it is also possible to stop the trace from the -t tracing instance using the traceoff trigger. Make rtla tools to check if the trace is stopped also in the trace instance, stopping the execution of the tool. Link: https://lkml.kernel.org/r/59fc7c6f23dddd5c8b7ef1782cf3da51ea2ce0f5.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 761916f commit 28d2160

6 files changed

Lines changed: 28 additions & 8 deletions

File tree

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ int osnoise_hist_main(int argc, char *argv[])
848848
goto out_hist;
849849
}
850850

851-
if (!tracefs_trace_is_on(trace->inst))
851+
if (trace_is_off(&tool->trace, &record->trace))
852852
break;
853853
};
854854

@@ -858,7 +858,7 @@ int osnoise_hist_main(int argc, char *argv[])
858858

859859
return_value = 0;
860860

861-
if (!tracefs_trace_is_on(trace->inst)) {
861+
if (trace_is_off(&tool->trace, &record->trace)) {
862862
printf("rtla timelat hit stop tracing\n");
863863
if (params->trace_output) {
864864
printf(" Saving trace to %s\n", params->trace_output);

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ int osnoise_top_main(int argc, char **argv)
629629
if (!params->quiet)
630630
osnoise_print_stats(params, tool);
631631

632-
if (!tracefs_trace_is_on(trace->inst))
632+
if (trace_is_off(&tool->trace, &record->trace))
633633
break;
634634

635635
} while (!stop_tracing);
@@ -638,7 +638,7 @@ int osnoise_top_main(int argc, char **argv)
638638

639639
return_value = 0;
640640

641-
if (!tracefs_trace_is_on(trace->inst)) {
641+
if (trace_is_off(&tool->trace, &record->trace)) {
642642
printf("osnoise hit stop tracing\n");
643643
if (params->trace_output) {
644644
printf(" Saving trace to %s\n", params->trace_output);

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,15 +861,15 @@ int timerlat_hist_main(int argc, char *argv[])
861861
goto out_hist;
862862
}
863863

864-
if (!tracefs_trace_is_on(trace->inst))
864+
if (trace_is_off(&tool->trace, &record->trace))
865865
break;
866866
};
867867

868868
timerlat_print_stats(params, tool);
869869

870870
return_value = 0;
871871

872-
if (!tracefs_trace_is_on(trace->inst)) {
872+
if (trace_is_off(&tool->trace, &record->trace)) {
873873
printf("rtla timelat hit stop tracing\n");
874874
if (params->trace_output) {
875875
printf(" Saving trace to %s\n", params->trace_output);

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ int timerlat_top_main(int argc, char *argv[])
655655
if (!params->quiet)
656656
timerlat_print_stats(params, top);
657657

658-
if (!tracefs_trace_is_on(trace->inst))
658+
if (trace_is_off(&top->trace, &record->trace))
659659
break;
660660

661661
};
@@ -664,7 +664,7 @@ int timerlat_top_main(int argc, char *argv[])
664664

665665
return_value = 0;
666666

667-
if (!tracefs_trace_is_on(trace->inst)) {
667+
if (trace_is_off(&top->trace, &record->trace)) {
668668
printf("rtla timelat hit stop tracing\n");
669669
if (params->trace_output) {
670670
printf(" Saving trace to %s\n", params->trace_output);

tools/tracing/rtla/src/trace.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,3 +516,22 @@ void trace_events_destroy(struct trace_instance *instance,
516516
trace_events_disable(instance, events);
517517
trace_events_free(events);
518518
}
519+
520+
int trace_is_off(struct trace_instance *tool, struct trace_instance *trace)
521+
{
522+
/*
523+
* The tool instance is always present, it is the one used to collect
524+
* data.
525+
*/
526+
if (!tracefs_trace_is_on(tool->inst))
527+
return 1;
528+
529+
/*
530+
* The trace instance is only enabled when -t is set. IOW, when the system
531+
* is tracing.
532+
*/
533+
if (trace && !tracefs_trace_is_on(trace->inst))
534+
return 1;
535+
536+
return 0;
537+
}

tools/tracing/rtla/src/trace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ int trace_events_enable(struct trace_instance *instance,
4747

4848
int trace_event_add_filter(struct trace_events *event, char *filter);
4949
int trace_event_add_trigger(struct trace_events *event, char *trigger);
50+
int trace_is_off(struct trace_instance *tool, struct trace_instance *trace);

0 commit comments

Comments
 (0)