• Marcelo Tosatti's avatar
    [PATCH] x86 bitops.h commentary on instruction reordering · c524e494
    Marcelo Tosatti authored
    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.
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    c524e494
bitops.h 11.7 KB