From: Peter Zijlstra <peterz@infradead.org>
To: Josh Don <joshdon@google.com>
Cc: Kayra Cizmeci <kayracizmeci@gmail.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
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,
jakub@okonski.org, longman@redhat.com, tj@kernel.org,
hannes@cmpxchg.org, mkoutny@suse.com, cgroups@vger.kernel.org,
jstultz@google.com, qyousef@layalina.io
Subject: Re: [PATCH v2] sched/eevdf: Fix sched idle task group preemption
Date: Thu, 22 Oct 2026 23:21:50 +0200 [thread overview]
Message-ID: <20261022212150.GW2823843@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CABk29NviVUAK6B_deQ7qah8eABiCikbFpTwDEO2hdproGLdLwQ@mail.gmail.com>
On Thu, Oct 22, 2026 at 10:49:36AM -0700, Josh Don wrote:
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index b5546cd27dba..779fcd5a2830 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -15767,6 +15767,40 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)
> > return ret;
> > }
> >
> > +struct tg_set_idle_struct {
> > + long idle;
> > + int cpu;
> > +};
> > +
> > +static int tg_set_idle_up(struct task_group *tg, void *data)
> > +{
> > + struct tg_set_idle_struct *tsi = data;
> > + struct cfs_rq *grp_cfs_rq = tg_cfs_rq(tg, tsi->cpu);
> > + struct sched_entity *se = tg_se(tg, tsi->cpu);
> > + int old_idle = grp_cfs_rq->idle;
> > + long task_delta;
> > +
> > + grp_cfs_rq->idle += tsi->idle;
> > +
> > + if (!!old_idle == !!grp_cfs_rq->idle)
> > + return 0;
> > +
> > + task_delta = grp_cfs_rq->h_nr_queued - grp_cfs_rq->h_nr_idle;
> > + if (!task_delta)
> > + return 0;
> > +
> > + task_delta *= tsi->idle;
> > +
> > + for_each_sched_entity(se) {
> > + if (!se->on_rq)
> > + break;
> > +
> > + cfs_rq_of(se)->h_nr_idle += task_delta;
> > + }
> > +
> > + return 0;
> > +}
>
> Took me a bit to parse this double traversal. I think this is broken
> for the clear side?
>
> root
> |
> A ( 2 tasks)
> |
> B (3 tasks)
>
> If we start out with A marked as idle, then we have
> root: h_nr_idle = 5
> A: h_nr_idle = 3
> B: h_nr_idle = 0
>
> When we clear, we'll first start with B and subtract 3...
> root: h_nr_idle = 2
> A: h_nr_idle = 0
> B: h_nr_idle = 0
>
> Then we go to A and try to subtract 5 leading to
> root: h_nr_idle = -3
>
Argh. Yes, I seem to have gotten it wrong. I'll try again in the
morning.
prev parent reply other threads:[~2026-10-22 21:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 18:26 Vincent Guittot
2026-10-21 7:19 ` Kayra Cizmeci
2026-10-21 13:13 ` Peter Zijlstra
2026-10-21 13:32 ` Vincent Guittot
2026-10-21 13:41 ` Kayra Cizmeci
2026-10-21 14:50 ` Peter Zijlstra
2026-10-21 15:18 ` Kayra Cizmeci
2026-10-21 16:39 ` Josh Don
2026-10-22 11:47 ` Peter Zijlstra
2026-10-22 14:04 ` Kayra Cizmeci
2026-10-22 17:49 ` Josh Don
2026-10-22 21:21 ` Peter Zijlstra [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=20261022212150.GW2823843@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=hannes@cmpxchg.org \
--cc=jakub@okonski.org \
--cc=joshdon@google.com \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=kayracizmeci@gmail.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=qyousef@layalina.io \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.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
all inboxes | Powered by JetHome®