[lkml]   [2007]   [Jul]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[PATCH 7/8] i386: bitops: Kill needless usage of __asm__ __volatile__
    From: Satyam Sharma <>

    [7/8] i386: bitops: Kill needless usage of __asm__ __volatile__

    Another oddity I noticed in this file. The semantics of __volatile__
    when used to qualify inline __asm__ are that the compiler will not
    (1) elid, or, (2) reorder, or, (3) intersperse, our inline asm with
    the rest of the generated code.

    However, we do not want these guarantees in the unlocked variants of the
    bitops functions. Also, note that test_bit() is *always* an unlocked
    operation on i386 -- the i386 instruction set disallows the use of the LOCK
    prefix with the "btl" instruction anyway, and the CPU will throw an invalid
    opcode exception otherwise. Hence, every caller of variable_test_bit() must
    have all the required locking implemented at a higher-level anyway and this
    operation would necessarily be guarantee-less.

    So let's remove the __volatile__ qualification of the inline asm in the
    variable_test_bit() function also -- and let's give the compiler a chance
    to optimize / combine multiple bitops, if possible.

    Signed-off-by: Satyam Sharma <>
    Cc: David Howells <>
    Cc: Nick Piggin <>


    include/asm-i386/bitops.h | 8 ++++----
    1 files changed, 4 insertions(+), 4 deletions(-)

    diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
    index f37b8a2..4f1fda5 100644
    --- a/include/asm-i386/bitops.h
    +++ b/include/asm-i386/bitops.h
    @@ -96,7 +96,7 @@ static inline void clear_bit(int nr, unsigned long *addr)
    static inline void __clear_bit(int nr, unsigned long *addr)
    - __asm__ __volatile__(
    + __asm__(
    "btrl %1,%0"
    :"=m" (*addr)
    :"r" (nr));
    @@ -123,7 +123,7 @@ static inline void __clear_bit(int nr, unsigned long *addr)
    static inline void __change_bit(int nr, unsigned long *addr)
    - __asm__ __volatile__(
    + __asm__(
    "btcl %1,%0"
    :"=m" (*addr)
    :"r" (nr));
    @@ -251,7 +251,7 @@ static inline int __test_and_change_bit(int nr, unsigned long *addr)
    int oldbit;

    - __asm__ __volatile__(
    + __asm__(
    "btcl %2,%1\n\tsbbl %0,%0"
    :"=r" (oldbit),"=m" (*addr)
    :"r" (nr));
    @@ -297,7 +297,7 @@ static inline int variable_test_bit(int nr, const unsigned long *addr)
    int oldbit;

    - __asm__ __volatile__(
    + __asm__(
    "btl %2,%1\n\tsbbl %0,%0"
    :"=r" (oldbit)
    :"m" (*addr),"r" (nr));
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at
     \ /
      Last update: 2007-07-23 18:09    [W:0.021 / U:48.620 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site