public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: jstultz@google.com, kprateek.nayak@amd.com,
	linux-kernel@vger.kernel.org, mingo@kernel.org,
	juri.lelli@redhat.com, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	vschneid@redhat.com
Subject: Re: [PATCH 2/2] sched/debug: Fix avg_vruntime() usage
Date: Wed, 1 Apr 2026 18:14:19 +0200	[thread overview]
Message-ID: <20260401161419.GY2872@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAKfTPtC1Uwbqy7ZgdqPW-NH89SXYVo8RoCQDg8rcKiuYshTP5Q@mail.gmail.com>

On Wed, Apr 01, 2026 at 04:13:06PM +0200, Vincent Guittot wrote:
> On Wed, 1 Apr 2026 at 15:24, Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > John reported that stress-ng-yield could make his machine unhappy and
> > managed to bisect it to commit b3d99f43c72b ("sched/fair: Fix
> > zero_vruntime tracking").
> >
> > The commit in question changes avg_vruntime() from a function that is
> > a pure reader, to a function that updates variables. This turns an
> > unlocked sched/debug usage of this function from a minor mistake into
> > a data corruptor.
> >
> > Fixes: af4cf40470c2 ("sched/fair: Add cfs_rq::avg_vruntime")
> > Fixes: b3d99f43c72b ("sched/fair: Fix zero_vruntime tracking")
> > Reported-by: John Stultz <jstultz@google.com>
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
> > Tested-by: John Stultz <jstultz@google.com>
> > ---
> >  kernel/sched/debug.c |    4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > --- a/kernel/sched/debug.c
> > +++ b/kernel/sched/debug.c
> > @@ -902,6 +902,7 @@ static void print_rq(struct seq_file *m,
> >  void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
> >  {
> >         s64 left_vruntime = -1, zero_vruntime, right_vruntime = -1, left_deadline = -1, spread;
> > +       u64 avruntime;
> >         struct sched_entity *last, *first, *root;
> >         struct rq *rq = cpu_rq(cpu);
> >         unsigned long flags;
> > @@ -925,6 +926,7 @@ void print_cfs_rq(struct seq_file *m, in
> >         if (last)
> >                 right_vruntime = last->vruntime;
> >         zero_vruntime = cfs_rq->zero_vruntime;
> > +       avruntime = avg_vruntime(cfs_rq);
> 
> Minor comment:
> Do you intentionally save zero_vruntime before callling avg_vruntime()
> which will update zero_vruntime ?
> That could make sense to take a snapshot before being modified by
> print_cfs_rq() but I'm afraid the call to debugfs will anyway trigger
> an update before we save and display the value

Intentional might be a big word, but yeah, printing the same value twice
seemed pointless. This way you can at least see where it came from or
something.

> Reviewed-by: Vincent Guittot <vincent.guittot@linaor.rog>

Thanks!


  reply	other threads:[~2026-04-01 16:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01 13:20 [PATCH 0/2] sched/urgent: zero_vruntime fixes Peter Zijlstra
2026-04-01 13:20 ` [PATCH 1/2] sched/fair: Fix zero_vruntime tracking fix Peter Zijlstra
2026-04-01 14:55   ` Vincent Guittot
2026-04-02 11:46   ` [tip: sched/urgent] " tip-bot2 for Peter Zijlstra
2026-04-01 13:20 ` [PATCH 2/2] sched/debug: Fix avg_vruntime() usage Peter Zijlstra
2026-04-01 14:13   ` Vincent Guittot
2026-04-01 16:14     ` Peter Zijlstra [this message]
2026-04-02 11:46   ` [tip: sched/urgent] " tip-bot2 for Peter Zijlstra
2026-04-01 13:26 ` [PATCH 0/2] sched/urgent: zero_vruntime fixes Peter Zijlstra
2026-04-01 17:26 ` John Stultz

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=20260401161419.GY2872@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=jstultz@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --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