From: Peter Zijlstra <peterz@infradead.org>
To: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>,
Doug Smythies <dsmythies@telus.net>,
mingo@kernel.org, juri.lelli@redhat.com,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
linux-kernel@vger.kernel.org, wangtao554@huawei.com,
quzicheng@huawei.com, wuyun.abel@bytedance.com
Subject: Re: [PATCH 0/4] sched: Various reweight_entity() fixes
Date: Thu, 12 Feb 2026 12:59:43 +0100 [thread overview]
Message-ID: <20260212115943.GB1282955@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <58c6c115-f544-4c51-990c-a3ad2fbf701a@amd.com>
On Thu, Feb 12, 2026 at 01:13:30PM +0530, K Prateek Nayak wrote:
> Hello Peter,
>
> On 2/11/2026 9:58 PM, Peter Zijlstra wrote:
> > On Wed, Feb 11, 2026 at 12:15:48PM +0100, Vincent Guittot wrote:
> >
> >> Regarding the use of calc_delta_fair() in update_entity_lag(), we use
> >> calc_delta_fair() for updating vruntime, deadline, vprot and vlag and
> >> I wonder how this diff of granularity compared to avg_vruntime can be
> >> an issue for sched_entity with a small weight
> >
> > It will effectively inflate their weight.
> >
> > The below seems to 'work' -- it builds, boots and builds a kernel.
> >
> > We could perhaps look at doing that reciprocal thing on unsigned long,
> > but meh.
>
> So I was testing peterz:sched/core at commit 84230c0ac1cf ("sched/fair:
> Use full weight to __calc_delta()") and it still crashes for the
> exorbitantly large copies of "yes" running on 6 cores.
Ah yes, our next great adventure :-)
> Here is what I've found out from today's crash on dumping the offending
> cfs_rq:
>
> ...
> Enqueue cfs_rq: depth(1) weight(2144337920) nr_queued(2045) sum_w_vruntime(18343811230990336) sum_weight(2144337920) zero_vruntime(18337852274) sum_shift(0) avg_vruntime(18337852274)
> Dequeue cfs_rq: depth(1) weight(2144337920) nr_queued(2045) sum_w_vruntime(1303379968) sum_weight(2143289344) zero_vruntime(18354971669) sum_shift(0) avg_vruntime(18354971669)
This is about where things go sideways... (see argument below)
> Enqueue cfs_rq: depth(1) weight(2152726528) nr_queued(2053) sum_w_vruntime(-31233567079006208) sum_weight(2152726528) zero_vruntime(18360916028) sum_shift(0) avg_vruntime(18360916028)
> Dequeue cfs_rq: depth(1) weight(2152726528) nr_queued(2053) sum_w_vruntime(-25773095996358656) sum_weight(2151677952) zero_vruntime(18366916795) sum_shift(0) avg_vruntime(18366916795)
> Enqueue cfs_rq: depth(1) weight(2152726528) nr_queued(2053) sum_w_vruntime(-195993505307295744) sum_weight(2152726528) zero_vruntime(18437453448) sum_shift(0) avg_vruntime(18437453448)
> Dequeue cfs_rq: depth(1) weight(2152726528) nr_queued(2053) sum_w_vruntime(-355777007188967424) sum_weight(2151677952) zero_vruntime(18520289238) sum_shift(0) avg_vruntime(18520289238)
> Enqueue cfs_rq: depth(1) weight(2152726528) nr_queued(2053) sum_w_vruntime(-1523774576650092544) sum_weight(2152726528) zero_vruntime(19054245803) sum_shift(0) avg_vruntime(19054245803)
> Dequeue cfs_rq: depth(1) weight(2152726528) nr_queued(2053) sum_w_vruntime(-3015239905359953920) sum_weight(2151677952) zero_vruntime(19756286051) sum_shift(0) avg_vruntime(19756286051)
This is definitely weird; so all these tasks should be more or less
equally spread out around avg_runtime with a +- of that lag bound. This
means that sum_w_vruntime should be in the order of walltime-delta.
To see this; let us remind that:
dt_i
dv_i = ----
w_i
dt
dV = -- ; where: W = \Sum w_i and dt = \Sum dt_i
W
(Virtual) lag is then defined as the difference between V and v_i. In
the fluid model the lag is 0 -- since everybody always advances equally.
In the discrete model this is translated to \Sum lag_i := 0. Anyway, it
can be shown that \Sum vlag_i := 0, is equivalent to:
\Sum w_i * v_i
V = --------------
W
In differential form that gives:
dt_i
\Sum w_i * ----
w_i \Sum dt_i dt
dV = ---------------- = --------- = --
W W W
Now: sum_w_vruntime := dt-dt_curr, sum_weight := W-w_curr
[ one way of looking at it is that sum_w_vruntime + curr->vruntime
carries the remainder of the division, while zero_vruntime carries whe
whole part ]
Anyway, your trace shows both zero_vruntime and avg_vruntime increasing,
this means dt is positive. However, at the same time it shows
sum_w_vruntime being increasingly negative.
The only way this can be is for curr->vruntime to be increasinly
positive such that the sum ends up being a 'small' positive number.
IOW, we're not running the right tasks (and wrecking the lag bounds in
the process).
>
> # I'm suspecting something goes sideways at this point looking at
> # the big jump that comes after in avg_vruntime()
> # "6222537296247259136" has bit 63 set so could it be a wraparound
> # in sum_w_vruntime?
>
> Enqueue cfs_rq: depth(1) weight(2152726528) nr_queued(2053) sum_w_vruntime(6222537296247259136) sum_weight(2152726528) zero_vruntime(24024889432) sum_shift(0) avg_vruntime(24024889432)
> Dequeue cfs_rq: depth(1) weight(2152726528) nr_queued(2053) sum_w_vruntime(-5928597400870453248) sum_weight(2151677952) zero_vruntime(21110281285) sum_shift(0) avg_vruntime(21110281285)
>
> cfs_rq of failed pick:
> cfs_rq: depth(0) weight(2176843776) nr_queued(2076) sum_w_vruntime(-90907067772043264) sum_weight(2175795200) zero_vruntime(26921355273)
> se: weight(1048576) vruntime(843832351) slice(2800000) deadline(846630448) curr?(1) task?(1) delayed?(0) se_depth(1)
> se: weight(1048576) vruntime(839841550) slice(2800000) deadline(842635020) curr?(0) task?(1) delayed?(0) se_depth(1)
> ...
>
> # Many entities have weight 1048576, and and vruntime around ~850,000
>
> ....
> se: weight(1048576) vruntime(843832916) slice(2800000) deadline(846629681) curr?(0) task?(1) delayed?(0) se_depth(1)
> se: weight(1048576) vruntime(843833563) slice(2800000) deadline(846630939) curr?(0) task?(1) delayed?(0) se_depth(1)
> se: weight(1048576) vruntime(843840684) slice(2800000) deadline(846633192) curr?(0) task?(1) delayed?(0) se_depth(1)
> se: weight(1048576) vruntime(18344670326) slice(2800000) deadline(18347465508) curr?(0) task?(1) delayed?(0) se_depth(1)
> se: weight(1048576) vruntime(18344679852) slice(2800000) deadline(18347475866) curr?(0) task?(1) delayed?(0) se_depth(1)
> se: weight(1048576) vruntime(18344682061) slice(2800000) deadline(18347477764) curr?(0) task?(1) delayed?(0) se_depth(1)
> ...
>
> # Many entities have weight 1048576, and and vruntime around ~18,344,682,061
>
>
> I'm running with CONFIG_HZ=250. In vruntime_eligible() we have for curr:
>
> entity_key(curr) = -26077522922LL
> weight = 1048576UL
>
>
> For the cfs_rq we get:
>
> avg = sum_w_runtime + (entity_key * weight) = -118251332447502336LL
> load = sum_weight + weight = 2176843776UL
>
>
> But on the way to check eligibility we compute:
>
> entity_key * load = -56766693466253033472 (in python)
> entity_key * load = -1426461245124378624LL (in C)
>
>
> vruntime_eligible() returns false always as a result of the overflow and
> we land in a pickle. Not sure if sum_w_vruntime itself can suffer from
> a wrap around that leads to all this.
>
> Parsing the stats based on the dump in Python gives me:
>
> Total weight: 2176843776 (checks out)
> Total weighted vruntime: 3145101113938673664
>
> Avg (floating point): 1444798725.849711
> Avg (signed 64-bit): 1444798725
> Avg (unsigned 64-bit): 1444798725
>
> which is a bit far off from the dumped stats of cfs_rq.
So eligibility is lag > 0, or v_i < V. Thus we have:
v_i < V_0 + dt/W
Because divisions are expensive, we've rearranged things:
(v_i - V_0) < dt/W
(v_i - V_0) * W < dt
Now, (v_i - V_0) is entity_key() and we've argued that:
(v_i - V_0) * w_i ~ 44 bits
But now we do * W, which is n*w_i (assuming, as is the case here that
all our tasks of equal weight). Still this would allow n to be of the
order of 20 bits, far larger than the 2k it is.
But yes, if (v_i - V_0) far exceeds the limits imposed by the lag
bounds, this will go sideways.
Let me go puzzle...
For you, slice+TICK_NSEC should be something like: 6800000, and given
everything is weight '1', we would expect vruntime to always be:
avg_vruntime +- 6800000
But that is clearly not happening.
next prev parent reply other threads:[~2026-02-12 12:00 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 9:34 Peter Zijlstra
2026-01-30 9:34 ` [PATCH 1/4] sched/fair: Only set slice protection at pick time Peter Zijlstra
2026-01-30 15:52 ` Vincent Guittot
2026-01-30 9:34 ` [PATCH 2/4] sched/eevdf: Update se->vprot in reweight_entity() Peter Zijlstra
2026-01-30 16:20 ` Vincent Guittot
2026-01-30 9:34 ` [PATCH 3/4] sched/fair: Increase weight bits for avg_vruntime Peter Zijlstra
2026-01-30 9:34 ` [PATCH 4/4] sched/fair: Revert 6d71a9c61604 ("sched/fair: Fix EEVDF entity placement bug causing scheduling lag") Peter Zijlstra
2026-01-31 1:47 ` Zhang Qiao
2026-01-31 15:21 ` Peter Zijlstra
2026-02-02 9:12 ` Peter Zijlstra
2026-02-02 9:24 ` Peter Zijlstra
2026-02-02 11:23 ` Zhang Qiao
2026-02-01 17:13 ` [PATCH 0/4] sched: Various reweight_entity() fixes Doug Smythies
2026-02-03 6:45 ` K Prateek Nayak
2026-02-03 11:11 ` Peter Zijlstra
2026-02-03 12:19 ` K Prateek Nayak
2026-02-03 16:36 ` Doug Smythies
2026-02-10 18:13 ` Peter Zijlstra
2026-02-11 5:51 ` Doug Smythies
2026-02-04 10:15 ` K Prateek Nayak
2026-02-09 15:47 ` Peter Zijlstra
2026-02-09 16:52 ` K Prateek Nayak
2026-02-10 5:16 ` K Prateek Nayak
2026-02-10 10:29 ` Peter Zijlstra
2026-02-10 15:41 ` Doug Smythies
2026-02-10 18:09 ` K Prateek Nayak
2026-02-10 18:35 ` Peter Zijlstra
2026-02-10 20:04 ` K Prateek Nayak
2026-02-11 6:28 ` K Prateek Nayak
2026-02-11 8:50 ` K Prateek Nayak
2026-02-11 23:09 ` Doug Smythies
2026-02-10 18:52 ` Peter Zijlstra
2026-02-10 20:52 ` Vincent Guittot
2026-02-11 5:21 ` Doug Smythies
2026-02-11 8:49 ` Vincent Guittot
2026-02-11 9:01 ` Peter Zijlstra
2026-02-11 10:48 ` Peter Zijlstra
2026-02-11 10:49 ` Peter Zijlstra
2026-02-11 11:15 ` Vincent Guittot
2026-02-11 16:28 ` Peter Zijlstra
2026-02-12 7:43 ` K Prateek Nayak
2026-02-12 11:59 ` Peter Zijlstra [this message]
2026-02-12 17:16 ` Peter Zijlstra
2026-02-12 17:24 ` Vincent Guittot
2026-02-12 19:31 ` Peter Zijlstra
2026-02-13 5:22 ` K Prateek Nayak
2026-02-13 6:44 ` Peter Zijlstra
2026-02-13 10:50 ` Peter Zijlstra
2026-02-13 14:29 ` K Prateek Nayak
2026-02-14 6:31 ` Doug Smythies
2026-02-21 22:51 ` Doug Smythies
2026-02-12 19:29 ` Peter Zijlstra
2026-02-12 19:37 ` Doug Smythies
2026-02-13 6:04 ` K Prateek Nayak
2026-02-11 16:21 ` Peter Zijlstra
2026-02-12 5:54 ` Doug Smythies
2026-02-12 7:51 ` Peter Zijlstra
2026-02-12 15:47 ` Doug Smythies
2026-02-12 7:46 ` Peter Zijlstra
2026-02-11 23:25 ` Doug Smythies
2026-02-11 8:48 ` Peter Zijlstra
2026-02-04 10:44 ` Peter Zijlstra
2026-02-14 7:20 ` Shubhang Kaushik
2026-02-16 3:14 ` K Prateek Nayak
2026-02-16 10:59 ` Dietmar Eggemann
2026-02-17 14:37 ` Dietmar Eggemann
2026-02-17 22:02 ` Shubhang Kaushik
2026-02-17 4:20 ` K Prateek Nayak
2026-02-18 18:37 ` Shubhang Kaushik
2026-02-19 7:53 ` Peter Zijlstra
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=20260212115943.GB1282955@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=dsmythies@telus.net \
--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=quzicheng@huawei.com \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=wangtao554@huawei.com \
--cc=wuyun.abel@bytedance.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®