mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kayra Cizmeci <kayracizmeci@gmail.com>
To: peterz@infradead.org
Cc: bsegall@google.com, dietmar.eggemann@arm.com,
	juri.lelli@redhat.com, kayracizmeci@gmail.com,
	kprateek.nayak@amd.com, linux-kernel@vger.kernel.org,
	mgorman@suse.de, mingo@redhat.com, rostedt@goodmis.org,
	vincent.guittot@linaro.org, vschneid@redhat.com
Subject: Re: [PATCH v2 2/2] sched/fair: avoid recalculating curr status in place_entity() and requeue_delayed_entity()
Date: Fri, 11 Sep 2026 17:08:24 +0300	[thread overview]
Message-ID: <20260911140824.1248362-1-kayracizmeci@gmail.com> (raw)
In-Reply-To: <20260911124256.GZ776954@noisy.programming.kicks-ass.net>

Hello Peter :>,

>> In enqueue_task_fair() a bool is calculated by cfs_rq->curr == se.
>> But this information gets recalculated on requeue_delayed_entity() and
>> requeue_delayed_entity() only gets called in enqueue_task_fair().
>> And on place_entity() if se == curr we call the avg_vruntime_weight()
>> twice with the same input. place_entity() only gets called in
>> enqueue_task_fair() and requeue_delayed_entity().

> I found it very hard to follow your Changelog. Could be my Friday brain.
> Sorry if I misunderstood.

It's not your Friday brain, it's my talking skills ;>.

> As I argued here:

>  https://patch.msgid.link/20260813103155.GC1246887%40noisy.programming.kicks-ass.net

Oh, I remembered that patch. 1 month ago. But I didn't look into it in detail at the time.

> I suspect that case is impossible. Which AFAICT renders your whole patch
> one big no-op, no?

Well, I run some tests with WARN_ON_ONCE and that case never worked. Atleast on my tests and on my machine. I didn't done so many tests tho.

I remember doing some WARN_ON_ONCE tests on v1 too. But I don't think I did
a test about curr == se, since I thought there was no way that it does not work. Well... :P.



> That is, I think we want to do the below.

> ---
>  kernel/sched/fair.c | 16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 4d0b94465d19..3c7fb0684a76 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7996,7 +7996,6 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
>         struct sched_entity *se = &p->se;
>         struct cfs_rq *cfs_rq = &rq->cfs;
>         unsigned long weight;
> -       bool curr;
> 
>         if (task_is_throttled(p) && enqueue_throttled_task(p))
>                 return;
> @@ -8025,23 +8024,14 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
>         if (p->in_iowait)
>                 cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT);
> 
> -       /*
> -        * XXX comment on the curr thing
> -        */
> -       curr = (cfs_rq->curr == se);
> -       if (curr)
> -               place_entity(cfs_rq, se, flags);
>
>         if (se->on_rq && se->sched_delayed)
>                 requeue_delayed_entity(cfs_rq, se);
> 
>         weight = enqueue_hierarchy(p, flags);
> -
> -       if (!curr) {
> -               reweight_eevdf(cfs_rq, se, weight, false);
> -               place_entity(cfs_rq, se, flags | ENQUEUE_QUEUED);
> -               __enqueue_entity(cfs_rq, se);
> -       }
> +       reweight_eevdf(cfs_rq, se, weight, false);
> +       place_entity(cfs_rq, se, flags | ENQUEUE_QUEUED);
> +       __enqueue_entity(cfs_rq, se);

        if (!rq_h_nr_queued && rq->cfs.h_nr_queued)
                dl_server_start(&rq->fair_server);

So, you say remove all of this curr crap and get everything in one place since the
curr = (cfs_rq->curr == se) returns false all the time? That way we wouldn't need to
worry about the place_entity() parts neither. I'm OK. I'll send the v3 today or tommorow
latest.




  reply	other threads:[~2026-09-11 14:08 UTC|newest]

Thread overview: 15+ 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 [this message]
2026-09-11 16:02       ` [PATCH v3] sched/fair: remove dead code on enqueue_task_fair() Kayra Cizmeci

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=20260911140824.1248362-1-kayracizmeci@gmail.com \
    --to=kayracizmeci@gmail.com \
    --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=peterz@infradead.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

all inboxes | Powered by JetHome®