asm-generic: add another generic ext2 atomic bitops
Subsystems (11)
PATCH 1/1 asm-generic: add another generic ext2 atomic bitops
The majority of architectures implement ext2 atomic bitops as test_and_{set,clear}_bit() without spinlock.
This adds this type of generic implementation in ext2-atomic.h and use it wherever possible.
--- arch/alpha/include/asm/bitops.h | 4 ++-- arch/arm/include/asm/bitops.h | 6 ++---- arch/cris/include/asm/bitops.h | 4 ++-- arch/frv/include/asm/bitops.h | 4 ++-- arch/ia64/include/asm/bitops.h | 4 ++-- arch/m68k/include/asm/bitops_mm.h | 6 ++---- arch/mn10300/include/asm/bitops.h | 8 ++------ arch/parisc/include/asm/bitops.h | 10 ++-------- arch/powerpc/include/asm/bitops.h | 6 ++---- arch/s390/include/asm/bitops.h | 6 ++---- arch/sparc/include/asm/bitops_64.h | 6 ++---- arch/tile/include/asm/bitops_64.h | 6 ++---- arch/x86/include/asm/bitops.h | 6 ++---- arch/xtensa/include/asm/bitops.h | 15 ++------------- include/asm-generic/bitops/ext2-atomic.h | 9 +++++++++ 15 files changed, 37 insertions(+), 63 deletions(-)
arch/alpha/include/asm/bitops.h +2 -2
@@ -456,8 +456,8 @@ sched_find_first_bit(const unsigned long b[2])#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (l,n,a) test_and_set_bit(n,a) -#define ext2_clear_bit_atomic (l,n,a) test_and_clear_bit(n,a) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */
arch/arm/include/asm/bitops.h +2 -4
@@ -310,10 +310,8 @@ static inline int find_next_bit_le(const void *p, int size, int offset)/* * Ext2 is defined to use little-endian byte ordering. */ -#define ext2_set_bit_atomic (lock, nr, p) \ - test_and_set_bit_le(nr, p) -#define ext2_clear_bit_atomic (lock, nr, p) \ - test_and_clear_bit_le(nr, p) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */
arch/cris/include/asm/bitops.h +2 -2
@@ -156,8 +156,8 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (l,n,a) test_and_set_bit(n,a) -#define ext2_clear_bit_atomic (l,n,a) test_and_clear_bit(n,a) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #include <asm-generic/bitops/sched.h>
arch/frv/include/asm/bitops.h +2 -2
@@ -403,8 +403,8 @@ int __ilog2_u64(u64 n)#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (lock,nr,addr) test_and_set_bit ((nr) ^ 0x18, (addr)) -#define ext2_clear_bit_atomic (lock,nr,addr) test_and_clear_bit((nr) ^ 0x18, (addr)) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */
arch/ia64/include/asm/bitops.h +2 -2
@@ -458,8 +458,8 @@ static __inline__ unsigned long __arch_hweight64(unsigned long x)#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (l,n,a) test_and_set_bit(n,a) -#define ext2_clear_bit_atomic (l,n,a) test_and_clear_bit(n,a) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #include <asm-generic/bitops/sched.h>
arch/m68k/include/asm/bitops_mm.h +2 -4
@@ -491,10 +491,8 @@ static inline unsigned long find_next_bit_le(const void *addr,/* Bitmap functions for the ext2 filesystem. */ -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit_le(nr, addr) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit_le(nr, addr) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */
arch/mn10300/include/asm/bitops.h +2 -6
@@ -227,12 +227,8 @@ int ffs(int x)#include <asm-generic/bitops/find.h> #include <asm-generic/bitops/sched.h> #include <asm-generic/bitops/hweight.h> - -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit((nr), (addr)) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit((nr), (addr)) - +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #include <asm-generic/bitops/le.h> #endif /* __KERNEL__ */
arch/parisc/include/asm/bitops.h +2 -8
@@ -223,14 +223,8 @@ static __inline__ int fls(int x)#ifdef __KERNEL__#include <asm-generic/bitops/le.h> - -/* '3' is bits per byte */ -#define LE_BYTE_ADDR ((sizeof(unsigned long) - 1) << 3) - -#define ext2_set_bit_atomic (l,nr,addr) \ - test_and_set_bit((nr) ^ LE_BYTE_ADDR, (unsigned long *)addr) -#define ext2_clear_bit_atomic (l,nr,addr) \ - test_and_clear_bit( (nr) ^ LE_BYTE_ADDR, (unsigned long *)addr) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */
arch/powerpc/include/asm/bitops.h +2 -4
@@ -327,10 +327,8 @@ unsigned long find_next_bit_le(const void *addr, unsigned long size, unsigned long offset);/* Bitmap functions for the ext2 filesystem */ -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit_le((nr), (unsigned long*)addr) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit_le((nr), (unsigned long*)addr) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #include <asm-generic/bitops/sched.h>
arch/s390/include/asm/bitops.h +2 -4
@@ -832,10 +832,8 @@ static inline int find_next_bit_le(void *vaddr, unsigned long size,#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit_le(nr, addr) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit_le(nr, addr) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */
arch/sparc/include/asm/bitops_64.h +2 -4
@@ -91,10 +91,8 @@ static inline unsigned int __arch_hweight8(unsigned int w)#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (lock,nr,addr) \ - test_and_set_bit((nr) ^ 0x38,(unsigned long *)(addr)) -#define ext2_clear_bit_atomic (lock,nr,addr) \ - test_and_clear_bit((nr) ^ 0x38,(unsigned long *)(addr)) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */
arch/tile/include/asm/bitops_64.h +2 -4
@@ -97,9 +97,7 @@ static inline int test_and_change_bit(unsigned nr, return (oldval & mask) != 0; } -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit((nr), (unsigned long *)(addr)) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit((nr), (unsigned long *)(addr)) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* _ASM_TILE_BITOPS_64_H */
arch/x86/include/asm/bitops.h +2 -4
@@ -458,10 +458,8 @@ static inline int fls(int x)#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit((nr), (unsigned long *)(addr)) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit((nr), (unsigned long *)(addr)) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */ #endif /* _ASM_X86_BITOPS_H */
arch/xtensa/include/asm/bitops.h +2 -13
@@ -108,19 +108,8 @@ static inline unsigned long __fls(unsigned long word)#include <asm-generic/bitops/find.h> #include <asm-generic/bitops/le.h> -#ifdef __XTENSA_EL__ -# define ext2_set_bit_atomic (lock,nr,addr) \ - test_and_set_bit((nr), (unsigned long*)(addr)) -# define ext2_clear_bit_atomic (lock,nr,addr) \ - test_and_clear_bit((nr), (unsigned long*)(addr)) -#elif defined(__XTENSA_EB__) -# define ext2_set_bit_atomic (lock,nr,addr) \ - test_and_set_bit((nr) ^ 0x18, (unsigned long*)(addr)) -# define ext2_clear_bit_atomic (lock,nr,addr) \ - test_and_clear_bit((nr) ^ 0x18, (unsigned long*)(addr)) -#else -# error processor byte order undefined! -#endif +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #include <asm-generic/bitops/hweight.h> #include <asm-generic/bitops/lock.h>
include/asm-generic/bitops/ext2-atomic.h +9 -0
@@ -1,6 +1,13 @@#ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_#define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ +#ifdef ARCH_NO_EXT2_ATOMIC_SPINLOCK + +#define ext2_set_bit_atomic (l, nr, addr) test_and_set_bit_le(nr, addr) +#define ext2_clear_bit_atomic (l, nr, addr) test_and_clear_bit_le(nr, addr) + +#else +#define ext2_set_bit_atomic (lock, nr, addr) \ ({ \ int ret; \
@@ -19,4 +26,6 @@ ret; \ }) +#endif +#endif /* _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ */
Signature · 1 line
1.7.4.4
Hi Akinobu,
Quoted 5 lines · Akinobu Mita
The majority of architectures implement ext2 atomic bitops as test_and_{set,clear}_bit() without spinlock.
This adds this type of generic implementation in
ext2-atomic.hand use it wherever possible.
I am trying to get consensus on merging the m68k bitops_mm.h and bitops_no.h. Here is a proposed patch to do this:
http://www.spinics.net/lists/linux-m68k/msg03803.html
I expect you wouldn't need to patch m68k/bitops_mm.h if this goes in.
Regards
Greg
Quoted 291 lines
Suggested-by Andreas Dilger<[email protected]>Signed-off-by Akinobu Mita<[email protected]>Cc Arnd Bergmann<[email protected]>--- arch/alpha/include/asm/bitops.h | 4 ++-- arch/arm/include/asm/bitops.h | 6 ++---- arch/cris/include/asm/bitops.h | 4 ++-- arch/frv/include/asm/bitops.h | 4 ++-- arch/ia64/include/asm/bitops.h | 4 ++-- arch/m68k/include/asm/bitops_mm.h | 6 ++---- arch/mn10300/include/asm/bitops.h | 8 ++------ arch/parisc/include/asm/bitops.h | 10 ++-------- arch/powerpc/include/asm/bitops.h | 6 ++---- arch/s390/include/asm/bitops.h | 6 ++---- arch/sparc/include/asm/bitops_64.h | 6 ++---- arch/tile/include/asm/bitops_64.h | 6 ++---- arch/x86/include/asm/bitops.h | 6 ++---- arch/xtensa/include/asm/bitops.h | 15 ++------------- include/asm-generic/bitops/ext2-atomic.h | 9 +++++++++ 15 files changed, 37 insertions(+), 63 deletions(-)arch/alpha/include/asm/bitops.h +2
-2@@ -456,8 +456,8 @@ sched_find_first_bit(const unsigned long b[2])#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (l,n,a) test_and_set_bit(n,a) -#define ext2_clear_bit_atomic (l,n,a) test_and_clear_bit(n,a) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */ arch/arm/include/asm/bitops.h +2
-4@@ -310,10 +310,8 @@ static inline int find_next_bit_le(const void *p, int size, int offset)/* * Ext2 is defined to use little-endian byte ordering. */ -#define ext2_set_bit_atomic (lock, nr, p) \ - test_and_set_bit_le(nr, p) -#define ext2_clear_bit_atomic (lock, nr, p) \ - test_and_clear_bit_le(nr, p) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */ arch/cris/include/asm/bitops.h +2
-2@@ -156,8 +156,8 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (l,n,a) test_and_set_bit(n,a) -#define ext2_clear_bit_atomic (l,n,a) test_and_clear_bit(n,a) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #include <asm-generic/bitops/sched.h> arch/frv/include/asm/bitops.h +2
-2@@ -403,8 +403,8 @@ int __ilog2_u64(u64 n)#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (lock,nr,addr) test_and_set_bit ((nr) ^ 0x18, (addr)) -#define ext2_clear_bit_atomic (lock,nr,addr) test_and_clear_bit((nr) ^ 0x18, (addr)) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */ arch/ia64/include/asm/bitops.h +2
-2@@ -458,8 +458,8 @@ static __inline__ unsigned long __arch_hweight64(unsigned long x)#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (l,n,a) test_and_set_bit(n,a) -#define ext2_clear_bit_atomic (l,n,a) test_and_clear_bit(n,a) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #include <asm-generic/bitops/sched.h> arch/m68k/include/asm/bitops_mm.h +2
-4@@ -491,10 +491,8 @@ static inline unsigned long find_next_bit_le(const void *addr,/* Bitmap functions for the ext2 filesystem. */ -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit_le(nr, addr) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit_le(nr, addr) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */ arch/mn10300/include/asm/bitops.h +2
-6@@ -227,12 +227,8 @@ int ffs(int x)#include <asm-generic/bitops/find.h> #include <asm-generic/bitops/sched.h> #include <asm-generic/bitops/hweight.h> - -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit((nr), (addr)) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit((nr), (addr)) - +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #include <asm-generic/bitops/le.h> #endif /* __KERNEL__ */ arch/parisc/include/asm/bitops.h +2
-8@@ -223,14 +223,8 @@ static __inline__ int fls(int x)#ifdef __KERNEL__#include <asm-generic/bitops/le.h> - -/* '3' is bits per byte */ -#define LE_BYTE_ADDR ((sizeof(unsigned long) - 1)<< 3) - -#define ext2_set_bit_atomic (l,nr,addr) \ - test_and_set_bit((nr) ^ LE_BYTE_ADDR, (unsigned long *)addr) -#define ext2_clear_bit_atomic (l,nr,addr) \ - test_and_clear_bit( (nr) ^ LE_BYTE_ADDR, (unsigned long *)addr) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */ arch/powerpc/include/asm/bitops.h +2
-4@@ -327,10 +327,8 @@ unsigned long find_next_bit_le(const void *addr, unsigned long size, unsigned long offset);/* Bitmap functions for the ext2 filesystem */ -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit_le((nr), (unsigned long*)addr) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit_le((nr), (unsigned long*)addr) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #include <asm-generic/bitops/sched.h> arch/s390/include/asm/bitops.h +2
-4@@ -832,10 +832,8 @@ static inline int find_next_bit_le(void *vaddr, unsigned long size,#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit_le(nr, addr) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit_le(nr, addr) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */ arch/sparc/include/asm/bitops_64.h +2
-4@@ -91,10 +91,8 @@ static inline unsigned int __arch_hweight8(unsigned int w)#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (lock,nr,addr) \ - test_and_set_bit((nr) ^ 0x38,(unsigned long *)(addr)) -#define ext2_clear_bit_atomic (lock,nr,addr) \ - test_and_clear_bit((nr) ^ 0x38,(unsigned long *)(addr)) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */ arch/tile/include/asm/bitops_64.h +2
-4@@ -97,9 +97,7 @@ static inline int test_and_change_bit(unsigned nr, return (oldval& mask) != 0; } -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit((nr), (unsigned long *)(addr)) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit((nr), (unsigned long *)(addr)) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* _ASM_TILE_BITOPS_64_H */ arch/x86/include/asm/bitops.h +2
-4@@ -458,10 +458,8 @@ static inline int fls(int x)#include <asm-generic/bitops/le.h> -#define ext2_set_bit_atomic (lock, nr, addr) \ - test_and_set_bit((nr), (unsigned long *)(addr)) -#define ext2_clear_bit_atomic (lock, nr, addr) \ - test_and_clear_bit((nr), (unsigned long *)(addr)) +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #endif /* __KERNEL__ */ #endif /* _ASM_X86_BITOPS_H */ arch/xtensa/include/asm/bitops.h +2
-13@@ -108,19 +108,8 @@ static inline unsigned long __fls(unsigned long word)#include <asm-generic/bitops/find.h> #include <asm-generic/bitops/le.h> -#ifdef __XTENSA_EL__ -# define ext2_set_bit_atomic (lock,nr,addr) \ - test_and_set_bit((nr), (unsigned long*)(addr)) -# define ext2_clear_bit_atomic (lock,nr,addr) \ - test_and_clear_bit((nr), (unsigned long*)(addr)) -#elif defined(__XTENSA_EB__) -# define ext2_set_bit_atomic (lock,nr,addr) \ - test_and_set_bit((nr) ^ 0x18, (unsigned long*)(addr)) -# define ext2_clear_bit_atomic (lock,nr,addr) \ - test_and_clear_bit((nr) ^ 0x18, (unsigned long*)(addr)) -#else -# error processor byte order undefined! -#endif +#define ARCH_NO_EXT2_ATOMIC_SPINLOCK +#include <asm-generic/bitops/ext2-atomic.h> #include <asm-generic/bitops/hweight.h> #include <asm-generic/bitops/lock.h> include/asm-generic/bitops/ext2-atomic.h +9
-0@@ -1,6 +1,13 @@#ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_#define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ +#ifdef ARCH_NO_EXT2_ATOMIC_SPINLOCK + +#define ext2_set_bit_atomic (l, nr, addr) test_and_set_bit_le(nr, addr) +#define ext2_clear_bit_atomic (l, nr, addr) test_and_clear_bit_le(nr, addr) + +#else +#define ext2_set_bit_atomic (lock, nr, addr) \ ({ \ int ret; \@@ -19,4 +26,6 @@ ret; \ }) +#endif +#endif /* _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ */
Signature · 5 lines
------------------------------------------------------------------------ Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
Arnd Bergmann
maintainerQuoted 5 lines · Akinobu Mita
The majority of architectures implement ext2 atomic bitops as test_and_{set,clear}_bit() without spinlock.
This adds this type of generic implementation in
ext2-atomic.hand use it wherever possible.
The idea sounds really good, but I'm trying to keep the number of ARCH_* macros low. How about instead providing a new asm-generic/bitops/ext2-atomic-setbit.h or similar?
Each architecture can then include either the spinlock or the atomic bitop based version.
Arnd