public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] sched/fair: Fix inaccurate tally of ttwu_move_affine
@ 2022-08-10 22:33 Libo Chen
  2022-08-15 11:01 ` Peter Zijlstra
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Libo Chen @ 2022-08-10 22:33 UTC (permalink / raw)
  To: mingo, peterz, vincent.guittot, juri.lelli, dietmar.eggemann,
	mgorman
  Cc: linux-kernel

There are scenarios where non-affine wakeups are incorrectly counted as
affine wakeups by schedstats.

When wake_affine_idle() returns prev_cpu which doesn't equal to
nr_cpumask_bits, it will slip through the check: target == nr_cpumask_bits
in wake_affine() and be counted as if target == this_cpu in schedstats.

Replace target == nr_cpumask_bits with target != this_cpu to make sure
affine wakeups are accurately tallied.

Fixes: 806486c377e33 (sched/fair: Do not migrate if the prev_cpu is idle)
Suggested-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Signed-off-by: Libo Chen <libo.chen@oracle.com>
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index da388657d5ac..b179da4f8105 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6114,7 +6114,7 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p,
 		target = wake_affine_weight(sd, p, this_cpu, prev_cpu, sync);
 
 	schedstat_inc(p->stats.nr_wakeups_affine_attempts);
-	if (target == nr_cpumask_bits)
+	if (target != this_cpu)
 		return prev_cpu;
 
 	schedstat_inc(sd->ttwu_move_affine);
-- 
2.31.1


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

end of thread, other threads:[~2023-04-06 10:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-10 22:33 [PATCH 1/1] sched/fair: Fix inaccurate tally of ttwu_move_affine Libo Chen
2022-08-15 11:01 ` Peter Zijlstra
2022-08-15 19:19   ` Libo Chen
2022-08-17 13:20     ` Vincent Guittot
2023-01-09 22:00     ` Libo Chen
2023-03-09  3:17       ` Libo Chen
2022-08-25  7:30 ` Gautham R. Shenoy
2022-08-25  9:13   ` Libo Chen
2023-03-30 10:39     ` Gautham R. Shenoy
2023-04-06 10:05 ` [tip: sched/core] " tip-bot2 for Libo Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox