diff options
author | Bjoern Brandenburg <bbb@swan.cs.unc.edu> | 2007-02-21 16:46:12 -0500 |
---|---|---|
committer | Bjoern Brandenburg <bbb@swan.cs.unc.edu> | 2007-02-21 16:46:12 -0500 |
commit | bf0d1c6734adf03b5f6631bdb431bed827767504 (patch) | |
tree | 0b079ed88bf4ebd6a896c93c35bf85fd619a8581 /include/linux/queuelock.h | |
parent | c5b319e81dc0c5a5a40a4ccfd7f60bc529980d8b (diff) |
small fixes
insert barrier() to be sure order is preserved by inline expansion
don't depend on macro for initialization
Diffstat (limited to 'include/linux/queuelock.h')
-rw-r--r-- | include/linux/queuelock.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/queuelock.h b/include/linux/queuelock.h index d60800d90e..6dac31c358 100644 --- a/include/linux/queuelock.h +++ b/include/linux/queuelock.h | |||
@@ -15,10 +15,8 @@ | |||
15 | * not enforced, but it will not work. | 15 | * not enforced, but it will not work. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/spinlock.h> | ||
19 | #include <linux/cache.h> | 18 | #include <linux/cache.h> |
20 | #include <asm/atomic.h> | 19 | #include <asm/atomic.h> |
21 | #include <linux/cpumask.h> | ||
22 | #include <linux/smp.h> | 20 | #include <linux/smp.h> |
23 | 21 | ||
24 | typedef struct { | 22 | typedef struct { |
@@ -48,7 +46,7 @@ typedef struct { | |||
48 | static inline void queue_lock_init(queuelock_t *lock) | 46 | static inline void queue_lock_init(queuelock_t *lock) |
49 | { | 47 | { |
50 | int i; | 48 | int i; |
51 | for_each_possible_cpu(i) { | 49 | for (i = 0; i < NR_CPUS; i++) { |
52 | lock->slots[i].val = MUST_WAIT; | 50 | lock->slots[i].val = MUST_WAIT; |
53 | lock->spin_slot[i] = i; | 51 | lock->spin_slot[i] = i; |
54 | } | 52 | } |
@@ -76,12 +74,14 @@ static inline void queue_lock(queuelock_t *lock) | |||
76 | while (lock->slots[lock->spin_slot[me]].val == MUST_WAIT); | 74 | while (lock->slots[lock->spin_slot[me]].val == MUST_WAIT); |
77 | /* reset the lock */ | 75 | /* reset the lock */ |
78 | lock->slots[lock->spin_slot[me]].val = MUST_WAIT; | 76 | lock->slots[lock->spin_slot[me]].val = MUST_WAIT; |
77 | barrier(); | ||
79 | } | 78 | } |
80 | 79 | ||
81 | 80 | ||
82 | static inline void queue_unlock(queuelock_t *lock) | 81 | static inline void queue_unlock(queuelock_t *lock) |
83 | { | 82 | { |
84 | int me = smp_processor_id(); | 83 | int me = smp_processor_id(); |
84 | barrier(); | ||
85 | lock->slots[(lock->spin_slot[me] + 1) % NR_CPUS].val = HAS_LOCK; | 85 | lock->slots[(lock->spin_slot[me] + 1) % NR_CPUS].val = HAS_LOCK; |
86 | } | 86 | } |
87 | 87 | ||