All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH sched_ext/for-7.4-fixes] sched_ext: Fix partial-SMT core counting in calc_shard_layout()
@ 2026-11-06  2:44 Zhang Qiao
  2026-11-06 18:48 ` Tejun Heo
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang Qiao @ 2026-11-06  2:44 UTC (permalink / raw)
  To: sched-ext, Tejun Heo; +Cc: David Vernet, Andrea Righi, Changwoo Min, Hui Tang

A core is counted when its cpu is the first cpu of
topology_sibling_cpumask(), which includes offline cpus. When the
low-numbered siblings of a core are offline at root-enable time, no
online sibling passes the test and the core is not counted. The
resulting cores_per_shard and nr_large are then too small and the
cores are spread unevenly across shards.

Count a core when its cpu is the first sibling in @llc_cpus, matching
the cores the build loop actually constructs.

Fixes: e2c841b91bf9 ("sched_ext: Add CID sharding")
Signed-off-by: Zhang Qiao <zhangqiao22@huawei.com>
---
 kernel/sched/ext/cid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/ext/cid.c b/kernel/sched/ext/cid.c
index 8e04a8494e11..64572e39c865 100644
--- a/kernel/sched/ext/cid.c
+++ b/kernel/sched/ext/cid.c
@@ -64,7 +64,9 @@ static void calc_shard_layout(const struct cpumask *llc_cpus,
u32 shard_size,
  	for_each_cpu(cpu, llc_cpus) {
 		nr_cpus++;
-		if (cpumask_first(topology_sibling_cpumask(cpu)) == cpu)
+		/* the low-numbered siblings may be offline */
+		if (cpumask_first_and(topology_sibling_cpumask(cpu),
+				      llc_cpus) == cpu)
 			nr_cores++;
 	}
 -- 2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH sched_ext/for-7.4-fixes] sched_ext: Fix partial-SMT core counting in calc_shard_layout()
  2026-11-06  2:44 [PATCH sched_ext/for-7.4-fixes] sched_ext: Fix partial-SMT core counting in calc_shard_layout() Zhang Qiao
@ 2026-11-06 18:48 ` Tejun Heo
  2026-11-10  6:28   ` Zhang Qiao
  0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2026-11-06 18:48 UTC (permalink / raw)
  To: Zhang Qiao; +Cc: sched-ext, David Vernet, Andrea Righi, Changwoo Min, Hui Tang

Hello, Qiao.

On Fri, Nov 06, 2026 at 10:44:30AM +0800, Zhang Qiao wrote:
> A core is counted when its cpu is the first cpu of
> topology_sibling_cpumask(), which includes offline cpus. When the

AFAICS topology_sibling_cpumask() includes offline cpus only on mips and
sparc64. x86, arm64, riscv, powerpc, loongarch and s390 clear an offlined
cpu from its siblings' masks. Which arch did you hit this on?

> +		/* the low-numbered siblings may be offline */
> +		if (cpumask_first_and(topology_sibling_cpumask(cpu),
> +				      llc_cpus) == cpu)

The comment describes one scenario rather than what the test does, which
isn't very useful. Can you state the rule instead? e.g.

  /*
   * scx_cid_init() forms each core from the siblings in
   * @llc_cpus. The sibling mask may include cpus outside
   * @llc_cpus, so count a core at its first sibling in @llc_cpus.
   */

The fix looks right, but the patch is whitespace damaged and doesn't
apply. Can you send v2 with git send-email?

Thanks.

--
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH sched_ext/for-7.4-fixes] sched_ext: Fix partial-SMT core counting in calc_shard_layout()
  2026-11-06 18:48 ` Tejun Heo
@ 2026-11-10  6:28   ` Zhang Qiao
  0 siblings, 0 replies; 3+ messages in thread
From: Zhang Qiao @ 2026-11-10  6:28 UTC (permalink / raw)
  To: Tejun Heo; +Cc: sched-ext, David Vernet, Andrea Righi, Changwoo Min, Hui Tang



在 2026/11/7 2:48, Tejun Heo 写道:
> Hello, Qiao.
> 
> On Fri, Nov 06, 2026 at 10:44:30AM +0800, Zhang Qiao wrote:
>> A core is counted when its cpu is the first cpu of
>> topology_sibling_cpumask(), which includes offline cpus. When the
> 
> AFAICS topology_sibling_cpumask() includes offline cpus only on mips and
> sparc64. x86, arm64, riscv, powerpc, loongarch and s390 clear an offlined
> cpu from its siblings' masks. Which arch did you hit this on?

No, this was based on code inspection. I incorrectly assumed that sibling masks
handle offline CPUs consistently across architectures. MIPS/sparc64 can retain
offlined low-numbered siblings in the masks. Also, on any architecture, siblings
may fall outside @llc_cpus. The count should follow the build loop's actual
logic, so v2 adopts your comment.


> 
>> +		/* the low-numbered siblings may be offline */
>> +		if (cpumask_first_and(topology_sibling_cpumask(cpu),
>> +				      llc_cpus) == cpu)
> 
> The comment describes one scenario rather than what the test does, which
> isn't very useful. Can you state the rule instead? e.g.
> 
>   /*
>    * scx_cid_init() forms each core from the siblings in
>    * @llc_cpus. The sibling mask may include cpus outside
>    * @llc_cpus, so count a core at its first sibling in @llc_cpus.
>    */
> 
> The fix looks right, but the patch is whitespace damaged and doesn't
> apply. Can you send v2 with git send-email?

Sorry about that - v1 got mangled by my mail client. v2 follows via
git send-email.


Thanks.

--
Qiao

> 
> Thanks.
> 
> --
> tejun
> 
> .
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-10  6:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06  2:44 [PATCH sched_ext/for-7.4-fixes] sched_ext: Fix partial-SMT core counting in calc_shard_layout() Zhang Qiao
2026-11-06 18:48 ` Tejun Heo
2026-11-10  6:28   ` Zhang Qiao

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.