Skip to content

Commit f339b9d

Browse files
Peter ZijlstraIngo Molnar
Peter Zijlstra
authored and
Ingo Molnar
committed
sched: Fix schedstat.nr_wakeups_migrate
While looking over the code I found that with the ttwu rework the nr_wakeups_migrate test broke since we now switch cpus prior to calling ttwu_stat(), hence the test is always true. Cure this by passing the migration state in wake_flags. Also move the whole test under CONFIG_SMP, its hard to migrate tasks on UP :-) Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/n/tip-pwwxl7gdqs5676f1d4cx6pj7@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent f01114c commit f339b9d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

include/linux/sched.h

+1
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,7 @@ struct sched_domain;
10631063
*/
10641064
#define WF_SYNC 0x01 /* waker goes to sleep after wakup */
10651065
#define WF_FORK 0x02 /* child wakeup after fork */
1066+
#define WF_MIGRATED 0x04 /* internal use, task got migrated */
10661067

10671068
#define ENQUEUE_WAKEUP 1
10681069
#define ENQUEUE_HEAD 2

kernel/sched.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -2447,6 +2447,10 @@ ttwu_stat(struct task_struct *p, int cpu, int wake_flags)
24472447
}
24482448
rcu_read_unlock();
24492449
}
2450+
2451+
if (wake_flags & WF_MIGRATED)
2452+
schedstat_inc(p, se.statistics.nr_wakeups_migrate);
2453+
24502454
#endif /* CONFIG_SMP */
24512455

24522456
schedstat_inc(rq, ttwu_count);
@@ -2455,9 +2459,6 @@ ttwu_stat(struct task_struct *p, int cpu, int wake_flags)
24552459
if (wake_flags & WF_SYNC)
24562460
schedstat_inc(p, se.statistics.nr_wakeups_sync);
24572461

2458-
if (cpu != task_cpu(p))
2459-
schedstat_inc(p, se.statistics.nr_wakeups_migrate);
2460-
24612462
#endif /* CONFIG_SCHEDSTATS */
24622463
}
24632464

@@ -2675,8 +2676,10 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
26752676
p->sched_class->task_waking(p);
26762677

26772678
cpu = select_task_rq(p, SD_BALANCE_WAKE, wake_flags);
2678-
if (task_cpu(p) != cpu)
2679+
if (task_cpu(p) != cpu) {
2680+
wake_flags |= WF_MIGRATED;
26792681
set_task_cpu(p, cpu);
2682+
}
26802683
#endif /* CONFIG_SMP */
26812684

26822685
ttwu_queue(p, cpu);

0 commit comments

Comments
 (0)