On Mon, 2 Mar 2026 21:35:46 -0500 Steven Rostedt <[email protected]> wrote:
> From: Steven Rostedt <[email protected]> > > When function trace PID filtering is enabled, the function tracer will > attach a callback to the fork tracepoint as well as the exit tracepoint > that will add the forked child PID to the PID filtering list as well as > remove the PID that is exiting. > > Commit a46023d5616e ("tracing: Guard __DECLARE_TRACE() use of > __DO_TRACE_CALL() with SRCU-fast") removed the disabling of preemption > when calling tracepoint callbacks. > > The callbacks used for the PID filtering accounting depended on preemption > being disabled, and now the trigger a "suspicious RCU usage" warning message. > > Make them explicitly disable preemption. > Hmm, we still have another "WARNING: suspicious RCU usage" [37] event tracing - restricts events based on pid notrace filtering[ 155.874095] [ 155.874869] ============================= [ 155.876037] WARNING: suspicious RCU usage [ 155.877287] 7.0.0-rc1-00004-g8cd473a19bc7 #7 Not tainted [ 155.879263] ----------------------------- [ 155.882839] kernel/trace/trace_events.c:1057 suspicious rcu_dereference_check() usage! [ 155.889281] [ 155.889281] other info that might help us debug this: [ 155.889281] [ 155.894519] [ 155.894519] rcu_scheduler_active = 2, debug_locks = 1 [ 155.898068] no locks held by ftracetest/4364. [ 155.900524] [ 155.900524] stack backtrace: [ 155.902645] CPU: 1 UID: 0 PID: 4364 Comm: ftracetest Not tainted 7.0.0-rc1-00004-g8cd473a19bc7 #7 PREEMPT(lazy) [ 155.902648] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014 [ 155.902651] Call Trace: [ 155.902655] <TASK> [ 155.902659] dump_stack_lvl+0x67/0x90 [ 155.902665] lockdep_rcu_suspicious+0x154/0x1a0 [ 155.902672] event_filter_pid_sched_process_fork+0x9a/0xd0 [ 155.902678] kernel_clone+0x367/0x3a0 [ 155.902689] __x64_sys_clone+0x116/0x140 [ 155.902696] do_syscall_64+0x158/0x460 [ 155.902700] ? entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 155.902702] ? trace_irq_disable+0x1d/0xc0 [ 155.902709] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 155.902711] RIP: 0033:0x4697c3 [ 155.902716] Code: 1f 84 00 00 00 00 00 64 48 8b 04 25 10 00 00 00 45 31 c0 31 d2 31 f6 bf 11 00 20 01 4c 8d 90 d0 02 00 00 b8 38 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 89 c2 85 c0 75 2c 64 48 8b 04 25 10 00 00 [ 155.902718] RSP: 002b:00007ffc41150428 EFLAGS: 00000246 ORIG_RAX: 0000000000000038 [ 155.902721] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00000000004697c3 [ 155.902722] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000001200011 [ 155.902724] RBP: 0000000000000000 R08: 0000000000000000 R09: 000000003fccf990 [ 155.902725] R10: 000000003fccd690 R11: 0000000000000246 R12: 0000000000000001 [ 155.902726] R13: 000000003fce8103 R14: 0000000000000001 R15: 0000000000000000 [ 155.902733] </TASK> [ 155.902747] It seems we need 2 more guard()s. diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 9928da636c9d..3b3aaf4831e9 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1039,6 +1039,7 @@ event_filter_pid_sched_process_exit(void *data, struct task_struct *task) struct trace_pid_list *pid_list; struct trace_array *tr = data; + guard(preempt)(); pid_list = rcu_dereference_raw(tr->filtered_pids); trace_filter_add_remove_task(pid_list, NULL, task); @@ -1054,6 +1055,7 @@ event_filter_pid_sched_process_fork(void *data, struct trace_pid_list *pid_list; struct trace_array *tr = data; + guard(preempt)(); pid_list = rcu_dereference_sched(tr->filtered_pids); trace_filter_add_remove_task(pid_list, self, task); Thanks, > Fixes: a46023d5616e ("tracing: Guard __DECLARE_TRACE() use of > __DO_TRACE_CALL() with SRCU-fast") > Signed-off-by: Steven Rostedt (Google) <[email protected]> > --- > kernel/trace/ftrace.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 1ce17c8af409..5274e0cab8f3 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -8611,6 +8611,7 @@ ftrace_pid_follow_sched_process_fork(void *data, > struct trace_pid_list *pid_list; > struct trace_array *tr = data; > > + guard(preempt)(); > pid_list = rcu_dereference_sched(tr->function_pids); > trace_filter_add_remove_task(pid_list, self, task); > > @@ -8624,6 +8625,7 @@ ftrace_pid_follow_sched_process_exit(void *data, struct > task_struct *task) > struct trace_pid_list *pid_list; > struct trace_array *tr = data; > > + guard(preempt)(); > pid_list = rcu_dereference_sched(tr->function_pids); > trace_filter_add_remove_task(pid_list, NULL, task); > > -- > 2.51.0 > -- Masami Hiramatsu (Google) <[email protected]>
