public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* Fix unlock_buffer() to work the same way as bit_unlock()
@ 2006-03-28  3:59 Christoph Lameter
  2006-03-28  8:10 ` Nick Piggin
                   ` (14 more replies)
  0 siblings, 15 replies; 38+ messages in thread
From: Christoph Lameter @ 2006-03-28  3:59 UTC (permalink / raw)
  To: akpm; +Cc: nickpiggin, Zoltan.Menyhart, linux-kernel, linux-ia64

Currently unlock_buffer() contains a smb_mb__after_clear_bit() which is 
weird because bit_spin_unlock() uses smb_mb__before_clear_bit():

From include/linux/bit_spinlock.h:

static inline void bit_spin_unlock(int bitnum, unsigned long *addr)
{
        smp_mb__before_clear_bit();
        clear_bit(bitnum, addr);
        preempt_enable();
        __release(bitlock);
}

For most architectures there is no difference because both
smp_mb__after_clear_bit() and smp_mb__before_clear_bit() are both
memory barriers and clear_buffer_locked() is an atomic operation.
However, they differ under IA64.

Note that this potential race has never been seen under IA64. It was 
discovered by inspection by Zoltan Menyhart <Zoltan.Menyhart@free.fr>. 

Regardless if this is a true race or not, I think the unlock sequence 
needs to be the same for bit locks and unlock_buffer(). Maybe 
unlock_buffer and lock_buffer better use bit spinlock operations?

Change unlock_buffer() to work the same way as bit_spin_unlock.

Signed-off-by: Christoph Lameter <clameter@sgi.com>

Index: linux-2.6/fs/buffer.c
=================================--- linux-2.6.orig/fs/buffer.c	2006-03-27 14:09:54.000000000 -0800
+++ linux-2.6/fs/buffer.c	2006-03-27 19:40:32.000000000 -0800
@@ -78,8 +78,8 @@ EXPORT_SYMBOL(__lock_buffer);
 
 void fastcall unlock_buffer(struct buffer_head *bh)
 {
+	smp_mb__before_clear_bit();
 	clear_buffer_locked(bh);
-	smp_mb__after_clear_bit();
 	wake_up_bit(&bh->b_state, BH_Lock);
 }
 

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2006-03-30 22:26 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-28  3:59 Fix unlock_buffer() to work the same way as bit_unlock() Christoph Lameter
2006-03-28  8:10 ` Nick Piggin
2006-03-28 18:53 ` Chen, Kenneth W
2006-03-28 21:42   ` Zoltan Menyhart
2006-03-28 23:48     ` Christoph Lameter
2006-03-29  0:07       ` Nick Piggin
2006-03-29  2:23         ` Christoph Lameter
2006-03-29  2:35           ` Nick Piggin
2006-03-29 10:57       ` Zoltan Menyhart
2006-03-29  0:12 ` Chen, Kenneth W
2006-03-29  0:27 ` Chen, Kenneth W
2006-03-29  0:47   ` Christoph Lameter
2006-03-29  1:39 ` Chen, Kenneth W
2006-03-29 12:16   ` Zoltan Menyhart
2006-03-30  1:56     ` Nick Piggin
2006-03-29  6:46 ` Chen, Kenneth W
2006-03-29  7:11   ` Christoph Lameter
2006-03-30  1:34   ` Nick Piggin
2006-03-29  6:50 ` Chen, Kenneth W
2006-03-30  1:36   ` Nick Piggin
2006-03-29 18:33 ` Boehm, Hans
2006-03-29 19:11   ` Grant Grundler
2006-03-29 19:31 ` Boehm, Hans
2006-03-29 22:17   ` Christoph Lameter
2006-03-29 22:56 ` Boehm, Hans
2006-03-29 23:33   ` Christoph Lameter
2006-03-30  8:43     ` Zoltan Menyhart
2006-03-30  8:55       ` Nick Piggin
2006-03-30 19:11         ` Christoph Lameter
2006-03-30 17:17       ` Christoph Lameter
2006-03-29 23:49 ` Chen, Kenneth W
2006-03-29 23:50   ` Christoph Lameter
2006-03-29 23:50   ` Grant Grundler
     [not found] ` <442AA13B.3050104@bull.net>
2006-03-30  1:57   ` Nick Piggin
2006-03-30 17:57 ` Boehm, Hans
2006-03-30 18:17   ` Christoph Lameter
2006-03-30 22:17 ` Boehm, Hans
2006-03-30 22:26 ` Boehm, Hans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox