summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLibo Chen <libo.chen@oracle.com>2022-08-10 15:33:13 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-05-11 23:00:34 +0900
commit3e09b68fc520a60cc634428d93e42cee4f00513c (patch)
tree610e9c71d4052cf278ebc13b9edc2129358f0891 /kernel
parentc3b9f95598b8029b7e8d9a6b3ad14280e712c70c (diff)
downloadlinux-stable-3e09b68fc520a60cc634428d93e42cee4f00513c.tar.gz
linux-stable-3e09b68fc520a60cc634428d93e42cee4f00513c.tar.bz2
linux-stable-3e09b68fc520a60cc634428d93e42cee4f00513c.zip
sched/fair: Fix inaccurate tally of ttwu_move_affine
[ Upstream commit 39afe5d6fc59237ff7738bf3ede5a8856822d59d ] 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> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Link: https://lore.kernel.org/r/20220810223313.386614-1-libo.chen@oracle.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched/fair.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2dd67e212f0a..646a6ae4b250 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6207,7 +6207,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);