[PATCH v3 10/22] powerpc, csky, mips, sh: Mark the accessors behind current notrace

bot+bpf-ci at kernel.org bot+bpf-ci at kernel.org
Mon Nov 30 21:08:11 PST 2026


> powerpc, csky, mips, sh: Mark the accessors behind current notrace

TL;DR: Microblaze's current_thread_info() is not marked notrace; once inline
stops implying notrace, ftrace may possibly recurse without bound before the
recursion bit is set. Should it get the same annotation?

> diff --git a/arch/csky/include/asm/thread_info.h b/arch/csky/include/asm/thread_info.h
> --- a/arch/csky/include/asm/thread_info.h
> +++ b/arch/csky/include/asm/thread_info.h
> @@ -42,7 +42,7 @@ struct thread_info {
>  #define thread_saved_lr(tsk) \
>  	((unsigned long)(((struct switch_stack *)(tsk->thread.sp))->r15))
>  
> -static inline struct thread_info *current_thread_info(void)
> +static inline notrace struct thread_info *current_thread_info(void)
>  {
>  	unsigned long sp;
>  

[ ... ]

Microblaze also selects HAVE_FUNCTION_TRACER and does not select
THREAD_INFO_IN_TASK, and its current_thread_info() is still a plain inline:

arch/microblaze/include/asm/thread_info.h:
    static inline struct thread_info *current_thread_info(void)
    {
        register unsigned long sp asm("r1");

        return (struct thread_info *)(sp & ~(THREAD_SIZE-1));
    }

On microblaze, current is the r31 register variable, so this helper is not
behind current.  It is behind preempt_count() though, because microblaze
uses the generic include/asm-generic/preempt.h:

    static __always_inline int preempt_count(void)
    {
        return READ_ONCE(current_thread_info()->preempt_count);
    }

The recursion protection reaches it before the recursion bit is set:

function_trace_call()
  ftrace_test_recursion_trylock()
    trace_test_and_set_recursion()
      trace_get_context_bit()
        interrupt_context_level()
          preempt_count()
            current_thread_info()

preempt_disable_notrace() at the end of trace_test_and_set_recursion() also
reaches it through preempt_count_ptr().

Right now the helper is still notrace because inline implies notrace.  Once
a833438864c3 ("compiler_types: Move notrace from inline to __always_inline")
removes that, can an out-of-line copy of microblaze's current_thread_info()
get an mcount call, so that tracing it re-enters the callback before the
recursion bit is set and recurses without bound?

This is the same condition the patch handles on csky, mips and sh, where
current_thread_info() is behind both current and the generic
preempt_count().  The arm64 patch 4a65f9d5e118 says the generic preempt count
helpers are __always_inline, but they depend on the arch's
current_thread_info().

No commit in this series touches arch/microblaze.  m68k, nios2 and arc keep
a plain inline current_thread_info() but do not select HAVE_FUNCTION_TRACER.

Should arch/microblaze/include/asm/thread_info.h get the same notrace
annotation, here or in the preempt count patch?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107


More information about the linux-arm-kernel mailing list