Skip to content

Commit 13600dd

Browse files
rostedtgregkh
authored andcommitted
tracing: Have traceon and traceoff trigger honor the instance
commit 302e9ed 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: ae63b31 ("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>
1 parent 950f98c commit 13600dd

1 file changed

Lines changed: 46 additions & 6 deletions

File tree

‎kernel/trace/trace_events_trigger.c‎

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,16 @@ traceon_trigger(struct event_trigger_data *data,
955955
struct trace_buffer *buffer, void *rec,
956956
struct ring_buffer_event *event)
957957
{
958+
struct trace_event_file *file = data->private_data;
959+
960+
if (file) {
961+
if (tracer_tracing_is_on(file->tr))
962+
return;
963+
964+
tracer_tracing_on(file->tr);
965+
return;
966+
}
967+
958968
if (tracing_is_on())
959969
return;
960970

@@ -966,23 +976,43 @@ traceon_count_trigger(struct event_trigger_data *data,
966976
struct trace_buffer *buffer, void *rec,
967977
struct ring_buffer_event *event)
968978
{
969-
if (tracing_is_on())
970-
return;
979+
struct trace_event_file *file = data->private_data;
980+
981+
if (file) {
982+
if (tracer_tracing_is_on(file->tr))
983+
return;
984+
} else {
985+
if (tracing_is_on())
986+
return;
987+
}
971988

972989
if (!data->count)
973990
return;
974991

975992
if (data->count != -1)
976993
(data->count)--;
977994

978-
tracing_on();
995+
if (file)
996+
tracer_tracing_on(file->tr);
997+
else
998+
tracing_on();
979999
}
9801000

9811001
static void
9821002
traceoff_trigger(struct event_trigger_data *data,
9831003
struct trace_buffer *buffer, void *rec,
9841004
struct ring_buffer_event *event)
9851005
{
1006+
struct trace_event_file *file = data->private_data;
1007+
1008+
if (file) {
1009+
if (!tracer_tracing_is_on(file->tr))
1010+
return;
1011+
1012+
tracer_tracing_off(file->tr);
1013+
return;
1014+
}
1015+
9861016
if (!tracing_is_on())
9871017
return;
9881018

@@ -994,16 +1024,26 @@ traceoff_count_trigger(struct event_trigger_data *data,
9941024
struct trace_buffer *buffer, void *rec,
9951025
struct ring_buffer_event *event)
9961026
{
997-
if (!tracing_is_on())
998-
return;
1027+
struct trace_event_file *file = data->private_data;
1028+
1029+
if (file) {
1030+
if (!tracer_tracing_is_on(file->tr))
1031+
return;
1032+
} else {
1033+
if (!tracing_is_on())
1034+
return;
1035+
}
9991036

10001037
if (!data->count)
10011038
return;
10021039

10031040
if (data->count != -1)
10041041
(data->count)--;
10051042

1006-
tracing_off();
1043+
if (file)
1044+
tracer_tracing_off(file->tr);
1045+
else
1046+
tracing_off();
10071047
}
10081048

10091049
static int

0 commit comments

Comments
 (0)