tracing: Have traceon and traceoff trigger honor the instance
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Thu, 24 Feb 2022 03:38:37 +0000 (22:38 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Apr 2022 11:15:29 +0000 (13:15 +0200)
commit 302e9edd54985f584cfc180098f3554774126969 upstream.

If a trigger is set on an event to disable or enable tracing within an
instance, then tracing should be disabled or enabled in the instance and
not at the top level, which is confusing to users.

Link: https://lkml.kernel.org/r/20220223223837.14f94ec3@rorschach.local.home
Cc: stable@vger.kernel.org
Fixes: ae63b31e4d0e2 ("tracing: Separate out trace events from global variables")
Tested-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Reviewed-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/trace_events_trigger.c

index 13f5013373085dfb59eed397f3d313ab7ced92d9..33c66fac1a31d33c8e5d65e5d1e72c7905c14e00 100644 (file)
@@ -932,6 +932,16 @@ void set_named_trigger_data(struct event_trigger_data *data,
 static void
 traceon_trigger(struct event_trigger_data *data, void *rec)
 {
+       struct trace_event_file *file = data->private_data;
+
+       if (file) {
+               if (tracer_tracing_is_on(file->tr))
+                       return;
+
+               tracer_tracing_on(file->tr);
+               return;
+       }
+
        if (tracing_is_on())
                return;
 
@@ -941,8 +951,15 @@ traceon_trigger(struct event_trigger_data *data, void *rec)
 static void
 traceon_count_trigger(struct event_trigger_data *data, void *rec)
 {
-       if (tracing_is_on())
-               return;
+       struct trace_event_file *file = data->private_data;
+
+       if (file) {
+               if (tracer_tracing_is_on(file->tr))
+                       return;
+       } else {
+               if (tracing_is_on())
+                       return;
+       }
 
        if (!data->count)
                return;
@@ -950,12 +967,25 @@ traceon_count_trigger(struct event_trigger_data *data, void *rec)
        if (data->count != -1)
                (data->count)--;
 
-       tracing_on();
+       if (file)
+               tracer_tracing_on(file->tr);
+       else
+               tracing_on();
 }
 
 static void
 traceoff_trigger(struct event_trigger_data *data, void *rec)
 {
+       struct trace_event_file *file = data->private_data;
+
+       if (file) {
+               if (!tracer_tracing_is_on(file->tr))
+                       return;
+
+               tracer_tracing_off(file->tr);
+               return;
+       }
+
        if (!tracing_is_on())
                return;
 
@@ -965,8 +995,15 @@ traceoff_trigger(struct event_trigger_data *data, void *rec)
 static void
 traceoff_count_trigger(struct event_trigger_data *data, void *rec)
 {
-       if (!tracing_is_on())
-               return;
+       struct trace_event_file *file = data->private_data;
+
+       if (file) {
+               if (!tracer_tracing_is_on(file->tr))
+                       return;
+       } else {
+               if (!tracing_is_on())
+                       return;
+       }
 
        if (!data->count)
                return;
@@ -974,7 +1011,10 @@ traceoff_count_trigger(struct event_trigger_data *data, void *rec)
        if (data->count != -1)
                (data->count)--;
 
-       tracing_off();
+       if (file)
+               tracer_tracing_off(file->tr);
+       else
+               tracing_off();
 }
 
 static int