Re: [tip:sched/core] [sched/fair] c9d93a73ce: WARNING:suspicious_RCU_usage

From: Andrea Righi

Date: Mon May 25 2026 - 00:24:49 EST


Hello,

On Mon, May 25, 2026 at 09:53:22AM +0800, Chen, Yu C wrote:
> On 5/23/2026 9:27 PM, kernel test robot wrote:
>
> >
> > [ 102.159951][ T23]
> > [ 102.160730][ T23] =============================
> > [ 102.162072][ T23] WARNING: suspicious RCU usage
> > [ 102.163398][ T23] 7.1.0-rc2-00011-gc9d93a73ce87 #1 Not tainted
> > [ 102.165064][ T23] -----------------------------
> > [ 102.167687][ T23] kernel/sched/fair.c:12793 suspicious rcu_dereference_check() usage!
> > [ 102.169994][ T23]

This should be fixed by
https://lore.kernel.org/all/20260522092523.2046095-1-arighi@xxxxxxxxxx/

Thanks,
-Andrea

>
> sched_cpu_deactivate() does not hold RCU read lock, nor are
> preemption/IRQs/BH disabled,
> how about this:
> static void set_cpu_sd_state_busy(int cpu)
> {
> struct sched_domain *sd;
> - sd = rcu_dereference_all(per_cpu(sd_llc, cpu));
> + sd = rcu_dereference_all_check(per_cpu(sd_llc, cpu),
> + lockdep_is_cpus_held());
>
> /*
> * sd->nohz_idle only pairs with nr_busy_cpus on sd->shared; if this
> @@ -12815,7 +12817,8 @@ void nohz_balance_exit_idle(struct rq *rq)
> static void set_cpu_sd_state_idle(int cpu)
> {
> struct sched_domain *sd;
> - sd = rcu_dereference_all(per_cpu(sd_llc, cpu));
> + sd = rcu_dereference_all_check(per_cpu(sd_llc, cpu),
> + lockdep_is_cpus_held());
>
> /* See set_cpu_sd_state_busy(): nohz_idle is only used with
> sd->shared. */
> if (!sd || !sd->shared || sd->nohz_idle)