mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH v2] riscv: entry: Mark ret_from_fork_kernel() and ret_from_fork_user() noinstr
  2026-11-09  4:18 [PATCH v2] riscv: entry: Mark ret_from_fork_kernel() and ret_from_fork_user() noinstr Karl Mehltretter
@ 2026-11-09  4:16 ` Jisheng Zhang
  0 siblings, 0 replies; 2+ messages in thread
From: Jisheng Zhang @ 2026-11-09  4:16 UTC (permalink / raw)
  To: Karl Mehltretter
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Charlie Jenkins, Thomas Gleixner, Steven Rostedt, linux-riscv,
	linux-kernel

On Mon, Nov 09, 2026 at 05:18:45AM +0100, Karl Mehltretter wrote:
> ret_from_fork_kernel() and ret_from_fork_user() are traceable and
> return 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 after RCU stops
> watching and triggers the ftrace_return_to_handler() warning.
> 
> Mark ret_from_fork_kernel() and ret_from_fork_user() noinstr.
> 
> Fixes: f955aa8723a6 ("riscv: entry: Convert ret_from_fork() to C")
> Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>

Reviewed-by: Jisheng Zhang <jszhang@kernel.org>
> ---
> Assisted by an LLM.
> 
> v2:
>  - Drop instrumentation_begin()/instrumentation_end() around the kernel
>    thread callback. They only feed objtool's noinstr validation, which
>    riscv does not have (Jisheng Zhang). ret_from_fork_kernel() and
>    ret_from_fork_user() disassemble identically to v1 (Clang, defconfig
>    with NO_HZ_FULL and FUNCTION_GRAPH_TRACER).
> 
> v1: https://lore.kernel.org/r/20261107194931.69176-1-kmehltretter@gmail.com/
> 
> Tested with v1 on mainline d48723711bae (after v7.4-rc1) under QEMU
> riscv64 (-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.
> 
>  arch/riscv/kernel/process.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
> index 34c1d498d1cad..6f2b46d1a8e98 100644
> --- a/arch/riscv/kernel/process.c
> +++ b/arch/riscv/kernel/process.c
> @@ -225,14 +225,15 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
>  	return 0;
>  }
>  
> -asmlinkage void ret_from_fork_kernel(void *fn_arg, int (*fn)(void *), struct pt_regs *regs)
> +asmlinkage void noinstr ret_from_fork_kernel(void *fn_arg, int (*fn)(void *),
> +					     struct pt_regs *regs)
>  {
>  	fn(fn_arg);
>  
>  	syscall_exit_to_user_mode(regs);
>  }
>  
> -asmlinkage void ret_from_fork_user(struct pt_regs *regs)
> +asmlinkage void noinstr ret_from_fork_user(struct pt_regs *regs)
>  {
>  	syscall_exit_to_user_mode(regs);
>  }
> 
> base-commit: d48723711bae9b8cdc56719c448ba42fef28cbee
> -- 
> 2.39.5 (Apple Git-154)
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2] riscv: entry: Mark ret_from_fork_kernel() and ret_from_fork_user() noinstr
@ 2026-11-09  4:18 Karl Mehltretter
  2026-11-09  4:16 ` Jisheng Zhang
  0 siblings, 1 reply; 2+ messages in thread
From: Karl Mehltretter @ 2026-11-09  4:18 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti
  Cc: Karl Mehltretter, Jisheng Zhang, Charlie Jenkins,
	Thomas Gleixner, Steven Rostedt, linux-riscv, linux-kernel

ret_from_fork_kernel() and ret_from_fork_user() are traceable and
return 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 after RCU stops
watching and triggers the ftrace_return_to_handler() warning.

Mark ret_from_fork_kernel() and ret_from_fork_user() noinstr.

Fixes: f955aa8723a6 ("riscv: entry: Convert ret_from_fork() to C")
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
---
Assisted by an LLM.

v2:
 - Drop instrumentation_begin()/instrumentation_end() around the kernel
   thread callback. They only feed objtool's noinstr validation, which
   riscv does not have (Jisheng Zhang). ret_from_fork_kernel() and
   ret_from_fork_user() disassemble identically to v1 (Clang, defconfig
   with NO_HZ_FULL and FUNCTION_GRAPH_TRACER).

v1: https://lore.kernel.org/r/20261107194931.69176-1-kmehltretter@gmail.com/

Tested with v1 on mainline d48723711bae (after v7.4-rc1) under QEMU
riscv64 (-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.

 arch/riscv/kernel/process.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index 34c1d498d1cad..6f2b46d1a8e98 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -225,14 +225,15 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
 	return 0;
 }
 
-asmlinkage void ret_from_fork_kernel(void *fn_arg, int (*fn)(void *), struct pt_regs *regs)
+asmlinkage void noinstr ret_from_fork_kernel(void *fn_arg, int (*fn)(void *),
+					     struct pt_regs *regs)
 {
 	fn(fn_arg);
 
 	syscall_exit_to_user_mode(regs);
 }
 
-asmlinkage void ret_from_fork_user(struct pt_regs *regs)
+asmlinkage void noinstr ret_from_fork_user(struct pt_regs *regs)
 {
 	syscall_exit_to_user_mode(regs);
 }

base-commit: d48723711bae9b8cdc56719c448ba42fef28cbee
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-09  4:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09  4:18 [PATCH v2] riscv: entry: Mark ret_from_fork_kernel() and ret_from_fork_user() noinstr Karl Mehltretter
2026-11-09  4:16 ` Jisheng Zhang

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®