mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH] sched/fair: scale wake_wide() threshold by SMT width
@ 2026-04-07  6:39 Zhang Qiao
  2026-04-07 14:38 ` Dietmar Eggemann
  2026-04-07 17:58 ` Shrikanth Hegde
  0 siblings, 2 replies; 10+ messages in thread
From: Zhang Qiao @ 2026-04-07  6:39 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, linux-kernel
  Cc: zhangqiao22, tanghui20

wake_wide() uses sd_llc_size as the spreading threshold to detect wide
waker/wakee relationships and to disable wake_affine() for those cases.

On SMT systems, sd_llc_size counts logical CPUs rather than physical
cores. This inflates the wake_wide() threshold, allowing wake_affine()
to pack more tasks into one LLC domain than the actual compute capacity
of its physical cores can sustain. The resulting SMT interference may
cost more than the cache-locality benefit wake_affine() intends to gain.

Scale the factor by the SMT width of the current CPU so that it
approximates the number of independent physical cores in the LLC domain,
making wake_wide() more likely to kick in before SMT interference
becomes significant. On non-SMT systems the SMT width is 1 and behaviour
is unchanged.

Signed-off-by: Zhang Qiao <zhangqiao22@huawei.com>
---
 kernel/sched/fair.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f07df8987a5ef..4896582c6e904 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7334,6 +7334,11 @@ static int wake_wide(struct task_struct *p)
 	unsigned int slave = p->wakee_flips;
 	int factor = __this_cpu_read(sd_llc_size);
 
+	/* Scale factor to physical-core count to account for SMT interference. */
+	if (sched_smt_active())
+		factor = DIV_ROUND_UP(factor,
+				cpumask_weight(cpu_smt_mask(smp_processor_id())));
+
 	if (master < slave)
 		swap(master, slave);
 	if (slave < factor || master < slave * factor)
-- 
2.18.0


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

end of thread, other threads:[~2026-05-18  7:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-07  6:39 [RFC PATCH] sched/fair: scale wake_wide() threshold by SMT width Zhang Qiao
2026-04-07 14:38 ` Dietmar Eggemann
2026-04-07 18:16   ` Shrikanth Hegde
2026-04-22 13:24     ` Dietmar Eggemann
2026-04-07 17:58 ` Shrikanth Hegde
2026-04-16  7:41   ` Zhang Qiao
2026-04-22 13:26     ` Dietmar Eggemann
2026-04-29  2:43       ` Zhang Qiao
2026-05-11 15:54         ` Dietmar Eggemann
2026-05-18  7:58           ` Zhang Qiao

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®