mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: mingo@kernel.org, juri.lelli@redhat.com,
	dietmar.eggemann@arm.com, rostedt@goodmis.org,
	bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
	kprateek.nayak@amd.com, tj@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] sched/fair: Rework/fix task_h_load()
Date: Mon, 31 Aug 2026 12:37:35 +0200	[thread overview]
Message-ID: <20260831103735.GW687043@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAKfTPtBuCgKjj_kM8zwihp7o10vBB7c9rmBtsJ5mVt3YxjXV0g@mail.gmail.com>

On Mon, Aug 31, 2026 at 12:10:42PM +0200, Vincent Guittot wrote:
> > +static inline void __update_cfs_rq_h_load(struct cfs_rq *cfs_rq,
> > +                                         struct sched_entity *se,
> > +                                         struct cfs_rq *p_cfs_rq)
> > +{
> > +       unsigned long load = cfs_rq->avg.load_avg;
> > +
> > +       if (cfs_rq != &cfs_rq->rq->cfs) {
> 
> A comment explaining that the 2 belows are used for the case where
> for_each_sched_entity has not been called to set backlink would be
> helpful

Fair enough; something like so?

		/*
		 * These last two arguments can be NULL then used outside of
		 * the for_each_sched_entity() hierarchy iteration. Like in
		 * __update_blocked_fair() where leaf_cfs_rq_list is iterated
		 * instead.
		 */

> > +               if (!se)
> > +                       se = &container_of(cfs_rq, struct cfs_tg_state, cfs_rq)->se;
> > +               if (!p_cfs_rq)
> > +                       p_cfs_rq = cfs_rq_of(se);
> > +
> > +               load = p_cfs_rq->h_load;
> > +               load = div64_ul(load * se->avg.load_avg,
> > +                               p_cfs_rq->avg.load_avg + 1);
> > +       }
> > +
> > +       WRITE_ONCE(cfs_rq->h_load, load);
> > +}
> > +
> > +static inline bool update_cfs_rq_h_load(struct cfs_rq *cfs_rq,
> > +                                       struct sched_entity *se,
> > +                                       struct cfs_rq *p_cfs_rq)
> > +{
> > +       /*
> > +        * Mask out the segment bits, if the remaining bits match, then there
> > +        * hasn't been a decay since the last time.
> > +        */
> > +       if ((cfs_rq->last_h_load_update & ~PELT_SEGMENT_MASK) ==
> > +           (cfs_rq->avg.last_update_time & ~PELT_SEGMENT_MASK))
> > +               return false;
> > +
> > +       __update_cfs_rq_h_load(cfs_rq, se, p_cfs_rq);
> > +
> > +       cfs_rq->last_h_load_update = cfs_rq->avg.last_update_time;
> > +       return true;
> > +}

  reply	other threads:[~2026-08-31 10:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28  7:40 [PATCH 0/4] sched/fair: Rework tash_h_load() Peter Zijlstra
2026-08-28  7:41 ` [PATCH 1/4] sched: Rename/clarify sched_class::task_tick(.queued) argument Peter Zijlstra
2026-08-28  7:41 ` [PATCH 2/4] sched/fair: Fold cfs_rq_of(se) into for_each_sched_entity() Peter Zijlstra
2026-08-28  7:41 ` [PATCH 3/4] sched/fair: Extend for_each_sched_entity() with a back-link Peter Zijlstra
2026-08-28  7:41 ` [PATCH 4/4] sched/fair: Rework/fix task_h_load() Peter Zijlstra
2026-08-31 10:10   ` Vincent Guittot
2026-08-31 10:37     ` Peter Zijlstra [this message]
2026-08-31 12:06       ` Vincent Guittot
2026-08-31 13:07         ` Peter Zijlstra
2026-09-02  5:26   ` Chen Yu
2026-09-02  7:55     ` Vincent Guittot
2026-09-02  8:13       ` Peter Zijlstra
2026-09-02 10:36         ` Peter Zijlstra
2026-09-02 10:39           ` Vincent Guittot
2026-09-02 10:37         ` 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=20260831103735.GW687043@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@kernel.org \
    --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®