Skip to content

Commit 3d07fa1

Browse files
Brian Fosterrostedt
authored andcommitted
tracing: Zero the pipe cpumask on alloc to avoid spurious -EBUSY
The pipe cpumask used to serialize opens between the main and percpu trace pipes is not zeroed or initialized. This can result in spurious -EBUSY returns if underlying memory is not fully zeroed. This has been observed by immediate failure to read the main trace_pipe file on an otherwise newly booted and idle system: # cat /sys/kernel/debug/tracing/trace_pipe cat: /sys/kernel/debug/tracing/trace_pipe: Device or resource busy Zero the allocation of pipe_cpumask to avoid the problem. Link: https://lore.kernel.org/linux-trace-kernel/20230831125500.986862-1-bfoster@redhat.com Cc: stable@vger.kernel.org Fixes: c2489bb ("tracing: Introduce pipe_cpumask to avoid race on trace_pipes") Reviewed-by: Zheng Yejian <zhengyejian1@huawei.com> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 2a30dbc commit 3d07fa1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/trace/trace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9474,7 +9474,7 @@ static struct trace_array *trace_array_create(const char *name)
94749474
if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL))
94759475
goto out_free_tr;
94769476

9477-
if (!alloc_cpumask_var(&tr->pipe_cpumask, GFP_KERNEL))
9477+
if (!zalloc_cpumask_var(&tr->pipe_cpumask, GFP_KERNEL))
94789478
goto out_free_tr;
94799479

94809480
tr->trace_flags = global_trace.trace_flags & ~ZEROED_TRACE_FLAGS;
@@ -10419,7 +10419,7 @@ __init static int tracer_alloc_buffers(void)
1041910419
if (trace_create_savedcmd() < 0)
1042010420
goto out_free_temp_buffer;
1042110421

10422-
if (!alloc_cpumask_var(&global_trace.pipe_cpumask, GFP_KERNEL))
10422+
if (!zalloc_cpumask_var(&global_trace.pipe_cpumask, GFP_KERNEL))
1042310423
goto out_free_savedcmd;
1042410424

1042510425
/* TODO: make the number of buffers hot pluggable with CPUS */

0 commit comments

Comments
 (0)