Re: [PATCH] splice : two smp_mb() can be omitted

From: Jens Axboe
Date: Tue Oct 31 2006 - 04:48:15 EST


On Tue, Oct 31 2006, Nick Piggin wrote:
> Eric Dumazet wrote:
> >This patch deletes two calls to smp_mb() that were done after
> >mutex_unlock() that contains an implicit memory barrier.
>
> Uh, there is nothing that says mutex_unlock or any unlock
> functions contain an implicit smp_mb(). What is given is that the
> lock and unlock obey aquire and release memory ordering,
> respectively.
>
> a = x;
> xxx_unlock
> b = y;
>
> In this situation, the load of y can be executed before that of x.
> And some architectures will even do so (i386 can, because the
> unlock is an unprefixed store; ia64 can, because it uses a release
> barrier in the unlock).
>
> Whenever you rely on orderings of things *outside* locks (even
> partially outside), you do need to be very careful about barriers
> and can't rely on locks to do the right thing for you.

Good point, we should not make any assumptions on the way the
architecture implements the mutexes.

--
Jens Axboe

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/