mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krister Johansen <kjlx@templeofstupid.com>
To: Peng Wang <peng_wang@linux.alibaba.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	mingo@redhat.com, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	vschneid@redhat.com, vdavydov.dev@gmail.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/fair: Clear ->h_load_next after hierarchical load
Date: Mon, 17 Nov 2025 10:59:47 -0800	[thread overview]
Message-ID: <aRtwo3Bg_ipNHYRq@templeofstupid.com> (raw)
In-Reply-To: <20251016030617.GA46570@j38d01266.eu95sqa>

On Thu, Oct 16, 2025 at 11:06:17AM +0800, Peng Wang wrote:
> On Wed, Oct 15, 2025 at 02:44:22PM +0200, Peter Zijlstra wrote:
> > On Wed, Oct 15, 2025 at 08:19:50PM +0800, Peng Wang wrote:
> > 
> > > We found that the task_group corresponding to the problematic se
> > > is not in the parent task_group’s children list, indicating that
> > > h_load_next points to an invalid address. Consider the following
> > > cgroup and task hierarchy:
> > > 
> > >          A
> > >         / \
> > >        /   \
> > >       B     E
> > >      / \    |
> > >     /   \   t2
> > >    C     D
> > >    |     |
> > >    t0    t1
> > > 
> > > Here follows a timing sequence that may be responsible for triggering
> > > the problem:
> > > 
> > > CPU X                   CPU Y                   CPU Z
> > > wakeup t0
> > > set list A->B->C
> > > traverse A->B->C
> > > t0 exits
> > > destroy C
> > >                         wakeup t2
> > >                         set list A->E           wakeup t1
> > >                                                 set list A->B->D
> > >                         traverse A->B->C
> > >                         panic
> > > 
> > > CPU Z sets ->h_load_next list to A->B->D, but due to arm64 weaker memory
> > > ordering, Y may observe A->B before it sees B->D, then in this time window,
> > > it can traverse A->B->C and reach an invalid se.
> > 
> > Hmm, I rather think we should ensure update_cfs_rq_h_load() is
> > serialized against unregister_fair_sched_group().
> 
> I might be mistaken, but it seems that, even with RCU protection around
> update_cfs_rq_h_load(), there remains a risk of reading stale values.
> 
> 
>  CPU X                   CPU Y                   CPU Z
> 
>  wakeup t0
>  rcu_read_lock()
>  set list A->B->C
>  traverse A->B->C
>  rcu_read_unlock()
>  t0 exits
>  destroy C
> 
> After the prior RCU grace period has elapsed, C has already been reclaimed,
> yet the stale A->B->C remains.
> 
> 
>                          wakeup t2
>                          rcu_read_lock()
>                          set list A->E           wakeup t1
>                                                  rcu_read_lock()
>                                                  set list A->B->D
>                                                       ...
>                          traverse A->B->C
>                          panic
> 
> A subsequent rcu_read_lock() only guarantees that A/B/D/E will not be
> reclaimed while the list is being traversed; C had already been freed
> before the next grace period even began.

FWIW, I've caught arm64 machines running into this problem recently on
6.x kernels.  These particular systems are small enough that they have
just a single memory node and no NUMA balancing enabled.

Would the scheduling experts be willing to consider picking up Peng's
fix while the 6.18 release is still open for bug fixes?

-K

      reply	other threads:[~2025-11-17 18:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15 12:19 Peng Wang
2025-10-15 12:44 ` Peter Zijlstra
2025-10-15 13:14   ` Vincent Guittot
2025-10-15 14:46     ` Peter Zijlstra
2025-10-22  9:00     ` Peng Wang
2025-10-22 12:52       ` Vincent Guittot
2025-10-23  6:28         ` [PATCH v2] sched/fair: Clear ->h_load_next when unregistering cgroup Peng Wang
2025-10-24  7:08           ` Vincent Guittot
2025-10-24  7:23             ` [PATCH v3] " Peng Wang
2025-10-24  7:52               ` Vincent Guittot
2025-12-03  8:17                 ` Peng Wang
2025-10-16  3:06   ` [PATCH] sched/fair: Clear ->h_load_next after hierarchical load Peng Wang
2025-11-17 18:59     ` Krister Johansen [this message]

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=aRtwo3Bg_ipNHYRq@templeofstupid.com \
    --to=kjlx@templeofstupid.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peng_wang@linux.alibaba.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vdavydov.dev@gmail.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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®