mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Aaron Tomlin <atomlin@atomlin.com>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, paulmck@kernel.org,
	dietmar.eggemann@arm.com, rostedt@goodmis.org,
	bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
	kprateek.nayak@amd.com, zhanxusheng1024@gmail.com,
	neelx@suse.com, chjohnst@mail.com, mproche@mail.com,
	sean@ashe.io, steve@abita.co, rishil1999@outlook.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 1/6] sched: Annotate rq->rd with __rcu and update lockless readers
Date: Thu, 27 Aug 2026 09:30:36 +0200	[thread overview]
Message-ID: <20260827073036.GC4121339@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260826224238.936456-2-atomlin@atomlin.com>

On Wed, Aug 26, 2026 at 06:42:33PM -0400, Aaron Tomlin wrote:
> The root_domain pointer rd field in struct rq is updated dynamically
> using RCU, and its memory reclamation is deferred via call_rcu() in
> rq_attach_root(). However, struct rq's rd field was missing the __rcu
> compiler annotation, and several lockless readers across the scheduler
> subsystem accessed rq->rd directly without using RCU dereference
> primitives.
> 
> Add the __rcu annotation to struct rq's rd field in kernel/sched/sched.h.
> Update lockless readers across kernel/sched/ to use rcu_dereference(),
> rcu_dereference_sched() or rcu_access_pointer() appropriately. This
> ensures proper data-dependency barriers on all architectures, enables
> Sparse static analysis validation, and documents RCU read-side ownership
> contracts.
> 
> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
> ---
>  kernel/sched/core.c     | 24 ++++++++++-----
>  kernel/sched/deadline.c | 67 +++++++++++++++++++++++------------------
>  kernel/sched/fair.c     | 29 +++++++++---------
>  kernel/sched/rt.c       | 64 ++++++++++++++++++++++-----------------
>  kernel/sched/sched.h    |  2 +-
>  kernel/sched/topology.c | 11 ++++---
>  6 files changed, 113 insertions(+), 84 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 2e7cde033a31..86de58f5825b 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -8547,8 +8547,10 @@ void set_rq_online(struct rq *rq)
>  {
>  	if (!rq->online) {
>  		const struct sched_class *class;
> +		struct root_domain *rd;
>  
> -		cpumask_set_cpu(rq->cpu, rq->rd->online);
> +		rd = rcu_dereference_protected(rq->rd, lockdep_is_held(&rq->__lock));

This seems wrong; rcu_dereference_protected() is only supposed to be
used during the update. And rq->lock is very much not the update side
lock of the topology.

Also, &rq->__lock is wrong.

And this is far too verbose to endlessly repeat.

  parent reply	other threads:[~2026-08-27  7:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 22:42 [PATCH v7 0/6] Introduce per-CPU debugfs files Aaron Tomlin
2026-08-26 22:42 ` [PATCH v7 1/6] sched: Annotate rq->rd with __rcu and update lockless readers Aaron Tomlin
2026-08-27  6:54   ` Vincent Guittot
2026-08-27  8:57     ` Aaron Tomlin
2026-08-27  7:30   ` Peter Zijlstra [this message]
2026-08-27  9:35     ` Aaron Tomlin
2026-08-27  9:39       ` Peter Zijlstra
2026-08-27  9:53         ` Aaron Tomlin
2026-08-27 10:50           ` Peter Zijlstra
2026-08-26 22:42 ` [PATCH v7 2/6] sched/debug: Protect lockless rq->rd access in print_dl_rq() Aaron Tomlin
2026-08-26 22:42 ` [PATCH v7 3/6] sched/debug: Protect lockless rq->curr access in print_cpu() Aaron Tomlin
2026-08-26 22:42 ` [PATCH v7 4/6] sched/debug: Protect p->mm access in sched_show_numa() Aaron Tomlin
2026-08-26 22:42 ` [PATCH v7 5/6] sched/fair: Use list_for_each_entry_rcu() in print_cfs_stats() Aaron Tomlin
2026-08-26 22:42 ` [PATCH v7 6/6] sched/debug: Introduce per-CPU debugfs files Aaron Tomlin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260827073036.GC4121339@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=atomlin@atomlin.com \
    --cc=bsegall@google.com \
    --cc=chjohnst@mail.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=mproche@mail.com \
    --cc=neelx@suse.com \
    --cc=paulmck@kernel.org \
    --cc=rishil1999@outlook.com \
    --cc=rostedt@goodmis.org \
    --cc=sean@ashe.io \
    --cc=steve@abita.co \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=zhanxusheng1024@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®