From: Rik van Riel <riel@surriel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Chris Mason <clm@meta.com>, Pat Cody <pat@patcody.io>,
mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, linux-kernel@vger.kernel.org,
patcody@meta.com, kernel-team@meta.com,
Breno Leitao <leitao@debian.org>
Subject: Re: [PATCH] sched/fair: Add null pointer check to pick_next_entity()
Date: Mon, 14 Apr 2025 15:57:42 -0400 [thread overview]
Message-ID: <b378f48593ca7449257a1bb55e78b186d88cd9f1.camel@surriel.com> (raw)
In-Reply-To: <20250402082221.GT5880@noisy.programming.kicks-ass.net>
On Wed, 2025-04-02 at 10:22 +0200, Peter Zijlstra wrote:
>
> Please confirm what the reason for overflow is.
>
Running a large enough sample size has its benefits.
We have hit 3 out of the 4 warnings below.
The only one we did not hit is the cfs_rq->avg_load != avg_load
warning.
Most of the time we seem to hit the warnings from the
code that removes tasks from the runqueue, but we are
occasionally seeing it when adding tasks to the runqueue,
as well.
> +++ b/kernel/sched/fair.c
> @@ -620,12 +620,36 @@ static inline s64 entity_key(struct cfs_
> *
> * As measured, the max (key * weight) value was ~44 bits for a
> kernel build.
> */
> +
> +static void avg_vruntime_validate(struct cfs_rq *cfs_rq)
> +{
> + unsigned long load = 0;
> + s64 vruntime = 0;
> +
> + for (struct rb_node *node = rb_first_cached(&cfs_rq-
> >tasks_timeline);
> + node; node = rb_next(node)) {
> + struct sched_entity *se = __node_2_se(node);
> + unsigned long weight = scale_load_down(se-
> >load.weight);
> + s64 key = entity_key(cfs_rq, se);
> + /* vruntime += key * weight; */
> + WARN_ON_ONCE(__builtin_mul_overflow(key, weight,
> &key));
> + WARN_ON_ONCE(__builtin_add_overflow(vruntime, key,
> &vruntime));
> + load += weight;
> + }
> +
> + WARN_ON_ONCE(cfs_rq->avg_load != load);
> + WARN_ON_ONCE(cfs_rq->avg_vruntime != vruntime);
> +}
> +
> static void
> avg_vruntime_add(struct cfs_rq *cfs_rq, struct sched_entity *se)
> {
> unsigned long weight = scale_load_down(se->load.weight);
> s64 key = entity_key(cfs_rq, se);
>
> + /* not yet added to tree */
> + avg_vruntime_validate(cfs_rq);
> +
> cfs_rq->avg_vruntime += key * weight;
> cfs_rq->avg_load += weight;
> }
> @@ -638,6 +662,9 @@ avg_vruntime_sub(struct cfs_rq *cfs_rq,
>
> cfs_rq->avg_vruntime -= key * weight;
> cfs_rq->avg_load -= weight;
> +
> + /* already removed from tree */
> + avg_vruntime_validate(cfs_rq);
> }
>
> static inline
>
--
All Rights Reversed.
next prev parent reply other threads:[~2025-04-14 19:59 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 20:53 Pat Cody
2025-03-20 22:42 ` Christian Loehle
2025-03-21 17:52 ` Pat Cody
2025-03-24 11:56 ` Peter Zijlstra
2025-03-25 15:12 ` Pat Cody
2025-03-25 18:59 ` Peter Zijlstra
2025-03-26 19:26 ` Pat Cody
2025-04-02 14:59 ` Rik van Riel
2025-04-02 18:07 ` Peter Zijlstra
2025-04-09 14:29 ` Rik van Riel
2025-04-09 15:27 ` Peter Zijlstra
2025-04-11 14:51 ` Rik van Riel
2025-04-14 9:08 ` Peter Zijlstra
2025-04-14 15:38 ` Chris Mason
2025-04-15 10:07 ` Peter Zijlstra
2025-04-16 7:59 ` Peter Zijlstra
[not found] ` <7B2CFC16-1ADE-4565-B555-7525A50494C2@surriel.com>
[not found] ` <20250402082221.GT5880@noisy.programming.kicks-ass.net>
2025-04-14 19:57 ` Rik van Riel [this message]
2025-04-15 8:02 ` Peter Zijlstra
2025-04-16 12:44 ` Peter Zijlstra
2025-04-16 14:19 ` Rik van Riel
2025-04-16 15:27 ` Chris Mason
2025-04-18 15:44 ` Peter Zijlstra
2025-04-18 23:49 ` Omar Sandoval
2025-04-22 0:06 ` Omar Sandoval
2025-04-22 14:13 ` Peter Zijlstra
2025-04-22 15:14 ` Peter Zijlstra
2025-04-25 8:53 ` Omar Sandoval
2025-04-22 13:36 ` Peter Zijlstra
2025-04-19 2:53 ` Mike Galbraith
[not found] <20250320173438.3562449-2-patcody@meta.com>
2025-03-24 15:56 ` Steven Rostedt
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=b378f48593ca7449257a1bb55e78b186d88cd9f1.camel@surriel.com \
--to=riel@surriel.com \
--cc=bsegall@google.com \
--cc=clm@meta.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kernel-team@meta.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=pat@patcody.io \
--cc=patcody@meta.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®