mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-29 10:01:25 +00:00
bit_spinlock: don't play preemption games inside the busy loop
When we are waiting for the bit-lock to be released, and are looping over the 'cpu_relax()' should not be doing anything else - otherwise we miss the point of trying to do the whole 'cpu_relax()'. Do the preemption enable/disable around the loop, rather than inside of it. Noticed when I was looking at the code generation for the dcache __d_drop usage, and the code just looked very odd. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
5dd12af05c
commit
3dd2ee4824
1 changed files with 4 additions and 4 deletions
|
@ -23,11 +23,11 @@ static inline void bit_spin_lock(int bitnum, unsigned long *addr)
|
||||||
preempt_disable();
|
preempt_disable();
|
||||||
#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
|
#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
|
||||||
while (unlikely(test_and_set_bit_lock(bitnum, addr))) {
|
while (unlikely(test_and_set_bit_lock(bitnum, addr))) {
|
||||||
while (test_bit(bitnum, addr)) {
|
preempt_enable();
|
||||||
preempt_enable();
|
do {
|
||||||
cpu_relax();
|
cpu_relax();
|
||||||
preempt_disable();
|
} while (test_bit(bitnum, addr));
|
||||||
}
|
preempt_disable();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
__acquire(bitlock);
|
__acquire(bitlock);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue