From: sashiko-bot@kernel.org
To: "K Prateek Nayak" <kprateek.nayak@amd.com>
Cc: "Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
linux-s390@vger.kernel.org,
"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [RFC PATCH v3 13/13] sched/fair: Switch nohz.idle_cpus to use sbm
Date: Fri, 02 Oct 2026 09:13:32 +0000 [thread overview]
Message-ID: <20261002091333.555F61F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261001192849.74788-14-kprateek.nayak@amd.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] sched/fair: _nohz_idle_balance() aborts during CPU hotplug
- [Medium] sched/fair: NOHZ blocked load decay broken for NO_HZ_FULL CPUs
- [Medium] sched/fair: silent deletion of ASYM_PACKING idle balance kick
- [Low] sched/fair: missing atomic operation before smp_mb__after_atomic()
--
commit 0b0c43c6e4d9b31b812d8407b146c5dc13783dc8
Author: Peter Zijlstra <peterz@infradead.org>
sched/fair: Switch nohz.idle_cpus to use sbm
With sbm infrastructure in place, convert the global nohz.idle_cpus cpumask
to use sparsebitmap (sbm).
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index a0a659f4c3be6..0b1458c4360e3 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -14186,24 +14186,6 @@ static void nohz_balancer_kick(struct rq *rq)
> }
> }
>
> - sd = rcu_dereference_all(per_cpu(sd_asym_packing, cpu));
> - if (sd) {
> - /*
> - * When ASYM_PACKING; see if there's a more preferred CPU
> - * currently idle; in which case, kick the ILB to move tasks
> - * around.
> - *
> - * When balancing between cores, all the SMT siblings of the
> - * preferred CPU must be idle.
> - */
> - for_each_cpu_and(i, sched_domain_span(sd), nohz.idle_cpus_mask) {
> - if (sched_asym(sd, i, cpu)) {
> - flags |= NOHZ_STATS_KICK | NOHZ_BALANCE_KICK;
> - goto out;
> - }
> - }
> - }
> -
[Severity: Medium]
Was it intentional to completely remove the ASYM_PACKING handling block here
without a replacement?
This appears to mean tasks will no longer be proactively migrated to favored
cores during NOHZ idle load balancing on asymmetric capacity systems.
> sd = rcu_dereference_all(per_cpu(sd_asym_cpucapacity, cpu));
> if (sd) {
> /*
[ ... ]
> @@ -14324,7 +14307,8 @@ void nohz_balance_enter_idle(int cpu)
>
> rq->nohz_tick_stopped = 1;
>
> - cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
> + if (cpumask_test_cpu(rq->cpu, housekeeping_cpumask(HK_TYPE_KERNEL_NOISE)))
> + sbm_cpu_set(nohz.sbm, rq->cpu);
>
> /*
> * Ensures that if nohz_idle_balance() fails to observe our
> * @idle_cpus_mask store, it must observe the @has_blocked_load
> * and @needs_update stores.
> */
> smp_mb__after_atomic();
[Severity: Low]
Does this conditional atomic operation violate the smp_mb__after_atomic() API
contract when the CPU is not in the housekeeping mask?
If a CPU is not in the housekeeping mask, sbm_cpu_set() is skipped. The
subsequent smp_mb__after_atomic() then executes without a preceding atomic
operation, which may fail to provide hardware memory ordering on architectures
where it is just a compiler barrier.
[ ... ]
> @@ -14351,7 +14335,7 @@ static bool update_nohz_stats(struct rq *rq)
> if (!rq->has_blocked_load)
> return false;
>
> - if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
> + if (!sbm_cpu_test(nohz.sbm, cpu))
> return false;
[Severity: Medium]
Will this prevent NO_HZ_FULL CPUs from ever decaying their blocked load when
idle?
When an isolated CPU enters idle, it is excluded from nohz.sbm due to the
housekeeping_cpumask() check in nohz_balance_enter_idle(). Consequently,
update_nohz_stats() entirely skips it because it checks sbm_cpu_test(), which
could lead to stale load averages and incorrect scheduling decisions for those
CPUs.
>
> if (!time_after(jiffies, READ_ONCE(rq->last_blocked_load_update_tick)))
[ ... ]
> @@ -14405,7 +14390,10 @@ static void _nohz_idle_balance(struct rq *this_rq, unsigned int flags)
> * Start with the next CPU after this_cpu so we will end with this_cpu and let a
> * chance for other idle cpu to pull load.
> */
> - for_each_cpu_wrap(balance_cpu, nohz.idle_cpus_mask, this_cpu+1) {
> + start = sbm_cpu_to_idx(cpumask_next_wrap(this_cpu, cpu_online_mask));
> + sbm_for_each_set_bit_wrap(nohz.sbm, idx, start) {
> + balance_cpu = sbm_idx_to_cpu(idx);
> +
[Severity: High]
Can this iteration abort entirely during CPU hotplug?
_nohz_idle_balance() uses cpumask_next_wrap() on cpu_online_mask. During CPU
teardown, sched_cpu_deactivate() calls free_sbm_index(cpu) which sets the CPU's
SBM index to -1, but the CPU remains in cpu_online_mask until later in the
teardown process.
If the ILB samples this offlining CPU, sbm_cpu_to_idx() returns -1, which is
passed as `start` to sbm_for_each_set_bit_wrap().
Since sbm_find_next_bit_wrap() returns -1 when start is -1:
include/linux/sbm.h:sbm_find_next_bit_wrap() {
...
bit = sbm_find_next_bit(sbm, 0);
return bit < start ? bit : -1;
}
won't this cause the loop to terminate immediately without balancing any CPUs?
> if (!idle_cpu(balance_cpu))
> continue;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261001192849.74788-1-kprateek.nayak@amd.com?part=13
next prev parent reply other threads:[~2026-10-02 9:13 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 19:28 [RFC PATCH v3 00/13] lib, sched: Introduce sparsebitmap (sbm) K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 01/13] lib/sbm: Introduce helpers for architectures to configure LLC properties K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-07 5:43 ` Shrikanth Hegde
2026-10-01 19:28 ` [RFC PATCH v3 02/13] drivers/base/arch_topology: Add support for initializing sbm topology K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-01 19:28 ` [RFC PATCH v3 03/13] LoongArch: Initialize CPU _PXM relation for disabled CPUs from SRAT K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-01 19:28 ` [RFC PATCH v3 04/13] LoongArch: Configure sbm topology during SMP preparation K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-07 3:51 ` [RFC PATCH v3.1 " K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 05/13] MIPS: Initialize sbm topology on multi-node systems K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-01 19:28 ` [RFC PATCH v3 06/13] powerpc/setup: Initialize sbm topology based on coregroup / NUMA topology K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-07 14:43 ` Shrikanth Hegde
2026-10-01 19:28 ` [RFC PATCH v3 07/13] s390/topology: Initialize sbm topology during topology_init_early() K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-07 10:19 ` Mete Durlu
2026-10-01 19:28 ` [RFC PATCH v3 08/13] sparc64: Initialize sbm topology on multi-LLC system K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-01 19:28 ` [RFC PATCH v3 09/13] x86/cpu/topology: Initialize sbm topology after topology parsing K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-03 8:27 ` Chen Yu
2026-10-04 6:17 ` K Prateek Nayak
2026-10-07 3:52 ` [RFC PATCH v3.1 " K Prateek Nayak
2026-10-01 19:28 ` [RFC PATCH v3 10/13] lib/sbm: Dynamically allocate sbm index when CPU is activated K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-01 19:28 ` [RFC PATCH v3 11/13] lib/sbm: Add helpers to allocate, set, clear, and traverse the bits on sbm K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-01 19:28 ` [RFC PATCH v3 12/13] sched/fair: Allocate nohz.idle_cpus_mask during sched_init_smp() K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot
2026-10-01 19:28 ` [RFC PATCH v3 13/13] sched/fair: Switch nohz.idle_cpus to use sbm K Prateek Nayak
2026-10-02 9:13 ` sashiko-bot [this message]
2026-10-03 9:10 ` [RFC PATCH v3 00/13] lib, sched: Introduce sparsebitmap (sbm) Chen Yu
2026-10-04 6:13 ` K Prateek Nayak
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=20261002091333.555F61F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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