* [PATCH] x86/process: Mark ret_from_fork() noinstr
@ 2026-11-07 19:16 Karl Mehltretter
0 siblings, 0 replies; only message in thread
From: Karl Mehltretter @ 2026-11-07 19:16 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
Cc: Karl Mehltretter, H. Peter Anvin, Brian Gerst, Peter Zijlstra,
Steven Rostedt, linux-kernel
ret_from_fork() is traceable and returns after
syscall_exit_to_user_mode() enters the RCU extended quiescent state via
user_enter_irqoff() on NO_HZ_FULL CPUs. When function_graph tracing is
enabled with FTRACE_VALIDATE_RCU_IS_WATCHING, the return hook runs in
ret_from_fork() after RCU stops watching and triggers the
ftrace_return_to_handler() warning.
Mark ret_from_fork() noinstr and bracket schedule_tail() and the kernel
thread callback with instrumentation_begin() and instrumentation_end().
Fixes: 3aec4ecb3d1f ("x86: Rewrite ret_from_fork() in C")
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
---
Assisted by an LLM.
Tested on v7.4-rc1 (d48723711bae) under QEMU x86_64 (-smp 4) with
NO_HZ_FULL, FTRACE_VALIDATE_RCU_IS_WATCHING, PROVE_LOCKING,
nohz_full=1-3 rcu_nocbs=1-3 on the kernel command line, and
function_graph tracing during parallel fork bursts across CPUs 0-3.
Without this patch, two consecutive runs trigger:
RCU not on for: ret_from_fork+0x4/0x370
WARNING: include/linux/trace_recursion.h:132 at ftrace_return_to_handler+0x185/0x2e0, CPU#3
With this patch, two consecutive runs complete without the
ftrace_return_to_handler() warning.
arch/x86/kernel/process.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 346c438ac8801..270d663e95c76 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -148,9 +148,10 @@ static int set_new_tls(struct task_struct *p, unsigned long tls)
return do_set_thread_area_64(p, ARCH_SET_FS, tls);
}
-__visible void ret_from_fork(struct task_struct *prev, struct pt_regs *regs,
+__visible noinstr void ret_from_fork(struct task_struct *prev, struct pt_regs *regs,
int (*fn)(void *), void *fn_arg)
{
+ instrumentation_begin();
schedule_tail(prev);
/* Is this a kernel thread? */
@@ -163,6 +164,7 @@ __visible void ret_from_fork(struct task_struct *prev, struct pt_regs *regs,
*/
regs->ax = 0;
}
+ instrumentation_end();
syscall_exit_to_user_mode(regs);
}
base-commit: d48723711bae9b8cdc56719c448ba42fef28cbee
--
2.39.5 (Apple Git-154)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-07 19:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-07 19:16 [PATCH] x86/process: Mark ret_from_fork() noinstr Karl Mehltretter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®