lkml.org 
[lkml]   [2014]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC][PATCH 4/7] x86: Add atomic_test_and_set_bit()
For use in qspinlock because unconditional atomic ops scale better
than cmpxchg loops.

Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
arch/x86/include/asm/atomic.h | 13 +++++++++++++
1 file changed, 13 insertions(+)

--- a/arch/x86/include/asm/atomic.h
+++ b/arch/x86/include/asm/atomic.h
@@ -218,6 +218,19 @@ static inline short int atomic_inc_short
return *v;
}

+/**
+ * test_and_set_bit - Set a bit and return its old value
+ * @nr: Bit to set
+ * @addr: Address to count from
+ *
+ * This operation is atomic and cannot be reordered.
+ * It also implies a memory barrier.
+ */
+static inline int atomic_test_and_set_bit(int nr, atomic_t *v)
+{
+ GEN_BINARY_RMWcc(LOCK_PREFIX "bts", v->counter, "Ir", nr, "%0", "c");
+}
+
#ifdef CONFIG_X86_64
/**
* atomic_or_long - OR of two long integers



\
 
 \ /
  Last update: 2014-03-10 17:41    [W:0.183 / U:0.568 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site