Re: linux-next: build warning after merge of the tip tree

Paul E. McKenney
2021-09-17T15:58:17Z

On Fri, Sep 17, 2021 at 10:23:48AM +0200, Peter Zijlstra wrote:
> On Fri, Sep 17, 2021 at 11:58:59AM +1000, Stephen Rothwell wrote:
> > Hi all,
> >
> > After merging the tip tree, today's linux-next build (x86_64 allmodconfig)
> > produced this warning:
> >
> > vmlinux.o: warning: objtool: mce_setup()+0x22: call to memset() leaves .noinstr.text section
> > vmlinux.o: warning: objtool: do_machine_check()+0x51: call to mce_gather_info() leaves .noinstr.text section
>
> Those are pre-existing and Boris is lokoing into them, these however,
> are new:
>
> > vmlinux.o: warning: objtool: rcu_dynticks_eqs_enter()+0x0: call to rcu_dynticks_task_trace_enter() leaves .noinstr.text section
> > vmlinux.o: warning: objtool: rcu_dynticks_eqs_exit()+0xe: call to rcu_dynticks_task_trace_exit() leaves .noinstr.text section
>
> These are from 7d0c9c50c5a1 ("rcu-tasks: Avoid IPIing userspace/idle
> tasks if kernel is so built").
>
> The below seems to help.
>
> > vmlinux.o: warning: objtool: rcu_nmi_enter()+0x36: call to __kasan_check_read() leaves .noinstr.text section
>
> That's 2be57f732889 ("rcu: Weaken ->dynticks accesses and updates"),
> doing:
>
> - return !(arch_atomic_read(&this_cpu_ptr(&rcu_data)->dynticks) & 0x1);
> + return !(atomic_read(this_cpu_ptr(&rcu_data.dynticks)) & 0x1);
>
> and causing instrumentation to be inserted where none is acceptable.
> Flipping that back to arch_atomic_read() makes it go away as expected.

The 2be57f732889 commit went in during the v5.15 merge window and the
7d0c9c50c5a1 went into v5.8, but perhaps Linus won't be averse to taking
a fix for an older bug along with the regression. ;-)

Given no Signed-off-by, I am guessing that you would like to push
this separately. If so:

Tested-by: Paul E. McKenney <paulmck@kernel.org>

> ---
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 1a6fdb03d0a5..5199559fbbf0 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -1479,7 +1479,7 @@ static void rcu_bind_gp_kthread(void)
> }
>
> /* Record the current task on dyntick-idle entry. */
> -static void noinstr rcu_dynticks_task_enter(void)
> +static __always_inline void rcu_dynticks_task_enter(void)
> {
> #if defined(CONFIG_TASKS_RCU) && defined(CONFIG_NO_HZ_FULL)
> WRITE_ONCE(current->rcu_tasks_idle_cpu, smp_processor_id());
> @@ -1487,7 +1487,7 @@ static void noinstr rcu_dynticks_task_enter(void)
> }
>
> /* Record no current task on dyntick-idle exit. */
> -static void noinstr rcu_dynticks_task_exit(void)
> +static __always_inline void rcu_dynticks_task_exit(void)
> {
> #if defined(CONFIG_TASKS_RCU) && defined(CONFIG_NO_HZ_FULL)
> WRITE_ONCE(current->rcu_tasks_idle_cpu, -1);
> @@ -1495,7 +1495,7 @@ static void noinstr rcu_dynticks_task_exit(void)
> }
>
> /* Turn on heavyweight RCU tasks trace readers on idle/user entry. */
> -static void rcu_dynticks_task_trace_enter(void)
> +static __always_inline void rcu_dynticks_task_trace_enter(void)
> {
> #ifdef CONFIG_TASKS_TRACE_RCU
> if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB))
> @@ -1504,7 +1504,7 @@ static void rcu_dynticks_task_trace_enter(void)
> }
>
> /* Turn off heavyweight RCU tasks trace readers on idle/user exit. */
> -static void rcu_dynticks_task_trace_exit(void)
> +static __always_inline void rcu_dynticks_task_trace_exit(void)
> {
> #ifdef CONFIG_TASKS_TRACE_RCU
> if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB))
>