From: Peter Zijlstra <peterz@infradead.org>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
kprateek.nayak@amd.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/fair: Fix flat hierarchy
Date: Thu, 13 Aug 2026 12:31:55 +0200 [thread overview]
Message-ID: <20260813103155.GC1246887@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAKfTPtBB2u+h9S5Aj1gNRESatGeTN7DvN_zfcubooF2wFgJmUw@mail.gmail.com>
On Wed, Aug 12, 2026 at 04:21:14PM +0200, Vincent Guittot wrote:
> On Wed, 12 Aug 2026 at 16:03, Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Wed, Aug 12, 2026 at 02:50:39PM +0200, Vincent Guittot wrote:
> > > When a fair task is enqueued, we must update curr and more precisely
> > > its vruntime before placing the enqueued task so avg vruntime will take
> > > into account the last exec phase.
> > >
> > > Example:
> > > TA is an always running task in cgroup G0.
> > > TB is a short running task (cyclictest) in cgroup G1.
> > > The lag of TB always increases up the clamp limit because TB is placed
> > > before TA(curr) is updated (since the last tick). When curr(TA) is
> > > finally updated, its last exec phase provide positive lag to TB
> > >
> > > Because TA and TB don't belong to the same group, enqueue_hierarchy()
> > > will not update TA's entity when updating curr but only G0's entity at
> > > root level.
> > >
> > > The same applies when dequeuing.
> >
> > This doesn't quite make sense to me; on the one hand you talk about
> > vruntime (which is only relevant for rq->cfs) on the other hand you talk
> > about non overlapping cgroup hierarchies.
> >
> > Hmm, update_curr() looks at ->h_curr, which is the intermediate crud. So
> > even though it updates all the cgroup nonsense, it will not in fact
> > update the root group, because it never actually sees rq->cfs.curr.
>
> Exactly
>
> >
> > Bah.
> >
> > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > > index dcf860c59a14..649b4f7505a1 100644
> > > --- a/kernel/sched/fair.c
> > > +++ b/kernel/sched/fair.c
> > > @@ -7983,6 +7983,9 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
> > > if (!p->se.sched_delayed || (flags & ENQUEUE_DELAYED))
> > > util_est_enqueue(cfs_rq, p);
> > >
> > > + if (cfs_rq->curr)
> > > + update_curr(cfs_rq_of(cfs_rq->curr));
> > > +
> >
> > Still, I think this wants to be in a different spot. It needs to be
> > below the whole initial if(curr) place_entity() thing. Perhaps stick
> > these into {en,de}queue_hierarchy() ?
>
> But are we sure that cfs_rq->curr has been updated ? Otherwise it
> means that we place cfs_rq->curr before having updated its vruntime so
> avg_vruntime will not account the last running phase.
>
> The same applies when we requeue a delayed entity.
Well, it is the same place the update was previously, no? Also, that XXX
comment thing is about enqueueing self, with the thinking that you
should not shift time since dequeue, allowing 'atomic' dequeue+enqueue.
However, looking at things now, I can't actually see how this could
happen in the new code. Putting a trace_printk() in also doesn't seem to
help much.
So perhaps there is some dead code there to clean up as well. But for
consistencies sake I think placing it near {en,de}queue_hierarchy()
where the other update_curr() lived/lives makes most sense.
Hmm?
next prev parent reply other threads:[~2026-08-13 10:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 12:50 [PATCH] sched/fair: Fix flat hierarchy Vincent Guittot
2026-08-12 14:03 ` Peter Zijlstra
2026-08-12 14:21 ` Vincent Guittot
2026-08-13 10:31 ` Peter Zijlstra [this message]
2026-08-13 10:49 ` Vincent Guittot
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=20260813103155.GC1246887@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bsegall@google.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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.