2020-10-12 12:52:06 +00:00
|
|
|
|
From ba1606a46ad4d99deaf51539cd49b3fe67f8900f Mon Sep 17 00:00:00 2001
|
|
|
|
|
Message-Id: <ba1606a46ad4d99deaf51539cd49b3fe67f8900f.1601675152.git.zanussi@kernel.org>
|
|
|
|
|
In-Reply-To: <5b5a156f9808b1acf1205606e03da117214549ea.1601675151.git.zanussi@kernel.org>
|
|
|
|
|
References: <5b5a156f9808b1acf1205606e03da117214549ea.1601675151.git.zanussi@kernel.org>
|
2018-08-27 14:32:32 +00:00
|
|
|
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
2019-04-08 23:49:20 +00:00
|
|
|
|
Date: Tue, 26 Feb 2019 16:56:02 +0100
|
2020-09-04 20:10:21 +00:00
|
|
|
|
Subject: [PATCH 139/333] rbtree: don't include the rcu header
|
2019-04-08 23:49:20 +00:00
|
|
|
|
MIME-Version: 1.0
|
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
|
Content-Transfer-Encoding: 8bit
|
2020-10-12 12:52:06 +00:00
|
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.148-rt64.tar.xz
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
|
|
The RCU header pulls in spinlock.h and fails due not yet defined types:
|
|
|
|
|
|
|
|
|
|
|In file included from include/linux/spinlock.h:275:0,
|
|
|
|
|
| from include/linux/rcupdate.h:38,
|
|
|
|
|
| from include/linux/rbtree.h:34,
|
|
|
|
|
| from include/linux/rtmutex.h:17,
|
|
|
|
|
| from include/linux/spinlock_types.h:18,
|
|
|
|
|
| from kernel/bounds.c:13:
|
|
|
|
|
|include/linux/rwlock_rt.h:16:38: error: unknown type name ‘rwlock_t’
|
|
|
|
|
| extern void __lockfunc rt_write_lock(rwlock_t *rwlock);
|
|
|
|
|
| ^
|
|
|
|
|
|
|
|
|
|
This patch moves the required RCU function from the rcupdate.h header file into
|
|
|
|
|
a new header file which can be included by both users.
|
|
|
|
|
|
|
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
|
---
|
2019-04-08 23:49:20 +00:00
|
|
|
|
include/linux/rbtree.h | 2 +-
|
|
|
|
|
include/linux/rcu_assign_pointer.h | 54 ++++++++++++++++++++++++++++++
|
|
|
|
|
include/linux/rcupdate.h | 49 +--------------------------
|
2018-08-27 14:32:32 +00:00
|
|
|
|
3 files changed, 56 insertions(+), 49 deletions(-)
|
2019-04-08 23:49:20 +00:00
|
|
|
|
create mode 100644 include/linux/rcu_assign_pointer.h
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
|
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
|
|
|
|
|
index fcbeed4053ef..2aa2aec354c2 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
|
--- a/include/linux/rbtree.h
|
|
|
|
|
+++ b/include/linux/rbtree.h
|
|
|
|
|
@@ -31,7 +31,7 @@
|
|
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
|
-#include <linux/rcupdate.h>
|
|
|
|
|
+#include <linux/rcu_assign_pointer.h>
|
|
|
|
|
|
|
|
|
|
struct rb_node {
|
|
|
|
|
unsigned long __rb_parent_color;
|
2019-04-08 23:49:20 +00:00
|
|
|
|
diff --git a/include/linux/rcu_assign_pointer.h b/include/linux/rcu_assign_pointer.h
|
|
|
|
|
new file mode 100644
|
|
|
|
|
index 000000000000..7066962a4379
|
2018-08-27 14:32:32 +00:00
|
|
|
|
--- /dev/null
|
|
|
|
|
+++ b/include/linux/rcu_assign_pointer.h
|
|
|
|
|
@@ -0,0 +1,54 @@
|
|
|
|
|
+#ifndef __LINUX_RCU_ASSIGN_POINTER_H__
|
|
|
|
|
+#define __LINUX_RCU_ASSIGN_POINTER_H__
|
|
|
|
|
+#include <linux/compiler.h>
|
|
|
|
|
+#include <asm/barrier.h>
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * RCU_INITIALIZER() - statically initialize an RCU-protected global variable
|
|
|
|
|
+ * @v: The value to statically initialize with.
|
|
|
|
|
+ */
|
|
|
|
|
+#define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v)
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * rcu_assign_pointer() - assign to RCU-protected pointer
|
|
|
|
|
+ * @p: pointer to assign to
|
|
|
|
|
+ * @v: value to assign (publish)
|
|
|
|
|
+ *
|
|
|
|
|
+ * Assigns the specified value to the specified RCU-protected
|
|
|
|
|
+ * pointer, ensuring that any concurrent RCU readers will see
|
|
|
|
|
+ * any prior initialization.
|
|
|
|
|
+ *
|
|
|
|
|
+ * Inserts memory barriers on architectures that require them
|
|
|
|
|
+ * (which is most of them), and also prevents the compiler from
|
|
|
|
|
+ * reordering the code that initializes the structure after the pointer
|
|
|
|
|
+ * assignment. More importantly, this call documents which pointers
|
|
|
|
|
+ * will be dereferenced by RCU read-side code.
|
|
|
|
|
+ *
|
|
|
|
|
+ * In some special cases, you may use RCU_INIT_POINTER() instead
|
|
|
|
|
+ * of rcu_assign_pointer(). RCU_INIT_POINTER() is a bit faster due
|
|
|
|
|
+ * to the fact that it does not constrain either the CPU or the compiler.
|
|
|
|
|
+ * That said, using RCU_INIT_POINTER() when you should have used
|
|
|
|
|
+ * rcu_assign_pointer() is a very bad thing that results in
|
|
|
|
|
+ * impossible-to-diagnose memory corruption. So please be careful.
|
|
|
|
|
+ * See the RCU_INIT_POINTER() comment header for details.
|
|
|
|
|
+ *
|
|
|
|
|
+ * Note that rcu_assign_pointer() evaluates each of its arguments only
|
|
|
|
|
+ * once, appearances notwithstanding. One of the "extra" evaluations
|
|
|
|
|
+ * is in typeof() and the other visible only to sparse (__CHECKER__),
|
|
|
|
|
+ * neither of which actually execute the argument. As with most cpp
|
|
|
|
|
+ * macros, this execute-arguments-only-once property is important, so
|
|
|
|
|
+ * please be careful when making changes to rcu_assign_pointer() and the
|
|
|
|
|
+ * other macros that it invokes.
|
|
|
|
|
+ */
|
|
|
|
|
+#define rcu_assign_pointer(p, v) \
|
|
|
|
|
+({ \
|
|
|
|
|
+ uintptr_t _r_a_p__v = (uintptr_t)(v); \
|
|
|
|
|
+ \
|
|
|
|
|
+ if (__builtin_constant_p(v) && (_r_a_p__v) == (uintptr_t)NULL) \
|
|
|
|
|
+ WRITE_ONCE((p), (typeof(p))(_r_a_p__v)); \
|
|
|
|
|
+ else \
|
|
|
|
|
+ smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
|
|
|
|
|
+ _r_a_p__v; \
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+#endif
|
2019-04-08 23:49:20 +00:00
|
|
|
|
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
|
2019-11-25 00:04:39 +00:00
|
|
|
|
index 027c58cdbb6e..e6733d7911e9 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
|
--- a/include/linux/rcupdate.h
|
|
|
|
|
+++ b/include/linux/rcupdate.h
|
|
|
|
|
@@ -42,6 +42,7 @@
|
|
|
|
|
#include <linux/lockdep.h>
|
|
|
|
|
#include <asm/processor.h>
|
|
|
|
|
#include <linux/cpumask.h>
|
|
|
|
|
+#include <linux/rcu_assign_pointer.h>
|
|
|
|
|
|
|
|
|
|
#define ULONG_CMP_GE(a, b) (ULONG_MAX / 2 >= (a) - (b))
|
|
|
|
|
#define ULONG_CMP_LT(a, b) (ULONG_MAX / 2 < (a) - (b))
|
2019-08-18 21:33:52 +00:00
|
|
|
|
@@ -369,54 +370,6 @@ static inline void rcu_preempt_sleep_check(void) { }
|
2019-04-08 23:49:20 +00:00
|
|
|
|
((typeof(*p) __force __kernel *)(________p1)); \
|
2018-08-27 14:32:32 +00:00
|
|
|
|
})
|
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
|
-/**
|
2018-08-27 14:32:32 +00:00
|
|
|
|
- * RCU_INITIALIZER() - statically initialize an RCU-protected global variable
|
|
|
|
|
- * @v: The value to statically initialize with.
|
|
|
|
|
- */
|
|
|
|
|
-#define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v)
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * rcu_assign_pointer() - assign to RCU-protected pointer
|
|
|
|
|
- * @p: pointer to assign to
|
|
|
|
|
- * @v: value to assign (publish)
|
|
|
|
|
- *
|
|
|
|
|
- * Assigns the specified value to the specified RCU-protected
|
|
|
|
|
- * pointer, ensuring that any concurrent RCU readers will see
|
|
|
|
|
- * any prior initialization.
|
|
|
|
|
- *
|
|
|
|
|
- * Inserts memory barriers on architectures that require them
|
|
|
|
|
- * (which is most of them), and also prevents the compiler from
|
|
|
|
|
- * reordering the code that initializes the structure after the pointer
|
|
|
|
|
- * assignment. More importantly, this call documents which pointers
|
|
|
|
|
- * will be dereferenced by RCU read-side code.
|
|
|
|
|
- *
|
|
|
|
|
- * In some special cases, you may use RCU_INIT_POINTER() instead
|
|
|
|
|
- * of rcu_assign_pointer(). RCU_INIT_POINTER() is a bit faster due
|
|
|
|
|
- * to the fact that it does not constrain either the CPU or the compiler.
|
|
|
|
|
- * That said, using RCU_INIT_POINTER() when you should have used
|
|
|
|
|
- * rcu_assign_pointer() is a very bad thing that results in
|
|
|
|
|
- * impossible-to-diagnose memory corruption. So please be careful.
|
|
|
|
|
- * See the RCU_INIT_POINTER() comment header for details.
|
|
|
|
|
- *
|
|
|
|
|
- * Note that rcu_assign_pointer() evaluates each of its arguments only
|
|
|
|
|
- * once, appearances notwithstanding. One of the "extra" evaluations
|
|
|
|
|
- * is in typeof() and the other visible only to sparse (__CHECKER__),
|
|
|
|
|
- * neither of which actually execute the argument. As with most cpp
|
|
|
|
|
- * macros, this execute-arguments-only-once property is important, so
|
|
|
|
|
- * please be careful when making changes to rcu_assign_pointer() and the
|
|
|
|
|
- * other macros that it invokes.
|
|
|
|
|
- */
|
|
|
|
|
-#define rcu_assign_pointer(p, v) \
|
|
|
|
|
-({ \
|
|
|
|
|
- uintptr_t _r_a_p__v = (uintptr_t)(v); \
|
|
|
|
|
- \
|
|
|
|
|
- if (__builtin_constant_p(v) && (_r_a_p__v) == (uintptr_t)NULL) \
|
|
|
|
|
- WRITE_ONCE((p), (typeof(p))(_r_a_p__v)); \
|
|
|
|
|
- else \
|
|
|
|
|
- smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
|
|
|
|
|
- _r_a_p__v; \
|
|
|
|
|
-})
|
|
|
|
|
-
|
2019-04-08 23:49:20 +00:00
|
|
|
|
/**
|
2018-08-27 14:32:32 +00:00
|
|
|
|
* rcu_swap_protected() - swap an RCU and a regular pointer
|
|
|
|
|
* @rcu_ptr: RCU pointer
|
2020-01-03 23:36:11 +00:00
|
|
|
|
--
|
2020-06-22 13:14:16 +00:00
|
|
|
|
2.17.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|
|