diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-11-27 08:12:25 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-09 04:03:03 -0500 |
commit | 5afcdab706d6002cb02b567ba46e650215e694e8 (patch) | |
tree | 015c3fb61dc8a4217bc83927efd7882e7d494d2b | |
parent | 970b13bacba14a8cef6f642861947df1d175b0b3 (diff) |
sched: Remove rq->clock coupling from set_task_cpu()
set_task_cpu() should be rq invariant and only touch task state, it
currently fails to do so, which opens up a few races, since not all
callers hold both rq->locks.
Remove the relyance on rq->clock, as any site calling set_task_cpu()
should also do a remote clock update, which should ensure the observed
time between these two cpus is monotonic, as per
kernel/sched_clock.c:sched_clock_remote().
Therefore we can simply remove the clock_offset bits and be happy.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/sched.c | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 01fd131b47a4..1f9c6d99f15d 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -2060,23 +2060,12 @@ task_hot(struct task_struct *p, u64 now, struct sched_domain *sd) | |||
2060 | void set_task_cpu(struct task_struct *p, unsigned int new_cpu) | 2060 | void set_task_cpu(struct task_struct *p, unsigned int new_cpu) |
2061 | { | 2061 | { |
2062 | int old_cpu = task_cpu(p); | 2062 | int old_cpu = task_cpu(p); |
2063 | struct rq *old_rq = cpu_rq(old_cpu), *new_rq = cpu_rq(new_cpu); | 2063 | struct rq *old_rq = cpu_rq(old_cpu); |
2064 | struct cfs_rq *old_cfsrq = task_cfs_rq(p), | 2064 | struct cfs_rq *old_cfsrq = task_cfs_rq(p), |
2065 | *new_cfsrq = cpu_cfs_rq(old_cfsrq, new_cpu); | 2065 | *new_cfsrq = cpu_cfs_rq(old_cfsrq, new_cpu); |
2066 | u64 clock_offset; | ||
2067 | |||
2068 | clock_offset = old_rq->clock - new_rq->clock; | ||
2069 | 2066 | ||
2070 | trace_sched_migrate_task(p, new_cpu); | 2067 | trace_sched_migrate_task(p, new_cpu); |
2071 | 2068 | ||
2072 | #ifdef CONFIG_SCHEDSTATS | ||
2073 | if (p->se.wait_start) | ||
2074 | p->se.wait_start -= clock_offset; | ||
2075 | if (p->se.sleep_start) | ||
2076 | p->se.sleep_start -= clock_offset; | ||
2077 | if (p->se.block_start) | ||
2078 | p->se.block_start -= clock_offset; | ||
2079 | #endif | ||
2080 | if (old_cpu != new_cpu) { | 2069 | if (old_cpu != new_cpu) { |
2081 | p->se.nr_migrations++; | 2070 | p->se.nr_migrations++; |
2082 | #ifdef CONFIG_SCHEDSTATS | 2071 | #ifdef CONFIG_SCHEDSTATS |