Skip to content

Commit 39afe5d

Browse files
Libo ChenPeter Zijlstra
authored andcommitted
sched/fair: Fix inaccurate tally of ttwu_move_affine
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: 806486c (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
1 parent 05bfb33 commit 39afe5d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/sched/fair.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6582,7 +6582,7 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p,
65826582
target = wake_affine_weight(sd, p, this_cpu, prev_cpu, sync);
65836583

65846584
schedstat_inc(p->stats.nr_wakeups_affine_attempts);
6585-
if (target == nr_cpumask_bits)
6585+
if (target != this_cpu)
65866586
return prev_cpu;
65876587

65886588
schedstat_inc(sd->ttwu_move_affine);

0 commit comments

Comments
 (0)