Skip to content

Commit afbeee1

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 99eb8d6 commit afbeee1

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
@@ -940,6 +940,16 @@ static void
940940
traceon_trigger(struct event_trigger_data *data, void *rec,
941941
struct ring_buffer_event *event)
942942
{
943+
struct trace_event_file *file = data->private_data;
944+
945+
if (file) {
946+
if (tracer_tracing_is_on(file->tr))
947+
return;
948+
949+
tracer_tracing_on(file->tr);
950+
return;
951+
}
952+
943953
if (tracing_is_on())
944954
return;
945955

@@ -950,22 +960,42 @@ static void
950960
traceon_count_trigger(struct event_trigger_data *data, void *rec,
951961
struct ring_buffer_event *event)
952962
{
953-
if (tracing_is_on())
954-
return;
963+
struct trace_event_file *file = data->private_data;
964+
965+
if (file) {
966+
if (tracer_tracing_is_on(file->tr))
967+
return;
968+
} else {
969+
if (tracing_is_on())
970+
return;
971+
}
955972

956973
if (!data->count)
957974
return;
958975

959976
if (data->count != -1)
960977
(data->count)--;
961978

962-
tracing_on();
979+
if (file)
980+
tracer_tracing_on(file->tr);
981+
else
982+
tracing_on();
963983
}
964984

965985
static void
966986
traceoff_trigger(struct event_trigger_data *data, void *rec,
967987
struct ring_buffer_event *event)
968988
{
989+
struct trace_event_file *file = data->private_data;
990+
991+
if (file) {
992+
if (!tracer_tracing_is_on(file->tr))
993+
return;
994+
995+
tracer_tracing_off(file->tr);
996+
return;
997+
}
998+
969999
if (!tracing_is_on())
9701000
return;
9711001

@@ -976,16 +1006,26 @@ static void
9761006
traceoff_count_trigger(struct event_trigger_data *data, void *rec,
9771007
struct ring_buffer_event *event)
9781008
{
979-
if (!tracing_is_on())
980-
return;
1009+
struct trace_event_file *file = data->private_data;
1010+
1011+
if (file) {
1012+
if (!tracer_tracing_is_on(file->tr))
1013+
return;
1014+
} else {
1015+
if (!tracing_is_on())
1016+
return;
1017+
}
9811018

9821019
if (!data->count)
9831020
return;
9841021

9851022
if (data->count != -1)
9861023
(data->count)--;
9871024

988-
tracing_off();
1025+
if (file)
1026+
tracer_tracing_off(file->tr);
1027+
else
1028+
tracing_off();
9891029
}
9901030

9911031
static int

0 commit comments

Comments
 (0)