Commit 152f9d07 authored by Eric Dumazet's avatar Eric Dumazet Committed by Ingo Molnar

sched_clock: Fix atomicity/continuity bug by using cmpxchg64()

Commit def0a9b2 (sched_clock: Make it NMI safe) assumed
cmpxchg() of 64bit values was available on X86_32.

That is not so - and causes some subtle scheduler misbehavior due
to incorrect timestamps off to up by ~4 seconds.

Two symptoms are known right now:

 - interactivity problems seen by Arjan: up to 600 msecs
   latencies instead of the expected 20-40 msecs. These
   latencies are very visible on the desktop.

 - incorrect CPU stats: occasionally too high percentages in 'top',
   and crazy CPU usage stats.
Reported-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarArjan van de Ven <arjan@linux.intel.com>
Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Cc: John Stultz <johnstul@us.ibm.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20090930170754.0886ff2e@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 79e1dd05
...@@ -127,7 +127,7 @@ static u64 sched_clock_local(struct sched_clock_data *scd) ...@@ -127,7 +127,7 @@ static u64 sched_clock_local(struct sched_clock_data *scd)
clock = wrap_max(clock, min_clock); clock = wrap_max(clock, min_clock);
clock = wrap_min(clock, max_clock); clock = wrap_min(clock, max_clock);
if (cmpxchg(&scd->clock, old_clock, clock) != old_clock) if (cmpxchg64(&scd->clock, old_clock, clock) != old_clock)
goto again; goto again;
return clock; return clock;
...@@ -163,7 +163,7 @@ static u64 sched_clock_remote(struct sched_clock_data *scd) ...@@ -163,7 +163,7 @@ static u64 sched_clock_remote(struct sched_clock_data *scd)
val = remote_clock; val = remote_clock;
} }
if (cmpxchg(ptr, old_val, val) != old_val) if (cmpxchg64(ptr, old_val, val) != old_val)
goto again; goto again;
return val; return val;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment