Skip to content

Commit ac9d2cb

Browse files
committed
tracing: Only make selftest conditionals affect the global_trace
The tracing_selftest_running and tracing_selftest_disabled variables were to keep trace_printk() and other writes from affecting the tracing selftests, as the tracing selftests would examine the ring buffer to see if it contained what it expected or not. trace_printk() and friends could add to the ring buffer and cause the selftests to fail (and then disable the tracer that was being tested). To keep that from happening, these variables were added and would keep trace_printk() and friends from writing to the ring buffer while the tests were going on. But this was only the top level ring buffer (owned by the global_trace instance). There is no reason to prevent writing into ring buffers of other instances via the trace_array_printk() and friends. For the functions that could be used by other instances, check if the global_trace is the tracer instance that is being written to before deciding to not allow the write. Link: https://lkml.kernel.org/r/20230528051742.1325503-5-rostedt@goodmis.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent a3ae76d commit ac9d2cb

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

kernel/trace/trace.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,10 @@ int __trace_array_puts(struct trace_array *tr, unsigned long ip,
10541054
if (!(tr->trace_flags & TRACE_ITER_PRINTK))
10551055
return 0;
10561056

1057-
if (unlikely(tracing_selftest_running || tracing_disabled))
1057+
if (unlikely(tracing_selftest_running && tr == &global_trace))
1058+
return 0;
1059+
1060+
if (unlikely(tracing_disabled))
10581061
return 0;
10591062

10601063
alloc = sizeof(*entry) + size + 2; /* possible \n added */
@@ -3512,7 +3515,7 @@ __trace_array_vprintk(struct trace_buffer *buffer,
35123515
unsigned int trace_ctx;
35133516
char *tbuffer;
35143517

3515-
if (tracing_disabled || tracing_selftest_running)
3518+
if (tracing_disabled)
35163519
return 0;
35173520

35183521
/* Don't pollute graph traces with trace_vprintk internals */
@@ -3560,6 +3563,9 @@ __printf(3, 0)
35603563
int trace_array_vprintk(struct trace_array *tr,
35613564
unsigned long ip, const char *fmt, va_list args)
35623565
{
3566+
if (tracing_selftest_running && tr == &global_trace)
3567+
return 0;
3568+
35633569
return __trace_array_vprintk(tr->array_buffer.buffer, ip, fmt, args);
35643570
}
35653571

0 commit comments

Comments
 (0)