Re: [PATCH] x86 bitops.h commentary on instruction reordering

From: Vladislav Bolkhovitin
Date: Fri Aug 06 2004 - 09:16:01 EST


So, is there any way to workaround this problem, i.e. prevent bit operations reordering on non-x86 architectures? Some kinds of memory barriers?

Vlad

Marcelo Tosatti wrote:
Hi,

Back when we were discussing the need for a memory barrier in sync_page(), it came to me (thanks Andrea!) that the bit operations can be perfectly reordered on architectures other than x86.

I think the commentary on i386 bitops.h is misleading, its worth to note that that these operations are not guaranteed not to be reordered on different architectures.

clear_bit() already does that:

* clear_bit() is atomic and may not be reordered. However, it does
* not contain a memory barrier, so if it is used for locking purposes,
* you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
* in order to ensure changes are visible on other processors.

What you think of the following
-
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/