diff options
author | Andrew Morton <akpm@linux-foundation.org> | 2009-09-19 14:55:44 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-09-20 14:00:32 -0400 |
commit | 89f19f04dc72363d912fd007a399cb10310eff6e (patch) | |
tree | daa64e5de98a668eed4a2ceeb6ca95c478be4053 /kernel/sched.c | |
parent | 3f04e8cd5b24727a2500f8ab8f3de730ba47b02c (diff) |
sched: Fix raciness in runqueue_is_locked()
runqueue_is_locked() is unavoidably racy due to a poor interface design.
It does
cpu = get_cpu()
ret = some_perpcu_thing(cpu);
put_cpu(cpu);
return ret;
Its return value is unreliable.
Fix.
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <200909191855.n8JItiko022148@imap1.linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r-- | kernel/sched.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index faf4d463bbff..575fb0139038 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -681,15 +681,9 @@ inline void update_rq_clock(struct rq *rq) | |||
681 | * This interface allows printk to be called with the runqueue lock | 681 | * This interface allows printk to be called with the runqueue lock |
682 | * held and know whether or not it is OK to wake up the klogd. | 682 | * held and know whether or not it is OK to wake up the klogd. |
683 | */ | 683 | */ |
684 | int runqueue_is_locked(void) | 684 | int runqueue_is_locked(int cpu) |
685 | { | 685 | { |
686 | int cpu = get_cpu(); | 686 | return spin_is_locked(&cpu_rq(cpu)->lock); |
687 | struct rq *rq = cpu_rq(cpu); | ||
688 | int ret; | ||
689 | |||
690 | ret = spin_is_locked(&rq->lock); | ||
691 | put_cpu(); | ||
692 | return ret; | ||
693 | } | 687 | } |
694 | 688 | ||
695 | /* | 689 | /* |