From: Vlad Poenaru <vlad.wing@gmail.com>
To: Prabhakar <prabhakar.csengg@gmail.com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Chen Yu <yu.c.chen@intel.com>,
Christian Loehle <christian.loehle@arm.com>,
Alexey Charkov <alchark@flipper.net>,
Prabhakar <prabhakar.csengg+renesas@gmail.com>,
linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH] sched/fair: Fix h_nr_runnable leak in dequeue_hierarchy()
Date: Wed, 25 Nov 2026 06:27:29 -0800 [thread overview]
Message-ID: <20261125142729.3161777-1-vlad.wing@gmail.com> (raw)
In-Reply-To: <20261123001213.7609-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
On Mon, Nov 23, 2026 at 12:12:13AM +0000, Prabhakar wrote:
> h_nr_runnable is therefore always 0, so dequeuing a task that is not
> delayed no longer decrements cfs_rq->h_nr_runnable. The count only
> grows, which inflates se->runnable_weight and skews PELT runnable_avg
> and load balancing.
The leak also crashes machines. In Meta's kernel testing, a one-hour
stress-ng soak on 176-CPU x86_64 machines hits a divide error on our
internal kernels based on v7.4-rc4:
Oops: divide error: 0000 [#1] SMP NOPTI
RIP: 0010:update_load_avg+0x267/0x800
Call Trace:
task_tick_fair
hrtick
__hrtimer_run_queues
hrtimer_interrupt
15 of the 16 machines that ran the soak on these kernels crashed this
way, and the 16th left no crash record. None of the soak runs on
v7.4-rc3 based kernels crashed.
The divisor in update_tg_cfs_load() is
scale_load_down(gcfs_rq->load.weight) truncated to u32. That weight was
0xfff8000000000000, so the u32 divisor is 0. Once the leaked count
pushes tg->runnable_avg >> 10 past INT_MAX, tg_tasks() returns a
negative int. calc_concur_shares() then gives clamp_t() a negative
upper bound, and that becomes the group entity weight.
This patch is based on sched/core and does not apply to sched/urgent or
to Linus' tree, where 486c3d06b902 ("sched/fair: Avoid transient double
accounting for delayed tasks") is part of v7.4-rc4. In those trees the
h_nr_runnable line comes before the h_nr_idle line.
I applied the same one-line change by hand to the v7.4-rc4 based kernel
that crashed. One soak run on it then completed all 200 iterations
without a crash.
So I think the fix should go through sched/urgent before v7.4 is released.
Tested-by: Vlad Poenaru <vlad.wing@gmail.com>
next prev parent reply other threads:[~2026-11-25 14:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 0:12 [PATCH] sched/fair: Fix h_nr_runnable leak in dequeue_hierarchy() Prabhakar
2026-11-23 8:06 ` K Prateek Nayak
2026-11-23 8:10 ` Chen Yu
2026-11-23 13:36 ` Christian Loehle
2026-11-23 13:52 ` Alexey Charkov
2026-11-25 14:27 ` Vlad Poenaru [this message]
2026-11-25 14:43 ` Prabhakar Mahadev Lad
2026-11-26 18:15 ` [tip: sched/urgent] " tip-bot2 for Lad Prabhakar
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=20261125142729.3161777-1-vlad.wing@gmail.com \
--to=vlad.wing@gmail.com \
--cc=alchark@flipper.net \
--cc=bsegall@google.com \
--cc=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kernel-team@meta.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=prabhakar.csengg+renesas@gmail.com \
--cc=prabhakar.csengg@gmail.com \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yu.c.chen@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.