]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
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)
committerPaolo Pisati <paolo.pisati@canonical.com>
Mon, 7 Mar 2022 10:46:01 +0000 (11:46 +0100)
BugLink: https://bugs.launchpad.net/bugs/1963891
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>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
kernel/trace/trace_events_trigger.c

index 1a41b682274a5a4a08157c37741312126b5de531..67c7979c40c0b63fe39a0476cc6af6aaa606ecce 100644 (file)
@@ -955,6 +955,16 @@ traceon_trigger(struct event_trigger_data *data,
                struct trace_buffer *buffer, void *rec,
                struct ring_buffer_event *event)
 {
+       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;
 
@@ -966,8 +976,15 @@ traceon_count_trigger(struct event_trigger_data *data,
                      struct trace_buffer *buffer, void *rec,
                      struct ring_buffer_event *event)
 {
-       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;
@@ -975,7 +992,10 @@ traceon_count_trigger(struct event_trigger_data *data,
        if (data->count != -1)
                (data->count)--;
 
-       tracing_on();
+       if (file)
+               tracer_tracing_on(file->tr);
+       else
+               tracing_on();
 }
 
 static void
@@ -983,6 +1003,16 @@ traceoff_trigger(struct event_trigger_data *data,
                 struct trace_buffer *buffer, void *rec,
                 struct ring_buffer_event *event)
 {
+       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;
 
@@ -994,8 +1024,15 @@ traceoff_count_trigger(struct event_trigger_data *data,
                       struct trace_buffer *buffer, void *rec,
                       struct ring_buffer_event *event)
 {
-       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;
@@ -1003,7 +1040,10 @@ traceoff_count_trigger(struct event_trigger_data *data,
        if (data->count != -1)
                (data->count)--;
 
-       tracing_off();
+       if (file)
+               tracer_tracing_off(file->tr);
+       else
+               tracing_off();
 }
 
 static int