From: Peter Zijlstra <peterz@infradead.org>
To: Omar Sandoval <osandov@osandov.com>
Cc: Rik van Riel <riel@surriel.com>, 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: Tue, 22 Apr 2025 15:36:20 +0200 [thread overview]
Message-ID: <20250422133620.GF14170@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <aALk9DVfjTTHGdvA@telecaster>
On Fri, Apr 18, 2025 at 04:49:08PM -0700, Omar Sandoval wrote:
> On Fri, Apr 18, 2025 at 05:44:38PM +0200, Peter Zijlstra wrote:
> > @@ -850,6 +811,7 @@ RB_DECLARE_CALLBACKS(static, min_vruntim
> > static void __enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
> > {
> > avg_vruntime_add(cfs_rq, se);
> > + update_zero_vruntime(cfs_rq);
>
> Won't this double-count cfs_rq->curr in the avg_vruntime() calculation
> in update_zero_vruntime()? When cfs_rq->curr->on_rq, put_prev_entity()
> calls this with se == cfs_rq->curr _before_ setting cfs_rq->curr to
> NULL.
Yep, right you are. I note that set_next_entity() sets cfs_rq->curr
late, and does not have this issue. I'll look at making
put_prev_entity() clear cfs_rq->curr early.
(obviously I'll have to check all that it does after is not using curr)
> So the avg_vruntime_add() call will add entity_key(cfs_rq->curr)
> to cfs_rq->avg_vruntime and se_weight(cfs_rq->curr) to cfs_rq->avg_load.
> Then update_zero_vruntime() calls avg_vruntime(), which still sees
> curr->on_rq and will add curr's key and weight again. This throws
> zero_vruntime off, maybe by enough to bust zero_vruntime and/or
> avg_vruntime?
>
> Should the call to update_zero_vruntime() go before avg_vruntime_add()?
The thing is that adding/removing from the tree makes avg_vruntime jump
around a bit, and I wanted to adjust for that jump (in the lazy way).
So it needs to be after enqueue/dequeue.
Meanwhile, I've done a custom module that does:
preempt_disable();
/* 'spin' for a minute */
for (int i = 0; i < 60*1000; i++)
__ndelay(1000000);
preempt_enable();
just to emulate some ridiculous PREEMPT_NONE kernel section, and while
it trips RCU and Soft Lockup watchdogs, it does not seem to trip any of
the __builtin_overflow bits, even when ran at nice 19.
(this was with the zero_vruntime thing on, I've yet to try with the
upstream min_vruntime thing)
So unless you've disabled those watchdogs (or pushed their limits up),
I'm fairly confident that there's no overflow to be had, even with that
curr issue.
next prev parent reply other threads:[~2025-04-22 13:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 20:53 [PATCH] sched/fair: Add null pointer check to pick_next_entity() 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
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 [this message]
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=20250422133620.GF14170@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--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=osandov@osandov.com \
--cc=pat@patcody.io \
--cc=patcody@meta.com \
--cc=riel@surriel.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