4848#define ulong2long (a ) (*(long *)(&(a)))
4949
5050/* Exported common interfaces */
51-
52- #ifdef CONFIG_PREEMPT_RCU
5351void call_rcu (struct rcu_head * head , rcu_callback_t func );
54- #else /* #ifdef CONFIG_PREEMPT_RCU */
55- #define call_rcu call_rcu_sched
56- #endif /* #else #ifdef CONFIG_PREEMPT_RCU */
57-
58- void call_rcu_bh (struct rcu_head * head , rcu_callback_t func );
59- void call_rcu_sched (struct rcu_head * head , rcu_callback_t func );
60- void synchronize_sched (void );
6152void rcu_barrier_tasks (void );
53+ void synchronize_rcu (void );
6254
6355#ifdef CONFIG_PREEMPT_RCU
6456
6557void __rcu_read_lock (void );
6658void __rcu_read_unlock (void );
67- void synchronize_rcu (void );
6859
6960/*
7061 * Defined as a macro as it is a very low level header included from
@@ -88,11 +79,6 @@ static inline void __rcu_read_unlock(void)
8879 preempt_enable ();
8980}
9081
91- static inline void synchronize_rcu (void )
92- {
93- synchronize_sched ();
94- }
95-
9682static inline int rcu_preempt_depth (void )
9783{
9884 return 0 ;
@@ -103,8 +89,6 @@ static inline int rcu_preempt_depth(void)
10389/* Internal to kernel */
10490void rcu_init (void );
10591extern int rcu_scheduler_active __read_mostly ;
106- void rcu_sched_qs (void );
107- void rcu_bh_qs (void );
10892void rcu_check_callbacks (int user );
10993void rcu_report_dead (unsigned int cpu );
11094void rcutree_migrate_callbacks (int cpu );
@@ -135,11 +119,10 @@ static inline void rcu_init_nohz(void) { }
135119 * RCU_NONIDLE - Indicate idle-loop code that needs RCU readers
136120 * @a: Code that RCU needs to pay attention to.
137121 *
138- * RCU, RCU-bh, and RCU-sched read-side critical sections are forbidden
139- * in the inner idle loop, that is, between the rcu_idle_enter() and
140- * the rcu_idle_exit() -- RCU will happily ignore any such read-side
141- * critical sections. However, things like powertop need tracepoints
142- * in the inner idle loop.
122+ * RCU read-side critical sections are forbidden in the inner idle loop,
123+ * that is, between the rcu_idle_enter() and the rcu_idle_exit() -- RCU
124+ * will happily ignore any such read-side critical sections. However,
125+ * things like powertop need tracepoints in the inner idle loop.
143126 *
144127 * This macro provides the way out: RCU_NONIDLE(do_something_with_RCU())
145128 * will tell RCU that it needs to pay attention, invoke its argument
@@ -167,20 +150,16 @@ static inline void rcu_init_nohz(void) { }
167150 if (READ_ONCE((t)->rcu_tasks_holdout)) \
168151 WRITE_ONCE((t)->rcu_tasks_holdout, false); \
169152 } while (0)
170- #define rcu_note_voluntary_context_switch (t ) \
171- do { \
172- rcu_all_qs(); \
173- rcu_tasks_qs(t); \
174- } while (0)
153+ #define rcu_note_voluntary_context_switch (t ) rcu_tasks_qs(t)
175154void call_rcu_tasks (struct rcu_head * head , rcu_callback_t func );
176155void synchronize_rcu_tasks (void );
177156void exit_tasks_rcu_start (void );
178157void exit_tasks_rcu_finish (void );
179158#else /* #ifdef CONFIG_TASKS_RCU */
180159#define rcu_tasks_qs (t ) do { } while (0)
181- #define rcu_note_voluntary_context_switch (t ) rcu_all_qs( )
182- #define call_rcu_tasks call_rcu_sched
183- #define synchronize_rcu_tasks synchronize_sched
160+ #define rcu_note_voluntary_context_switch (t ) do { } while (0 )
161+ #define call_rcu_tasks call_rcu
162+ #define synchronize_rcu_tasks synchronize_rcu
184163static inline void exit_tasks_rcu_start (void ) { }
185164static inline void exit_tasks_rcu_finish (void ) { }
186165#endif /* #else #ifdef CONFIG_TASKS_RCU */
@@ -325,9 +304,8 @@ static inline void rcu_preempt_sleep_check(void) { }
325304 * Helper functions for rcu_dereference_check(), rcu_dereference_protected()
326305 * and rcu_assign_pointer(). Some of these could be folded into their
327306 * callers, but they are left separate in order to ease introduction of
328- * multiple flavors of pointers to match the multiple flavors of RCU
329- * (e.g., __rcu_bh, * __rcu_sched, and __srcu), should this make sense in
330- * the future.
307+ * multiple pointers markings to match different RCU implementations
308+ * (e.g., __srcu), should this make sense in the future.
331309 */
332310
333311#ifdef __CHECKER__
@@ -686,14 +664,9 @@ static inline void rcu_read_unlock(void)
686664/**
687665 * rcu_read_lock_bh() - mark the beginning of an RCU-bh critical section
688666 *
689- * This is equivalent of rcu_read_lock(), but to be used when updates
690- * are being done using call_rcu_bh() or synchronize_rcu_bh(). Since
691- * both call_rcu_bh() and synchronize_rcu_bh() consider completion of a
692- * softirq handler to be a quiescent state, a process in RCU read-side
693- * critical section must be protected by disabling softirqs. Read-side
694- * critical sections in interrupt context can use just rcu_read_lock(),
695- * though this should at least be commented to avoid confusing people
696- * reading the code.
667+ * This is equivalent of rcu_read_lock(), but also disables softirqs.
668+ * Note that anything else that disables softirqs can also serve as
669+ * an RCU read-side critical section.
697670 *
698671 * Note that rcu_read_lock_bh() and the matching rcu_read_unlock_bh()
699672 * must occur in the same context, for example, it is illegal to invoke
@@ -726,10 +699,9 @@ static inline void rcu_read_unlock_bh(void)
726699/**
727700 * rcu_read_lock_sched() - mark the beginning of a RCU-sched critical section
728701 *
729- * This is equivalent of rcu_read_lock(), but to be used when updates
730- * are being done using call_rcu_sched() or synchronize_rcu_sched().
731- * Read-side critical sections can also be introduced by anything that
732- * disables preemption, including local_irq_disable() and friends.
702+ * This is equivalent of rcu_read_lock(), but disables preemption.
703+ * Read-side critical sections can also be introduced by anything else
704+ * that disables preemption, including local_irq_disable() and friends.
733705 *
734706 * Note that rcu_read_lock_sched() and the matching rcu_read_unlock_sched()
735707 * must occur in the same context, for example, it is illegal to invoke
@@ -885,4 +857,96 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
885857#endif /* #else #ifdef CONFIG_ARCH_WEAK_RELEASE_ACQUIRE */
886858
887859
860+ /* Has the specified rcu_head structure been handed to call_rcu()? */
861+
862+ /*
863+ * rcu_head_init - Initialize rcu_head for rcu_head_after_call_rcu()
864+ * @rhp: The rcu_head structure to initialize.
865+ *
866+ * If you intend to invoke rcu_head_after_call_rcu() to test whether a
867+ * given rcu_head structure has already been passed to call_rcu(), then
868+ * you must also invoke this rcu_head_init() function on it just after
869+ * allocating that structure. Calls to this function must not race with
870+ * calls to call_rcu(), rcu_head_after_call_rcu(), or callback invocation.
871+ */
872+ static inline void rcu_head_init (struct rcu_head * rhp )
873+ {
874+ rhp -> func = (rcu_callback_t )~0L ;
875+ }
876+
877+ /*
878+ * rcu_head_after_call_rcu - Has this rcu_head been passed to call_rcu()?
879+ * @rhp: The rcu_head structure to test.
880+ * @func: The function passed to call_rcu() along with @rhp.
881+ *
882+ * Returns @true if the @rhp has been passed to call_rcu() with @func,
883+ * and @false otherwise. Emits a warning in any other case, including
884+ * the case where @rhp has already been invoked after a grace period.
885+ * Calls to this function must not race with callback invocation. One way
886+ * to avoid such races is to enclose the call to rcu_head_after_call_rcu()
887+ * in an RCU read-side critical section that includes a read-side fetch
888+ * of the pointer to the structure containing @rhp.
889+ */
890+ static inline bool
891+ rcu_head_after_call_rcu (struct rcu_head * rhp , rcu_callback_t f )
892+ {
893+ if (READ_ONCE (rhp -> func ) == f )
894+ return true;
895+ WARN_ON_ONCE (READ_ONCE (rhp -> func ) != (rcu_callback_t )~0L );
896+ return false;
897+ }
898+
899+
900+ /* Transitional pre-consolidation compatibility definitions. */
901+
902+ static inline void synchronize_rcu_bh (void )
903+ {
904+ synchronize_rcu ();
905+ }
906+
907+ static inline void synchronize_rcu_bh_expedited (void )
908+ {
909+ synchronize_rcu_expedited ();
910+ }
911+
912+ static inline void call_rcu_bh (struct rcu_head * head , rcu_callback_t func )
913+ {
914+ call_rcu (head , func );
915+ }
916+
917+ static inline void rcu_barrier_bh (void )
918+ {
919+ rcu_barrier ();
920+ }
921+
922+ static inline void synchronize_sched (void )
923+ {
924+ synchronize_rcu ();
925+ }
926+
927+ static inline void synchronize_sched_expedited (void )
928+ {
929+ synchronize_rcu_expedited ();
930+ }
931+
932+ static inline void call_rcu_sched (struct rcu_head * head , rcu_callback_t func )
933+ {
934+ call_rcu (head , func );
935+ }
936+
937+ static inline void rcu_barrier_sched (void )
938+ {
939+ rcu_barrier ();
940+ }
941+
942+ static inline unsigned long get_state_synchronize_sched (void )
943+ {
944+ return get_state_synchronize_rcu ();
945+ }
946+
947+ static inline void cond_synchronize_sched (unsigned long oldstate )
948+ {
949+ cond_synchronize_rcu (oldstate );
950+ }
951+
888952#endif /* __LINUX_RCUPDATE_H */
0 commit comments