Skip to content

Commit b56ada1

Browse files
committed
Merge branches 'doc.2018.08.30a', 'dynticks.2018.08.30b', 'srcu.2018.08.30b' and 'torture.2018.08.29a' into HEAD
doc.2018.08.30a: Documentation updates dynticks.2018.08.30b: RCU flavor consolidation updates and cleanups srcu.2018.08.30b: SRCU updates torture.2018.08.29a: Torture-test updates
4 parents 5c3f78e + 894d45b + 4e6ea4e + 7c590fc commit b56ada1

35 files changed

Lines changed: 2214 additions & 2594 deletions

‎Documentation/RCU/Design/Requirements/Requirements.html‎

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,30 +2398,9 @@ <h3><a name="Scheduler and RCU">Scheduler and RCU</a></h3>
23982398
<p>
23992399
RCU depends on the scheduler, and the scheduler uses RCU to
24002400
protect some of its data structures.
2401-
This means the scheduler is forbidden from acquiring
2402-
the runqueue locks and the priority-inheritance locks
2403-
in the middle of an outermost RCU read-side critical section unless either
2404-
(1)&nbsp;it releases them before exiting that same
2405-
RCU read-side critical section, or
2406-
(2)&nbsp;interrupts are disabled across
2407-
that entire RCU read-side critical section.
2408-
This same prohibition also applies (recursively!) to any lock that is acquired
2409-
while holding any lock to which this prohibition applies.
2410-
Adhering to this rule prevents preemptible RCU from invoking
2411-
<tt>rcu_read_unlock_special()</tt> while either runqueue or
2412-
priority-inheritance locks are held, thus avoiding deadlock.
2413-
2414-
<p>
2415-
Prior to v4.4, it was only necessary to disable preemption across
2416-
RCU read-side critical sections that acquired scheduler locks.
2417-
In v4.4, expedited grace periods started using IPIs, and these
2418-
IPIs could force a <tt>rcu_read_unlock()</tt> to take the slowpath.
2419-
Therefore, this expedited-grace-period change required disabling of
2420-
interrupts, not just preemption.
2421-
2422-
<p>
2423-
For RCU's part, the preemptible-RCU <tt>rcu_read_unlock()</tt>
2424-
implementation must be written carefully to avoid similar deadlocks.
2401+
The preemptible-RCU <tt>rcu_read_unlock()</tt>
2402+
implementation must therefore be written carefully to avoid deadlocks
2403+
involving the scheduler's runqueue and priority-inheritance locks.
24252404
In particular, <tt>rcu_read_unlock()</tt> must tolerate an
24262405
interrupt where the interrupt handler invokes both
24272406
<tt>rcu_read_lock()</tt> and <tt>rcu_read_unlock()</tt>.
@@ -2430,7 +2409,7 @@ <h3><a name="Scheduler and RCU">Scheduler and RCU</a></h3>
24302409
interrupt handler's use of RCU.
24312410

24322411
<p>
2433-
This pair of mutual scheduler-RCU requirements came as a
2412+
This scheduler-RCU requirement came as a
24342413
<a href="https://lwn.net/Articles/453002/">complete surprise</a>.
24352414

24362415
<p>
@@ -2441,9 +2420,28 @@ <h3><a name="Scheduler and RCU">Scheduler and RCU</a></h3>
24412420
<tt>CONFIG_NO_HZ_FULL=y</tt>
24422421
<a href="http://www.rdrop.com/users/paulmck/scalability/paper/BareMetal.2015.01.15b.pdf">did come as a surprise [PDF]</a>.
24432422
RCU has made good progress towards meeting this requirement, even
2444-
for context-switch-have <tt>CONFIG_NO_HZ_FULL=y</tt> workloads,
2423+
for context-switch-heavy <tt>CONFIG_NO_HZ_FULL=y</tt> workloads,
24452424
but there is room for further improvement.
24462425

2426+
<p>
2427+
In the past, it was forbidden to disable interrupts across an
2428+
<tt>rcu_read_unlock()</tt> unless that interrupt-disabled region
2429+
of code also included the matching <tt>rcu_read_lock()</tt>.
2430+
Violating this restriction could result in deadlocks involving the
2431+
scheduler's runqueue and priority-inheritance spinlocks.
2432+
This restriction was lifted when interrupt-disabled calls to
2433+
<tt>rcu_read_unlock()</tt> started deferring the reporting of
2434+
the resulting RCU-preempt quiescent state until the end of that
2435+
interrupts-disabled region.
2436+
This deferred reporting means that the scheduler's runqueue and
2437+
priority-inheritance locks cannot be held while reporting an RCU-preempt
2438+
quiescent state, which lifts the earlier restriction, at least from
2439+
a deadlock perspective.
2440+
Unfortunately, real-time systems using RCU priority boosting may
2441+
need this restriction to remain in effect because deferred
2442+
quiescent-state reporting also defers deboosting, which in turn
2443+
degrades real-time latencies.
2444+
24472445
<h3><a name="Tracing and RCU">Tracing and RCU</a></h3>
24482446

24492447
<p>

‎Documentation/admin-guide/kernel-parameters.txt‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,7 +3595,14 @@
35953595
Set required age in jiffies for a
35963596
given grace period before RCU starts
35973597
soliciting quiescent-state help from
3598-
rcu_note_context_switch().
3598+
rcu_note_context_switch(). If not specified, the
3599+
kernel will calculate a value based on the most
3600+
recent settings of rcutree.jiffies_till_first_fqs
3601+
and rcutree.jiffies_till_next_fqs.
3602+
This calculated value may be viewed in
3603+
rcutree.jiffies_to_sched_qs. Any attempt to
3604+
set rcutree.jiffies_to_sched_qs will be
3605+
cheerfully overwritten.
35993606

36003607
rcutree.jiffies_till_first_fqs= [KNL]
36013608
Set delay from grace-period initialization to
@@ -3863,12 +3870,6 @@
38633870
rcupdate.rcu_self_test= [KNL]
38643871
Run the RCU early boot self tests
38653872

3866-
rcupdate.rcu_self_test_bh= [KNL]
3867-
Run the RCU bh early boot self tests
3868-
3869-
rcupdate.rcu_self_test_sched= [KNL]
3870-
Run the RCU sched early boot self tests
3871-
38723873
rdinit= [KNL]
38733874
Format: <full_path>
38743875
Run specified binary instead of /init from the ramdisk,

‎include/linux/rculist.h‎

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static inline void list_replace_rcu(struct list_head *old,
182182
* @list: the RCU-protected list to splice
183183
* @prev: points to the last element of the existing list
184184
* @next: points to the first element of the existing list
185-
* @sync: function to sync: synchronize_rcu(), synchronize_sched(), ...
185+
* @sync: synchronize_rcu, synchronize_rcu_expedited, ...
186186
*
187187
* The list pointed to by @prev and @next can be RCU-read traversed
188188
* concurrently with this function.
@@ -240,7 +240,7 @@ static inline void __list_splice_init_rcu(struct list_head *list,
240240
* designed for stacks.
241241
* @list: the RCU-protected list to splice
242242
* @head: the place in the existing list to splice the first list into
243-
* @sync: function to sync: synchronize_rcu(), synchronize_sched(), ...
243+
* @sync: synchronize_rcu, synchronize_rcu_expedited, ...
244244
*/
245245
static inline void list_splice_init_rcu(struct list_head *list,
246246
struct list_head *head,
@@ -255,7 +255,7 @@ static inline void list_splice_init_rcu(struct list_head *list,
255255
* list, designed for queues.
256256
* @list: the RCU-protected list to splice
257257
* @head: the place in the existing list to splice the first list into
258-
* @sync: function to sync: synchronize_rcu(), synchronize_sched(), ...
258+
* @sync: synchronize_rcu, synchronize_rcu_expedited, ...
259259
*/
260260
static inline void list_splice_tail_init_rcu(struct list_head *list,
261261
struct list_head *head,
@@ -359,13 +359,12 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,
359359
* @type: the type of the struct this is embedded in.
360360
* @member: the name of the list_head within the struct.
361361
*
362-
* This primitive may safely run concurrently with the _rcu list-mutation
363-
* primitives such as list_add_rcu(), but requires some implicit RCU
364-
* read-side guarding. One example is running within a special
365-
* exception-time environment where preemption is disabled and where
366-
* lockdep cannot be invoked (in which case updaters must use RCU-sched,
367-
* as in synchronize_sched(), call_rcu_sched(), and friends). Another
368-
* example is when items are added to the list, but never deleted.
362+
* This primitive may safely run concurrently with the _rcu
363+
* list-mutation primitives such as list_add_rcu(), but requires some
364+
* implicit RCU read-side guarding. One example is running within a special
365+
* exception-time environment where preemption is disabled and where lockdep
366+
* cannot be invoked. Another example is when items are added to the list,
367+
* but never deleted.
369368
*/
370369
#define list_entry_lockless(ptr, type, member) \
371370
container_of((typeof(ptr))READ_ONCE(ptr), type, member)
@@ -376,13 +375,12 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,
376375
* @head: the head for your list.
377376
* @member: the name of the list_struct within the struct.
378377
*
379-
* This primitive may safely run concurrently with the _rcu list-mutation
380-
* primitives such as list_add_rcu(), but requires some implicit RCU
381-
* read-side guarding. One example is running within a special
382-
* exception-time environment where preemption is disabled and where
383-
* lockdep cannot be invoked (in which case updaters must use RCU-sched,
384-
* as in synchronize_sched(), call_rcu_sched(), and friends). Another
385-
* example is when items are added to the list, but never deleted.
378+
* This primitive may safely run concurrently with the _rcu
379+
* list-mutation primitives such as list_add_rcu(), but requires some
380+
* implicit RCU read-side guarding. One example is running within a special
381+
* exception-time environment where preemption is disabled and where lockdep
382+
* cannot be invoked. Another example is when items are added to the list,
383+
* but never deleted.
386384
*/
387385
#define list_for_each_entry_lockless(pos, head, member) \
388386
for (pos = list_entry_lockless((head)->next, typeof(*pos), member); \

‎include/linux/rcupdate.h‎

Lines changed: 109 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,14 @@
4848
#define ulong2long(a) (*(long *)(&(a)))
4949

5050
/* Exported common interfaces */
51-
52-
#ifdef CONFIG_PREEMPT_RCU
5351
void 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);
6152
void rcu_barrier_tasks(void);
53+
void synchronize_rcu(void);
6254

6355
#ifdef CONFIG_PREEMPT_RCU
6456

6557
void __rcu_read_lock(void);
6658
void __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-
9682
static 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 */
10490
void rcu_init(void);
10591
extern int rcu_scheduler_active __read_mostly;
106-
void rcu_sched_qs(void);
107-
void rcu_bh_qs(void);
10892
void rcu_check_callbacks(int user);
10993
void rcu_report_dead(unsigned int cpu);
11094
void 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)
175154
void call_rcu_tasks(struct rcu_head *head, rcu_callback_t func);
176155
void synchronize_rcu_tasks(void);
177156
void exit_tasks_rcu_start(void);
178157
void 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
184163
static inline void exit_tasks_rcu_start(void) { }
185164
static 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

Comments
 (0)