* [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit
@ 2010-10-08 10:03 Akinobu Mita
2010-10-08 10:03 ` [PATCH 2/5] bitops: cleanup asm-generic/bitops/le.h Akinobu Mita
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Akinobu Mita @ 2010-10-08 10:03 UTC (permalink / raw)
To: linux-kernel, linux-arch, Arnd Bergmann, Andrew Morton; +Cc: Akinobu Mita
This introduces asm-generic header file for generic implementation of
ext2 atomic bit operations by test_and_set_bit() and test_and_clear_bit().
alpha, arm, cris, frv, ia64, m68k, mn10300, parisc, powerpc, s390,
sparc64, x86, xtensa can use this header file in its asm/bitops.h.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
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 | 4 +-
arch/mn10300/include/asm/bitops.h | 6 +----
arch/parisc/include/asm/bitops.h | 9 +-------
arch/powerpc/include/asm/bitops.h | 8 ++----
arch/s390/include/asm/bitops.h | 6 +---
arch/sparc/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-test.h | 26 +++++++++++++++++++++++++
include/asm-generic/bitops/ext2-atomic.h | 4 +++
15 files changed, 48 insertions(+), 64 deletions(-)
create mode 100644 include/asm-generic/bitops/ext2-atomic-test.h
diff --git a/arch/alpha/include/asm/bitops.h b/arch/alpha/include/asm/bitops.h
index adfab8a..778468b 100644
--- a/arch/alpha/include/asm/bitops.h
+++ b/arch/alpha/include/asm/bitops.h
@@ -455,9 +455,7 @@ sched_find_first_bit(const unsigned long b[2])
}
#include <asm-generic/bitops/ext2-non-atomic.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)
+#include <asm-generic/bitops/ext2-atomic-test.h>
#include <asm-generic/bitops/minix.h>
diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
index 338ff19..f98b8c8 100644
--- a/arch/arm/include/asm/bitops.h
+++ b/arch/arm/include/asm/bitops.h
@@ -309,12 +309,8 @@ static inline int fls(int x)
*/
#define ext2_set_bit(nr,p) \
__test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
-#define ext2_set_bit_atomic(lock,nr,p) \
- test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
#define ext2_clear_bit(nr,p) \
__test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
-#define ext2_clear_bit_atomic(lock,nr,p) \
- test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
#define ext2_test_bit(nr,p) \
test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
#define ext2_find_first_zero_bit(p,sz) \
@@ -324,6 +320,8 @@ static inline int fls(int x)
#define ext2_find_next_bit(p, sz, off) \
_find_next_bit_le(p, sz, off)
+#include <asm-generic/bitops/ext2-atomic-test.h>
+
/*
* Minix is defined to use little-endian byte ordering.
* These do not need to be atomic.
diff --git a/arch/cris/include/asm/bitops.h b/arch/cris/include/asm/bitops.h
index 9e69cfb..e1f77fc 100644
--- a/arch/cris/include/asm/bitops.h
+++ b/arch/cris/include/asm/bitops.h
@@ -155,9 +155,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
#include <asm-generic/bitops/lock.h>
#include <asm-generic/bitops/ext2-non-atomic.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)
+#include <asm-generic/bitops/ext2-atomic-test.h>
#include <asm-generic/bitops/minix.h>
#include <asm-generic/bitops/sched.h>
diff --git a/arch/frv/include/asm/bitops.h b/arch/frv/include/asm/bitops.h
index 50ae91b..0d718ce 100644
--- a/arch/frv/include/asm/bitops.h
+++ b/arch/frv/include/asm/bitops.h
@@ -402,9 +402,7 @@ int __ilog2_u64(u64 n)
#include <asm-generic/bitops/lock.h>
#include <asm-generic/bitops/ext2-non-atomic.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))
+#include <asm-generic/bitops/ext2-atomic-test.h>
#include <asm-generic/bitops/minix-le.h>
diff --git a/arch/ia64/include/asm/bitops.h b/arch/ia64/include/asm/bitops.h
index 9da3df6..22ba18b 100644
--- a/arch/ia64/include/asm/bitops.h
+++ b/arch/ia64/include/asm/bitops.h
@@ -457,9 +457,7 @@ static __inline__ unsigned long __arch_hweight64(unsigned long x)
#ifdef __KERNEL__
#include <asm-generic/bitops/ext2-non-atomic.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)
+#include <asm-generic/bitops/ext2-atomic-test.h>
#include <asm-generic/bitops/minix.h>
#include <asm-generic/bitops/sched.h>
diff --git a/arch/m68k/include/asm/bitops_mm.h b/arch/m68k/include/asm/bitops_mm.h
index b4ecdaa..776d7b3 100644
--- a/arch/m68k/include/asm/bitops_mm.h
+++ b/arch/m68k/include/asm/bitops_mm.h
@@ -362,9 +362,7 @@ static inline int minix_test_bit(int nr, const void *vaddr)
/* Bitmap functions for the ext2 filesystem. */
#define ext2_set_bit(nr, addr) __test_and_set_bit((nr) ^ 24, (unsigned long *)(addr))
-#define ext2_set_bit_atomic(lock, nr, addr) test_and_set_bit((nr) ^ 24, (unsigned long *)(addr))
#define ext2_clear_bit(nr, addr) __test_and_clear_bit((nr) ^ 24, (unsigned long *)(addr))
-#define ext2_clear_bit_atomic(lock, nr, addr) test_and_clear_bit((nr) ^ 24, (unsigned long *)(addr))
#define ext2_find_next_zero_bit(addr, size, offset) \
generic_find_next_zero_le_bit((unsigned long *)addr, size, offset)
#define ext2_find_next_bit(addr, size, offset) \
@@ -461,6 +459,8 @@ static inline unsigned long generic_find_next_le_bit(const unsigned long *addr,
return (p - addr) * 32 + res;
}
+#include <asm-generic/bitops/ext2-atomic-test.h>
+
#endif /* __KERNEL__ */
#endif /* _M68K_BITOPS_H */
diff --git a/arch/mn10300/include/asm/bitops.h b/arch/mn10300/include/asm/bitops.h
index 3f50e96..23e3a5a 100644
--- a/arch/mn10300/include/asm/bitops.h
+++ b/arch/mn10300/include/asm/bitops.h
@@ -228,11 +228,7 @@ int ffs(int x)
#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))
-
+#include <asm-generic/bitops/ext2-atomic-test.h>
#include <asm-generic/bitops/ext2-non-atomic.h>
#include <asm-generic/bitops/minix-le.h>
diff --git a/arch/parisc/include/asm/bitops.h b/arch/parisc/include/asm/bitops.h
index 7a6ea10..2bd003d 100644
--- a/arch/parisc/include/asm/bitops.h
+++ b/arch/parisc/include/asm/bitops.h
@@ -223,14 +223,7 @@ static __inline__ int fls(int x)
#ifdef __KERNEL__
#include <asm-generic/bitops/ext2-non-atomic.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)
+#include <asm-generic/bitops/ext2-atomic-test.h>
#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index 30964ae..d8dba27 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -307,11 +307,6 @@ unsigned long generic_find_next_le_bit(const unsigned long *addr,
#define ext2_clear_bit(nr, addr) \
__test_and_clear_le_bit((nr), (unsigned long*)addr)
-#define ext2_set_bit_atomic(lock, nr, addr) \
- test_and_set_le_bit((nr), (unsigned long*)addr)
-#define ext2_clear_bit_atomic(lock, nr, addr) \
- test_and_clear_le_bit((nr), (unsigned long*)addr)
-
#define ext2_test_bit(nr, addr) test_le_bit((nr),(unsigned long*)addr)
#define ext2_find_first_zero_bit(addr, size) \
@@ -321,6 +316,9 @@ unsigned long generic_find_next_le_bit(const unsigned long *addr,
#define ext2_find_next_bit(addr, size, off) \
generic_find_next_le_bit((unsigned long *)addr, size, off)
+
+#include <asm-generic/bitops/ext2-atomic-test.h>
+
/* Bitmap functions for the minix filesystem. */
#define minix_test_and_set_bit(nr,addr) \
diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h
index 2e05972..052b4fb 100644
--- a/arch/s390/include/asm/bitops.h
+++ b/arch/s390/include/asm/bitops.h
@@ -744,12 +744,8 @@ static inline int sched_find_first_bit(unsigned long *b)
#define ext2_set_bit(nr, addr) \
__test_and_set_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr)
-#define ext2_set_bit_atomic(lock, nr, addr) \
- test_and_set_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr)
#define ext2_clear_bit(nr, addr) \
__test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr)
-#define ext2_clear_bit_atomic(lock, nr, addr) \
- test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr)
#define ext2_test_bit(nr, addr) \
test_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr)
@@ -834,6 +830,8 @@ static inline int ext2_find_next_bit(void *vaddr, unsigned long size,
return offset + ext2_find_first_bit(p, size);
}
+#include <asm-generic/bitops/ext2-atomic-test.h>
+
#include <asm-generic/bitops/minix.h>
#endif /* __KERNEL__ */
diff --git a/arch/sparc/include/asm/bitops_64.h b/arch/sparc/include/asm/bitops_64.h
index 766121a..fd12692 100644
--- a/arch/sparc/include/asm/bitops_64.h
+++ b/arch/sparc/include/asm/bitops_64.h
@@ -90,11 +90,7 @@ static inline unsigned int __arch_hweight8(unsigned int w)
#ifdef __KERNEL__
#include <asm-generic/bitops/ext2-non-atomic.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))
+#include <asm-generic/bitops/ext2-atomic-test.h>
#include <asm-generic/bitops/minix.h>
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index 903683b..601f4c4 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -457,11 +457,7 @@ static inline int fls(int x)
#ifdef __KERNEL__
#include <asm-generic/bitops/ext2-non-atomic.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))
+#include <asm-generic/bitops/ext2-atomic-test.h>
#include <asm-generic/bitops/minix.h>
diff --git a/arch/xtensa/include/asm/bitops.h b/arch/xtensa/include/asm/bitops.h
index 6c39303..1aa0a5c 100644
--- a/arch/xtensa/include/asm/bitops.h
+++ b/arch/xtensa/include/asm/bitops.h
@@ -107,20 +107,7 @@ static inline unsigned long __fls(unsigned long word)
#include <asm-generic/bitops/fls64.h>
#include <asm-generic/bitops/find.h>
#include <asm-generic/bitops/ext2-non-atomic.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
+#include <asm-generic/bitops/ext2-atomic-test.h>
#include <asm-generic/bitops/hweight.h>
#include <asm-generic/bitops/lock.h>
diff --git a/include/asm-generic/bitops/ext2-atomic-test.h b/include/asm-generic/bitops/ext2-atomic-test.h
new file mode 100644
index 0000000..ece193a
--- /dev/null
+++ b/include/asm-generic/bitops/ext2-atomic-test.h
@@ -0,0 +1,26 @@
+#ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_TEST_H_
+#define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_TEST_H_
+
+/*
+ * Generic implementation of ext2 atomic bit operations
+ * by test_and_set_bit() and test_and_clear_bit()
+ */
+
+#include <asm/byteorder.h>
+
+#if defined(__LITTLE_ENDIAN)
+#define LE_BYTE_ADDR 0
+#elif defined(__BIG_ENDIAN)
+/* '3' is bits per byte */
+#define LE_BYTE_ADDR ((sizeof(unsigned long) - 1) << 3)
+#else
+#error processor byte order undefined!
+#endif
+
+#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))
+
+#endif /* _ASM_GENERIC_BITOPS_EXT2_ATOMIC_TEST_H_ */
diff --git a/include/asm-generic/bitops/ext2-atomic.h b/include/asm-generic/bitops/ext2-atomic.h
index ab1c875..151219f 100644
--- a/include/asm-generic/bitops/ext2-atomic.h
+++ b/include/asm-generic/bitops/ext2-atomic.h
@@ -1,6 +1,10 @@
#ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_
#define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_
+/*
+ * Generic implementation of ext2 atomic bit operations by spinlock
+ */
+
#define ext2_set_bit_atomic(lock, nr, addr) \
({ \
int ret; \
--
1.7.1.231.gd0b16
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/5] bitops: cleanup asm-generic/bitops/le.h
2010-10-08 10:03 [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit Akinobu Mita
@ 2010-10-08 10:03 ` Akinobu Mita
2010-10-08 10:03 ` [PATCH 3/5] kvm: stop including asm-generic/bitops/le.h directly Akinobu Mita
` (3 subsequent siblings)
4 siblings, 0 replies; 13+ messages in thread
From: Akinobu Mita @ 2010-10-08 10:03 UTC (permalink / raw)
To: linux-kernel, linux-arch, Arnd Bergmann, Andrew Morton; +Cc: Akinobu Mita
- Remove unused BITOP_WORD macro
- Merge definisions for big endian and little endian as much as possible
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
include/asm-generic/bitops/le.h | 38 +++++++++++++++-----------------------
1 files changed, 15 insertions(+), 23 deletions(-)
diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h
index 80e3bf1..db2be81 100644
--- a/include/asm-generic/bitops/le.h
+++ b/include/asm-generic/bitops/le.h
@@ -4,27 +4,28 @@
#include <asm/types.h>
#include <asm/byteorder.h>
-#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)
-#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
-
#if defined(__LITTLE_ENDIAN)
-#define generic_test_le_bit(nr, addr) test_bit(nr, addr)
-#define generic___set_le_bit(nr, addr) __set_bit(nr, addr)
-#define generic___clear_le_bit(nr, addr) __clear_bit(nr, addr)
-
-#define generic_test_and_set_le_bit(nr, addr) test_and_set_bit(nr, addr)
-#define generic_test_and_clear_le_bit(nr, addr) test_and_clear_bit(nr, addr)
+#define BITOP_LE_SWIZZLE 0
-#define generic___test_and_set_le_bit(nr, addr) __test_and_set_bit(nr, addr)
-#define generic___test_and_clear_le_bit(nr, addr) __test_and_clear_bit(nr, addr)
-
-#define generic_find_next_zero_le_bit(addr, size, offset) find_next_zero_bit(addr, size, offset)
+#define generic_find_next_zero_le_bit(addr, size, offset) \
+ find_next_zero_bit(addr, size, offset)
#define generic_find_next_le_bit(addr, size, offset) \
- find_next_bit(addr, size, offset)
+ find_next_bit(addr, size, offset)
#elif defined(__BIG_ENDIAN)
+#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
+
+extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
+ unsigned long size, unsigned long offset);
+extern unsigned long generic_find_next_le_bit(const unsigned long *addr,
+ unsigned long size, unsigned long offset);
+
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
+
#define generic_test_le_bit(nr, addr) \
test_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
#define generic___set_le_bit(nr, addr) \
@@ -42,15 +43,6 @@
#define generic___test_and_clear_le_bit(nr, addr) \
__test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
-extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
- unsigned long size, unsigned long offset);
-extern unsigned long generic_find_next_le_bit(const unsigned long *addr,
- unsigned long size, unsigned long offset);
-
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-
#define generic_find_first_zero_le_bit(addr, size) \
generic_find_next_zero_le_bit((addr), (size), 0)
--
1.7.1.231.gd0b16
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/5] kvm: stop including asm-generic/bitops/le.h directly
2010-10-08 10:03 [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit Akinobu Mita
2010-10-08 10:03 ` [PATCH 2/5] bitops: cleanup asm-generic/bitops/le.h Akinobu Mita
@ 2010-10-08 10:03 ` Akinobu Mita
2010-10-08 12:45 ` Alexander Graf
2010-10-08 10:03 ` [PATCH 4/5] rds: " Akinobu Mita
` (2 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Akinobu Mita @ 2010-10-08 10:03 UTC (permalink / raw)
To: linux-kernel, linux-arch, Arnd Bergmann, Andrew Morton
Cc: Akinobu Mita, Avi Kivity, Marcelo Tosatti, kvm
asm-generic/bitops/le.h is only intended to be included directly from
asm-generic/bitops/ext2-non-atomic.h or asm-generic/bitops/minix-le.h
which implements generic ext2 or minix bit operations.
This stops including asm-generic/bitops/le.h directly and use ext2
non-atomic bit operations instead.
An alternative approach is introducing little endian bit operations
in linux/bitops.h. But it needs to touch more files than this change does.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org
---
virt/kvm/kvm_main.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 5186e72..780b71d 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -52,7 +52,6 @@
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
-#include <asm-generic/bitops/le.h>
#include "coalesced_mmio.h"
@@ -1208,7 +1207,7 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
if (memslot && memslot->dirty_bitmap) {
unsigned long rel_gfn = gfn - memslot->base_gfn;
- generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
+ ext2_set_bit(rel_gfn, memslot->dirty_bitmap);
}
}
--
1.7.1.231.gd0b16
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/5] rds: stop including asm-generic/bitops/le.h directly
2010-10-08 10:03 [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit Akinobu Mita
2010-10-08 10:03 ` [PATCH 2/5] bitops: cleanup asm-generic/bitops/le.h Akinobu Mita
2010-10-08 10:03 ` [PATCH 3/5] kvm: stop including asm-generic/bitops/le.h directly Akinobu Mita
@ 2010-10-08 10:03 ` Akinobu Mita
2010-10-08 18:55 ` Andy Grover
2010-10-08 10:03 ` [PATCH 5/5] bitops: forbid asm-generic/bitops/le.h direct inclusion Akinobu Mita
2010-10-08 10:24 ` [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit Christoph Hellwig
4 siblings, 1 reply; 13+ messages in thread
From: Akinobu Mita @ 2010-10-08 10:03 UTC (permalink / raw)
To: linux-kernel, linux-arch, Arnd Bergmann, Andrew Morton
Cc: Akinobu Mita, Andy Grover, rds-devel, David S. Miller, netdev
asm-generic/bitops/le.h is only intended to be included directly from
asm-generic/bitops/ext2-non-atomic.h or asm-generic/bitops/minix-le.h
which implements generic ext2 or minix bit operations.
This stops including asm-generic/bitops/le.h directly and use ext2
non-atomic bit operations instead.
An alternative approach is introducing little endian bit operations
in linux/bitops.h. But it needs to touch more files than this change does.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Andy Grover <andy.grover@oracle.com>
Cc: rds-devel@oss.oracle.com
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---
net/rds/cong.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/net/rds/cong.c b/net/rds/cong.c
index 0871a29..5bd0f36 100644
--- a/net/rds/cong.c
+++ b/net/rds/cong.c
@@ -33,8 +33,7 @@
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/rbtree.h>
-
-#include <asm-generic/bitops/le.h>
+#include <linux/bitops.h>
#include "rds.h"
@@ -285,7 +284,7 @@ void rds_cong_set_bit(struct rds_cong_map *map, __be16 port)
i = be16_to_cpu(port) / RDS_CONG_MAP_PAGE_BITS;
off = be16_to_cpu(port) % RDS_CONG_MAP_PAGE_BITS;
- generic___set_le_bit(off, (void *)map->m_page_addrs[i]);
+ ext2_set_bit(off, (void *)map->m_page_addrs[i]);
}
void rds_cong_clear_bit(struct rds_cong_map *map, __be16 port)
@@ -299,7 +298,7 @@ void rds_cong_clear_bit(struct rds_cong_map *map, __be16 port)
i = be16_to_cpu(port) / RDS_CONG_MAP_PAGE_BITS;
off = be16_to_cpu(port) % RDS_CONG_MAP_PAGE_BITS;
- generic___clear_le_bit(off, (void *)map->m_page_addrs[i]);
+ ext2_clear_bit(off, (void *)map->m_page_addrs[i]);
}
static int rds_cong_test_bit(struct rds_cong_map *map, __be16 port)
@@ -310,7 +309,7 @@ static int rds_cong_test_bit(struct rds_cong_map *map, __be16 port)
i = be16_to_cpu(port) / RDS_CONG_MAP_PAGE_BITS;
off = be16_to_cpu(port) % RDS_CONG_MAP_PAGE_BITS;
- return generic_test_le_bit(off, (void *)map->m_page_addrs[i]);
+ return ext2_test_bit(off, (void *)map->m_page_addrs[i]);
}
void rds_cong_add_socket(struct rds_sock *rs)
--
1.7.1.231.gd0b16
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/5] bitops: forbid asm-generic/bitops/le.h direct inclusion
2010-10-08 10:03 [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit Akinobu Mita
` (2 preceding siblings ...)
2010-10-08 10:03 ` [PATCH 4/5] rds: " Akinobu Mita
@ 2010-10-08 10:03 ` Akinobu Mita
2010-10-08 10:24 ` [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit Christoph Hellwig
4 siblings, 0 replies; 13+ messages in thread
From: Akinobu Mita @ 2010-10-08 10:03 UTC (permalink / raw)
To: linux-kernel, linux-arch, Arnd Bergmann, Andrew Morton; +Cc: Akinobu Mita
asm-generic/bitops/le.h is only intended to be included directly from
asm-generic/bitops/ext2-non-atomic.h or asm-generic/bitops/minix-le.h
which implements generic ext2 or minix bit operations.
But there were some source files that include it directly.
(those are already fixed by other commits)
This forbids asm-generic/bitops/le.h direct inclusion in the future.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
include/asm-generic/bitops/le.h | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h
index db2be81..f8d0225 100644
--- a/include/asm-generic/bitops/le.h
+++ b/include/asm-generic/bitops/le.h
@@ -1,6 +1,11 @@
#ifndef _ASM_GENERIC_BITOPS_LE_H_
#define _ASM_GENERIC_BITOPS_LE_H_
+#if !defined(_ASM_GENERIC_BITOPS_MINIX_LE_H_) && \
+ !defined(_ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_)
+#error only minix-le.h and ext2-non-atomic.h can be included directly
+#endif
+
#include <asm/types.h>
#include <asm/byteorder.h>
--
1.7.1.231.gd0b16
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit
2010-10-08 10:03 [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit Akinobu Mita
` (3 preceding siblings ...)
2010-10-08 10:03 ` [PATCH 5/5] bitops: forbid asm-generic/bitops/le.h direct inclusion Akinobu Mita
@ 2010-10-08 10:24 ` Christoph Hellwig
2010-10-10 15:07 ` Akinobu Mita
4 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2010-10-08 10:24 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-kernel, linux-arch, Arnd Bergmann, Andrew Morton
On Fri, Oct 08, 2010 at 07:03:09PM +0900, Akinobu Mita wrote:
> This introduces asm-generic header file for generic implementation of
> ext2 atomic bit operations by test_and_set_bit() and test_and_clear_bit().
>
> alpha, arm, cris, frv, ia64, m68k, mn10300, parisc, powerpc, s390,
> sparc64, x86, xtensa can use this header file in its asm/bitops.h.
Care to rename the functions to le_* instead of ext2_* while you're at
it and documenting their semantics?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/5] kvm: stop including asm-generic/bitops/le.h directly
2010-10-08 10:03 ` [PATCH 3/5] kvm: stop including asm-generic/bitops/le.h directly Akinobu Mita
@ 2010-10-08 12:45 ` Alexander Graf
0 siblings, 0 replies; 13+ messages in thread
From: Alexander Graf @ 2010-10-08 12:45 UTC (permalink / raw)
To: Akinobu Mita
Cc: linux-kernel, linux-arch, Arnd Bergmann, Andrew Morton,
Avi Kivity, Marcelo Tosatti, kvm
On 08.10.2010, at 12:03, Akinobu Mita wrote:
> asm-generic/bitops/le.h is only intended to be included directly from
> asm-generic/bitops/ext2-non-atomic.h or asm-generic/bitops/minix-le.h
> which implements generic ext2 or minix bit operations.
>
> This stops including asm-generic/bitops/le.h directly and use ext2
> non-atomic bit operations instead.
>
> An alternative approach is introducing little endian bit operations
> in linux/bitops.h. But it needs to touch more files than this change does.
That's properly a better idea, given the fact that ext2_set_bit doesn't really say too much to the reader :).
Alex
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/5] rds: stop including asm-generic/bitops/le.h directly
2010-10-08 10:03 ` [PATCH 4/5] rds: " Akinobu Mita
@ 2010-10-08 18:55 ` Andy Grover
2010-10-08 18:59 ` David Miller
0 siblings, 1 reply; 13+ messages in thread
From: Andy Grover @ 2010-10-08 18:55 UTC (permalink / raw)
To: Akinobu Mita
Cc: linux-kernel, linux-arch, Arnd Bergmann, Andrew Morton,
rds-devel, David S. Miller, netdev
On 10/08/2010 03:03 AM, Akinobu Mita wrote:
> asm-generic/bitops/le.h is only intended to be included directly from
> asm-generic/bitops/ext2-non-atomic.h or asm-generic/bitops/minix-le.h
> which implements generic ext2 or minix bit operations.
>
> This stops including asm-generic/bitops/le.h directly and use ext2
> non-atomic bit operations instead.
>
> An alternative approach is introducing little endian bit operations
> in linux/bitops.h. But it needs to touch more files than this change does.
> - generic___set_le_bit(off, (void *)map->m_page_addrs[i]);
> + ext2_set_bit(off, (void *)map->m_page_addrs[i]);
I'd like a solution that doesn't have rds calling a function starting
with ext2_. Seems wrong.
Thanks -- Regards -- Andy
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/5] rds: stop including asm-generic/bitops/le.h directly
2010-10-08 18:55 ` Andy Grover
@ 2010-10-08 18:59 ` David Miller
2010-10-10 15:09 ` Akinobu Mita
0 siblings, 1 reply; 13+ messages in thread
From: David Miller @ 2010-10-08 18:59 UTC (permalink / raw)
To: andy.grover
Cc: akinobu.mita, linux-kernel, linux-arch, arnd, akpm, rds-devel, netdev
From: Andy Grover <andy.grover@oracle.com>
Date: Fri, 08 Oct 2010 11:55:55 -0700
> On 10/08/2010 03:03 AM, Akinobu Mita wrote:
>> asm-generic/bitops/le.h is only intended to be included directly from
>> asm-generic/bitops/ext2-non-atomic.h or asm-generic/bitops/minix-le.h
>> which implements generic ext2 or minix bit operations.
>>
>> This stops including asm-generic/bitops/le.h directly and use ext2
>> non-atomic bit operations instead.
>>
>> An alternative approach is introducing little endian bit operations
>> in linux/bitops.h. But it needs to touch more files than this change
>> does.
>
>> - generic___set_le_bit(off, (void *)map->m_page_addrs[i]);
>> + ext2_set_bit(off, (void *)map->m_page_addrs[i]);
>
> I'd like a solution that doesn't have rds calling a function starting
> with ext2_. Seems wrong.
Agreed.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit
2010-10-08 10:24 ` [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit Christoph Hellwig
@ 2010-10-10 15:07 ` Akinobu Mita
2010-10-10 16:36 ` Arnd Bergmann
0 siblings, 1 reply; 13+ messages in thread
From: Akinobu Mita @ 2010-10-10 15:07 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-kernel, linux-arch, Arnd Bergmann, Andrew Morton
2010/10/8 Christoph Hellwig <hch@infradead.org>:
> On Fri, Oct 08, 2010 at 07:03:09PM +0900, Akinobu Mita wrote:
>> This introduces asm-generic header file for generic implementation of
>> ext2 atomic bit operations by test_and_set_bit() and test_and_clear_bit().
>>
>> alpha, arm, cris, frv, ia64, m68k, mn10300, parisc, powerpc, s390,
>> sparc64, x86, xtensa can use this header file in its asm/bitops.h.
>
> Care to rename the functions to le_* instead of ext2_* while you're at
> it and documenting their semantics?
OK, as several people requested in another threads, I'll introduce
little endian bit operations for all architectures and rename ext2
bitops to le bitops.
BTW, I have a question about ext2 atomic bit operations.
Some architectures use spinlock to implement it
(asm-generic/bitops/ext2-atomic.h). Most other architectures use
test_and_set_bit() and test_and_clear_bit() as this patch shows.
Why are there two implementations? test_and_{set,clear}_bit() are more
costly operations than spinlock for some architectures?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/5] rds: stop including asm-generic/bitops/le.h directly
2010-10-08 18:59 ` David Miller
@ 2010-10-10 15:09 ` Akinobu Mita
0 siblings, 0 replies; 13+ messages in thread
From: Akinobu Mita @ 2010-10-10 15:09 UTC (permalink / raw)
To: David Miller
Cc: andy.grover, linux-kernel, linux-arch, arnd, akpm, rds-devel,
netdev, Alexander Graf
2010/10/9 David Miller <davem@davemloft.net>:
> From: Andy Grover <andy.grover@oracle.com>
> Date: Fri, 08 Oct 2010 11:55:55 -0700
>
>> On 10/08/2010 03:03 AM, Akinobu Mita wrote:
>>> asm-generic/bitops/le.h is only intended to be included directly from
>>> asm-generic/bitops/ext2-non-atomic.h or asm-generic/bitops/minix-le.h
>>> which implements generic ext2 or minix bit operations.
>>>
>>> This stops including asm-generic/bitops/le.h directly and use ext2
>>> non-atomic bit operations instead.
>>>
>>> An alternative approach is introducing little endian bit operations
>>> in linux/bitops.h. But it needs to touch more files than this change
>>> does.
>>
>>> - generic___set_le_bit(off, (void *)map->m_page_addrs[i]);
>>> + ext2_set_bit(off, (void *)map->m_page_addrs[i]);
>>
>> I'd like a solution that doesn't have rds calling a function starting
>> with ext2_. Seems wrong.
>
> Agreed.
OK, I'll rewrite the patch series to take the alternative approach.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit
2010-10-10 15:07 ` Akinobu Mita
@ 2010-10-10 16:36 ` Arnd Bergmann
2010-10-12 3:39 ` Akinobu Mita
0 siblings, 1 reply; 13+ messages in thread
From: Arnd Bergmann @ 2010-10-10 16:36 UTC (permalink / raw)
To: Akinobu Mita; +Cc: Christoph Hellwig, linux-kernel, linux-arch, Andrew Morton
On Sunday 10 October 2010 17:07:26 Akinobu Mita wrote:
> Some architectures use spinlock to implement it
> (asm-generic/bitops/ext2-atomic.h). Most other architectures use
> test_and_set_bit() and test_and_clear_bit() as this patch shows.
>
> Why are there two implementations? test_and_{set,clear}_bit() are more
> costly operations than spinlock for some architectures?
I would guess that is only true on architectures that implement all atomics
using a hashed spinlock like cris, sparc32 or parisc. This way the user
can decide which spinlock to use rather than have the arch code calculate
a hash on the pointer.
This is an ext2 specific micro-optimization that I don't think makes
sense in the generic le bitops code.
Arnd
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit
2010-10-10 16:36 ` Arnd Bergmann
@ 2010-10-12 3:39 ` Akinobu Mita
0 siblings, 0 replies; 13+ messages in thread
From: Akinobu Mita @ 2010-10-12 3:39 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Christoph Hellwig, linux-kernel, linux-arch, Andrew Morton
2010/10/11 Arnd Bergmann <arnd@arndb.de>:
> On Sunday 10 October 2010 17:07:26 Akinobu Mita wrote:
>> Some architectures use spinlock to implement it
>> (asm-generic/bitops/ext2-atomic.h). Most other architectures use
>> test_and_set_bit() and test_and_clear_bit() as this patch shows.
>>
>> Why are there two implementations? test_and_{set,clear}_bit() are more
>> costly operations than spinlock for some architectures?
>
> I would guess that is only true on architectures that implement all atomics
> using a hashed spinlock like cris, sparc32 or parisc. This way the user
> can decide which spinlock to use rather than have the arch code calculate
> a hash on the pointer.
Thanks. It looks quite right.
> This is an ext2 specific micro-optimization that I don't think makes
> sense in the generic le bitops code.
OK, I'll only rename ext2 non-atomic bitops to le bitops and
keep ext2 atomic bitops for now.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2010-10-12 3:39 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-08 10:03 [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit Akinobu Mita
2010-10-08 10:03 ` [PATCH 2/5] bitops: cleanup asm-generic/bitops/le.h Akinobu Mita
2010-10-08 10:03 ` [PATCH 3/5] kvm: stop including asm-generic/bitops/le.h directly Akinobu Mita
2010-10-08 12:45 ` Alexander Graf
2010-10-08 10:03 ` [PATCH 4/5] rds: " Akinobu Mita
2010-10-08 18:55 ` Andy Grover
2010-10-08 18:59 ` David Miller
2010-10-10 15:09 ` Akinobu Mita
2010-10-08 10:03 ` [PATCH 5/5] bitops: forbid asm-generic/bitops/le.h direct inclusion Akinobu Mita
2010-10-08 10:24 ` [PATCH 1/5] bitops: add generic implementation of ext2 atomic bitops by test_and_{set,clear}_bit Christoph Hellwig
2010-10-10 15:07 ` Akinobu Mita
2010-10-10 16:36 ` Arnd Bergmann
2010-10-12 3:39 ` Akinobu Mita
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).