hc
2023-11-22 f743a7adbd6e230d66a6206fa115b59fec2d88eb
kernel/include/linux/rcupdate.h
....@@ -42,6 +42,7 @@
4242 #include <linux/lockdep.h>
4343 #include <asm/processor.h>
4444 #include <linux/cpumask.h>
45
+#include <linux/rcu_assign_pointer.h>
4546
4647 #define ULONG_CMP_GE(a, b) (ULONG_MAX / 2 >= (a) - (b))
4748 #define ULONG_CMP_LT(a, b) (ULONG_MAX / 2 < (a) - (b))
....@@ -55,7 +56,11 @@
5556 #define call_rcu call_rcu_sched
5657 #endif /* #else #ifdef CONFIG_PREEMPT_RCU */
5758
59
+#ifdef CONFIG_PREEMPT_RT_FULL
60
+#define call_rcu_bh call_rcu
61
+#else
5862 void call_rcu_bh(struct rcu_head *head, rcu_callback_t func);
63
+#endif
5964 void call_rcu_sched(struct rcu_head *head, rcu_callback_t func);
6065 void synchronize_sched(void);
6166 void rcu_barrier_tasks(void);
....@@ -73,6 +78,11 @@
7378 * types of kernel builds, the rcu_read_lock() nesting depth is unknowable.
7479 */
7580 #define rcu_preempt_depth() (current->rcu_read_lock_nesting)
81
+#ifndef CONFIG_PREEMPT_RT_FULL
82
+#define sched_rcu_preempt_depth() rcu_preempt_depth()
83
+#else
84
+static inline int sched_rcu_preempt_depth(void) { return 0; }
85
+#endif
7686
7787 #else /* #ifdef CONFIG_PREEMPT_RCU */
7888
....@@ -95,6 +105,8 @@
95105 {
96106 return 0;
97107 }
108
+
109
+#define sched_rcu_preempt_depth() rcu_preempt_depth()
98110
99111 #endif /* #else #ifdef CONFIG_PREEMPT_RCU */
100112
....@@ -253,7 +265,14 @@
253265 extern struct lockdep_map rcu_callback_map;
254266 int debug_lockdep_rcu_enabled(void);
255267 int rcu_read_lock_held(void);
268
+#ifdef CONFIG_PREEMPT_RT_FULL
269
+static inline int rcu_read_lock_bh_held(void)
270
+{
271
+ return rcu_read_lock_held();
272
+}
273
+#else
256274 int rcu_read_lock_bh_held(void);
275
+#endif
257276 int rcu_read_lock_sched_held(void);
258277
259278 #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
....@@ -360,54 +379,6 @@
360379 /* Dependency order vs. p above. */ \
361380 typeof(p) ________p1 = READ_ONCE(p); \
362381 ((typeof(*p) __force __kernel *)(________p1)); \
363
-})
364
-
365
-/**
366
- * RCU_INITIALIZER() - statically initialize an RCU-protected global variable
367
- * @v: The value to statically initialize with.
368
- */
369
-#define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v)
370
-
371
-/**
372
- * rcu_assign_pointer() - assign to RCU-protected pointer
373
- * @p: pointer to assign to
374
- * @v: value to assign (publish)
375
- *
376
- * Assigns the specified value to the specified RCU-protected
377
- * pointer, ensuring that any concurrent RCU readers will see
378
- * any prior initialization.
379
- *
380
- * Inserts memory barriers on architectures that require them
381
- * (which is most of them), and also prevents the compiler from
382
- * reordering the code that initializes the structure after the pointer
383
- * assignment. More importantly, this call documents which pointers
384
- * will be dereferenced by RCU read-side code.
385
- *
386
- * In some special cases, you may use RCU_INIT_POINTER() instead
387
- * of rcu_assign_pointer(). RCU_INIT_POINTER() is a bit faster due
388
- * to the fact that it does not constrain either the CPU or the compiler.
389
- * That said, using RCU_INIT_POINTER() when you should have used
390
- * rcu_assign_pointer() is a very bad thing that results in
391
- * impossible-to-diagnose memory corruption. So please be careful.
392
- * See the RCU_INIT_POINTER() comment header for details.
393
- *
394
- * Note that rcu_assign_pointer() evaluates each of its arguments only
395
- * once, appearances notwithstanding. One of the "extra" evaluations
396
- * is in typeof() and the other visible only to sparse (__CHECKER__),
397
- * neither of which actually execute the argument. As with most cpp
398
- * macros, this execute-arguments-only-once property is important, so
399
- * please be careful when making changes to rcu_assign_pointer() and the
400
- * other macros that it invokes.
401
- */
402
-#define rcu_assign_pointer(p, v) \
403
-({ \
404
- uintptr_t _r_a_p__v = (uintptr_t)(v); \
405
- \
406
- if (__builtin_constant_p(v) && (_r_a_p__v) == (uintptr_t)NULL) \
407
- WRITE_ONCE((p), (typeof(p))(_r_a_p__v)); \
408
- else \
409
- smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
410
- _r_a_p__v; \
411382 })
412383
413384 /**
....@@ -701,10 +672,14 @@
701672 static inline void rcu_read_lock_bh(void)
702673 {
703674 local_bh_disable();
675
+#ifdef CONFIG_PREEMPT_RT_FULL
676
+ rcu_read_lock();
677
+#else
704678 __acquire(RCU_BH);
705679 rcu_lock_acquire(&rcu_bh_lock_map);
706680 RCU_LOCKDEP_WARN(!rcu_is_watching(),
707681 "rcu_read_lock_bh() used illegally while idle");
682
+#endif
708683 }
709684
710685 /*
....@@ -714,10 +689,14 @@
714689 */
715690 static inline void rcu_read_unlock_bh(void)
716691 {
692
+#ifdef CONFIG_PREEMPT_RT_FULL
693
+ rcu_read_unlock();
694
+#else
717695 RCU_LOCKDEP_WARN(!rcu_is_watching(),
718696 "rcu_read_unlock_bh() used illegally while idle");
719697 rcu_lock_release(&rcu_bh_lock_map);
720698 __release(RCU_BH);
699
+#endif
721700 local_bh_enable();
722701 }
723702