Re: [PATCH v7 1/6] sched: Annotate rq->rd with __rcu and update lockless readers

From: Peter Zijlstra

Date: Thu Aug 27 2026 - 05:44:42 EST


On Thu, Aug 27, 2026 at 05:35:44AM -0400, Aaron Tomlin wrote:

> To solve this cleanly, I propose introducing a concise helper, for the root
> domain in kernel/sched/sched.h mirroring rcu_dereference_sched_domain(p):
>
> #define rcu_dereference_root_domain(p) \
> rcu_dereference_all_check((p), lockdep_is_held(&sched_domains_mutex))
>
> This covers both the update side (under sched_domains_mutex) and read-side
> contexts (under rq_lock(), preemption-disabled, or RCU read locks) via
> rcu_read_lock_any_held(), while keeping the call sites clean and
> eliminating Sparse warnings.
>
> Would you prefer rcu_dereference_root_domain(p)?

Yeah, but I'm not sure I see the point of adding it, as it is exactly
the same as rcu_dereference_sched_domain(). The root domains are part of
the sched domains, so it doesn't seem wrong to me to use that existing
one.