mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Christian Loehle <christian.loehle@arm.com>
Cc: Kayra Cizmeci <kayracizmeci@gmail.com>,
	Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] sched/fair: remove dead code on enqueue_task_fair()
Date: Tue, 13 Oct 2026 13:58:35 +0200	[thread overview]
Message-ID: <20261013115835.GI2009045@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <5661a8d7-1a83-4336-b238-589f598075cf@arm.com>

On Mon, Oct 12, 2026 at 03:59:40PM +0100, Christian Loehle wrote:
> On 10/12/26 15:02, Peter Zijlstra wrote:

> > Anyway, this is different from the initial use-case, where a
> > sched_entity would get dequeue and re-enqueued while walking the cgroup
> > hierarchy, and thus had to appear like nothing happened in between.
> > 
> > In this case we're fine to advance time.
> > 
> > Anyway... the normal block/wakeup paths are >< close to also hitting
> > this in the case where balancing drops the rq->lock after dequeue. The
> > only reason ttwu can't tickle this is because it has that ->on_cpu
> > stuff. However, we cannot use that on the unthrottle path :/
> > 
> > Bah.
> > 
> > Does this work?
> > 
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 5c98d8dfce5d..0edd8bfb6363 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -8250,7 +8250,14 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
> >  	weight = enqueue_hierarchy(p, flags);
> >  	reweight_eevdf(cfs_rq, se, weight, false);
> >  	place_entity(cfs_rq, se, flags | ENQUEUE_QUEUED);
> > -	__enqueue_entity(cfs_rq, se);
> > +
> > +	/*
> > +	 * This can actually happen with CFS_BANDWIDTH, in that case a task
> > +	 * can get throttled, dequeued and then unthrottled, woken *before* it
> > +	 * schedules out and does put_prev_task().
> > +	 */
> > +	if (cfs_rq->curr != se)
> > +		__enqueue_entity(cfs_rq, se);
> >  
> >  	if (!rq_h_nr_queued && rq->cfs.h_nr_queued)
> >  		dl_server_start(&rq->fair_server);
> 
> Tested-by: Christian Loehle <christian.loehle@arm.com>
> for my reproducer, that being said, and indeed the failure is:
> throttle -> dequeue (not put_prev_task()'d yet) -> (from remote CPU) unthrottle -> enqueue()
> 
> The dequeue()->enqueue() also lets place_entity()
> 'double-account' the entity's (on dequeue() saved) lag, right?
> After dequeue:       curr == se, on_rq == 0 -> excl from average
> enqueue_hierarchy(): curr == se, on_rq == 1 -> incl again
> place_entity():      calculate placement assuming se is excl

I'm not entirely sure I follow. With the above fix there is still only
one place_entity(), which is after enqueue_hierarchy() and has
ENQUEUE_QUEUED on.

Here enqueue_hierarchy() adds the entity to h_nr_queued, and
ENQUEUE_QUEUED tells place_entity() exactly this, so it can adjust.

  reply	other threads:[~2026-10-13 11:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 12:52 [PATCH 1/2] sched/fair: reuse the ENQUEUE_DELAYED calculation in enqueue_task_fair() Kayra Cizmeci
2026-08-24 12:52 ` [PATCH 2/2] sched/fair: avoid recalculating curr status in place_entity() and requeue_delayed_entity() Kayra Cizmeci
2026-08-26 10:15 ` [PATCH v2 0/2] sched/fair: reduce repeated work in enqueue path Kayra Cizmeci
2026-08-26 10:15   ` [PATCH v2 1/2] sched/fair: reuse the ENQUEUE_DELAYED calculation in enqueue_task_fair() Kayra Cizmeci
2026-08-26 10:41     ` K Prateek Nayak
2026-08-26 18:44       ` Kayra Cizmeci
2026-09-07 16:05       ` [PATCH] sched/fair: Remove unused autogroup.h include Kayra Cizmeci
2026-09-07 16:14         ` [PATCH v2 1/2] sched/fair: reuse the ENQUEUE_DELAYED calculation in enqueue_task_fair() Kayra Cizmeci
2026-08-26 10:15   ` [PATCH v2 2/2] sched/fair: avoid recalculating curr status in place_entity() and requeue_delayed_entity() Kayra Cizmeci
2026-09-11 10:57     ` Kayra Cizmeci
2026-09-11 12:19     ` Vincent Guittot
2026-09-11 13:10       ` Kayra Cizmeci
2026-09-11 12:42     ` Peter Zijlstra
2026-09-11 14:08       ` Kayra Cizmeci
2026-09-11 16:02       ` [PATCH v3] sched/fair: remove dead code on enqueue_task_fair() Kayra Cizmeci
2026-10-12 12:58         ` Christian Loehle
2026-10-12 13:33           ` Kayra Cizmeci
2026-10-12 14:02           ` Peter Zijlstra
2026-10-12 14:15             ` Kayra Cizmeci
2026-10-12 14:59             ` Christian Loehle
2026-10-13 11:58               ` Peter Zijlstra [this message]
2026-10-13 13:42                 ` Kayra Cizmeci
2026-10-13 19:56                 ` Christian Loehle

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=20261013115835.GI2009045@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bsegall@google.com \
    --cc=christian.loehle@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kayracizmeci@gmail.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 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®