Skip to content

Commit 302e9ed

Browse files
committed
tracing: Have traceon and traceoff trigger honor the instance
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>
1 parent ce33c84 commit 302e9ed

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
@@ -1295,6 +1295,16 @@ traceon_trigger(struct event_trigger_data *data,
12951295
struct trace_buffer *buffer, void *rec,
12961296
struct ring_buffer_event *event)
12971297
{
1298+
struct trace_event_file *file = data->private_data;
1299+
1300+
if (file) {
1301+
if (tracer_tracing_is_on(file->tr))
1302+
return;
1303+
1304+
tracer_tracing_on(file->tr);
1305+
return;
1306+
}
1307+
12981308
if (tracing_is_on())
12991309
return;
13001310

@@ -1306,23 +1316,43 @@ traceon_count_trigger(struct event_trigger_data *data,
13061316
struct trace_buffer *buffer, void *rec,
13071317
struct ring_buffer_event *event)
13081318
{
1309-
if (tracing_is_on())
1310-
return;
1319+
struct trace_event_file *file = data->private_data;
1320+
1321+
if (file) {
1322+
if (tracer_tracing_is_on(file->tr))
1323+
return;
1324+
} else {
1325+
if (tracing_is_on())
1326+
return;
1327+
}
13111328

13121329
if (!data->count)
13131330
return;
13141331

13151332
if (data->count != -1)
13161333
(data->count)--;
13171334

1318-
tracing_on();
1335+
if (file)
1336+
tracer_tracing_on(file->tr);
1337+
else
1338+
tracing_on();
13191339
}
13201340

13211341
static void
13221342
traceoff_trigger(struct event_trigger_data *data,
13231343
struct trace_buffer *buffer, void *rec,
13241344
struct ring_buffer_event *event)
13251345
{
1346+
struct trace_event_file *file = data->private_data;
1347+
1348+
if (file) {
1349+
if (!tracer_tracing_is_on(file->tr))
1350+
return;
1351+
1352+
tracer_tracing_off(file->tr);
1353+
return;
1354+
}
1355+
13261356
if (!tracing_is_on())
13271357
return;
13281358

@@ -1334,16 +1364,26 @@ traceoff_count_trigger(struct event_trigger_data *data,
13341364
struct trace_buffer *buffer, void *rec,
13351365
struct ring_buffer_event *event)
13361366
{
1337-
if (!tracing_is_on())
1338-
return;
1367+
struct trace_event_file *file = data->private_data;
1368+
1369+
if (file) {
1370+
if (!tracer_tracing_is_on(file->tr))
1371+
return;
1372+
} else {
1373+
if (!tracing_is_on())
1374+
return;
1375+
}
13391376

13401377
if (!data->count)
13411378
return;
13421379

13431380
if (data->count != -1)
13441381
(data->count)--;
13451382

1346-
tracing_off();
1383+
if (file)
1384+
tracer_tracing_off(file->tr);
1385+
else
1386+
tracing_off();
13471387
}
13481388

13491389
static int

0 commit comments

Comments
 (0)