sched_ext: Fix partial-SMT core counting in calc_shard_layout()
Subsystems (2)
PATCH v2 1/1 sched_ext: Fix partial-SMT core counting in calc_shard_layout()
calc_shard_layout() counts the cores of an LLC to spread them evenly across shards. A core is counted when its cpu is the first cpu of topology_sibling_cpumask(), but the cores scx_cid_init() builds are the siblings intersected with @llc_cpus.
The sibling mask may contain cpus outside @llc_cpus - siblings which landed in another node or LLC unit, or offlined siblings on archs that keep them in the mask (mips, sparc64). A core whose first sibling is such a cpu is never counted, so cores_per_shard and nr_large come out too small and the shards end up uneven.
Count a core at its first sibling in @llc_cpus, matching the cores the build loop constructs.
--- kernel/sched/ext/cid.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/sched/ext/cid.c +7 -1
@@ -64,7 +64,13 @@ 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) +/* +* 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. +*/ +if (cpumask_first_and (topology_sibling_cpumask (cpu), + llc_cpus) == cpu) nr_cores++; }
Signature · 1 line
2.43.0
Applied to sched_ext/for-7.4-fixes.
Thanks.
--
tejun