Re: [PATCH v9 3/5] qrwlock, x86 - Treat all data type not biggerthan long as atomic in x86

From: Waiman Long
Date: Tue Jan 21 2014 - 10:37:03 EST

On 01/20/2014 10:03 AM, Peter Zijlstra wrote:
On Tue, Jan 14, 2014 at 11:44:05PM -0500, Waiman Long wrote:
The generic __native_word() macro defined in include/linux/compiler.h
only allows "int" and "long" data types to be treated as native and
atomic. The x86 architecture, however, allow the use of char and short
data types as atomic as well.

This patch extends the data type allowed in the __native_word() macro to
allow the use of char and short.

Signed-off-by: Waiman Long<Waiman.Long@xxxxxx>
arch/x86/include/asm/barrier.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
index 04a4890..4d3e30a 100644
--- a/arch/x86/include/asm/barrier.h
+++ b/arch/x86/include/asm/barrier.h
@@ -24,6 +24,14 @@
#define wmb() asm volatile("sfence" ::: "memory")

+ * All data types<= long are atomic in x86
+ */
+#ifdef __native_word
+#undef __native_word
+#define __native_word(t) (sizeof(t)<= sizeof(long))
Yeah, not going to happen.

Does explicit list of acceptable sizes work for you?

#define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int ) ||
sizeof(t) == sizeof(long))

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at