History

Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull RCU updates from Ingo Molnar: "The main changes in this cycle were: - Make kfree_rcu() use kfree_bulk() for added performance - RCU updates - Callback-overload handling updates - Tasks-RCU KCSAN and sparse updates - Locking torture test and RCU torture test updates - Documentation updates - Miscellaneous fixes" * 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (74 commits) rcu: Make rcu_barrier() account for offline no-CBs CPUs rcu: Mark rcu_state.gp_seq to detect concurrent writes Documentation/memory-barriers: Fix typos doc: Add rcutorture scripting to torture.txt doc/RCU/rcu: Use https instead of http if possible doc/RCU/rcu: Use absolute paths for non-rst files doc/RCU/rcu: Use ':ref:' for links to other docs doc/RCU/listRCU: Update example function name doc/RCU/listRCU: Fix typos in a example code snippets doc/RCU/Design: Remove remaining HTML tags in ReST files doc: Add some more RCU list patterns in the kernel rcutorture: Set KCSAN Kconfig options to detect more data races rcutorture: Manually clean up after rcu_barrier() failure rcutorture: Make rcu_torture_barrier_cbs() post from corresponding CPU rcuperf: Measure memory footprint during kfree_rcu() test rcutorture: Annotation lockless accesses to rcu_torture_current rcutorture: Add READ_ONCE() to rcu_torture_count and rcu_torture_batch rcutorture: Fix stray access to rcu_fwd_cb_nodelay rcutorture: Fix rcu_torture_one_read()/rcu_torture_writer() data race rcutorture: Make kvm-find-errors.sh abort on bad directory ...

Linus Torvalds committed 6 years ago

Commit 7c4fa152 parents d937a6d baf5fe734 files · +1015 −294Browse files

Unified · Split

34 files
  1. Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst +4 −4
  2. Documentation/RCU/listRCU.rst +214 −67
  3. Documentation/RCU/rcu.rst +9 −9
  4. Documentation/RCU/torture.txt +140 −7
  5. Documentation/admin-guide/kernel-parameters.txt +19 −0
  6. Documentation/memory-barriers.txt +4 −4
  7. fs/nfs/dir.c +1 −1
  8. include/linux/rculist.h +2 −2
  9. include/linux/rcutiny.h +1 −0
  10. include/linux/rcutree.h +1 −0
  11. include/linux/timer.h +1 −1
  12. include/trace/events/rcu.h +29 −0
  13. kernel/locking/locktorture.c +8 −7
  14. kernel/locking/rtmutex.c +1 −1
  15. kernel/rcu/Makefile +4 −0
  16. kernel/rcu/rcu.h +21 −2
  17. kernel/rcu/rcu_segcblist.c +1 −3
  18. kernel/rcu/rcuperf.c +12 −2
  19. kernel/rcu/rcutorture.c +50 −17
  20. kernel/rcu/srcutree.c +10 −8
  21. kernel/rcu/tree.c +339 −113
  22. kernel/rcu/tree.h +4 −0
  23. kernel/rcu/tree_exp.h +9 −4
  24. kernel/rcu/tree_plugin.h +16 −9
  25. kernel/rcu/tree_stall.h +23 −18
  26. kernel/rcu/update.c +23 −5
  27. kernel/time/timer.c +4 −3
  28. kernel/torture.c +25 −4
  29. tools/testing/selftests/rcutorture/bin/functions.sh +1 −1
  30. tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh +2 −0
  31. tools/testing/selftests/rcutorture/bin/kvm-recheck.sh +16 −1
  32. tools/testing/selftests/rcutorture/bin/kvm.sh +1 −1
  33. tools/testing/selftests/rcutorture/configs/rcu/CFcommon +2 −0
  34. tools/testing/selftests/rcutorture/configs/rcu/TREE10 +18 −0
Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst+4−4
@@ -4,7 +4,7 @@ A Tour Through TREE_RCU's Grace-Period Memory Ordering · 3 unmodified lines
4 4
5August 8, 20175August 8, 2017
6 6
7This article was contributed by Paul E. McKenney7This article was contributed by Paul E. McKenney
8 8
9Introduction9Introduction
10============10============
@@ -48,7 +48,7 @@ Tree RCU Grace Period Memory Ordering Building Blocks · 37 unmodified lines
48 48
49The workhorse for RCU's grace-period memory ordering is the49The workhorse for RCU's grace-period memory ordering is the
50critical section for the ``rcu_node`` structure's50critical section for the ``rcu_node`` structure's
51``->lock``. These critical sections use helper functions for lock51``->lock``. These critical sections use helper functions for lock
52acquisition, including ``raw_spin_lock_rcu_node()``,52acquisition, including ``raw_spin_lock_rcu_node()``,
53``raw_spin_lock_irq_rcu_node()``, and ``raw_spin_lock_irqsave_rcu_node()``.53``raw_spin_lock_irq_rcu_node()``, and ``raw_spin_lock_irqsave_rcu_node()``.
54Their lock-release counterparts are ``raw_spin_unlock_rcu_node()``,54Their lock-release counterparts are ``raw_spin_unlock_rcu_node()``,
@@ -102,9 +102,9 @@ lock-acquisition and lock-release functions:: · 47 unmodified lines
102 23 r3 = READ_ONCE(x);102 23 r3 = READ_ONCE(x);
103 24 }103 24 }
104 25104 25
105 26 WARN_ON(r1 == 0 && r2 == 0 && r3 == 0);105 26 WARN_ON(r1 == 0 && r2 == 0 && r3 == 0);
106 106
107The ``WARN_ON()`` is evaluated at “the end of time”,107The ``WARN_ON()`` is evaluated at "the end of time",
108after all changes have propagated throughout the system.108after all changes have propagated throughout the system.
109Without the ``smp_mb__after_unlock_lock()`` provided by the109Without the ``smp_mb__after_unlock_lock()`` provided by the
110acquisition functions, this ``WARN_ON()`` could trigger, for example110acquisition functions, this ``WARN_ON()`` could trigger, for example
Documentation/RCU/listRCU.rst+214−67
@@ -4,12 +4,61 @@ Using RCU to Protect Read-Mostly Linked Lists · 3 unmodified lines
4=============================================4=============================================
5 5
6One of the best applications of RCU is to protect read-mostly linked lists6One of the best applications of RCU is to protect read-mostly linked lists
7("struct list_head" in list.h). One big advantage of this approach7(``struct list_head`` in list.h). One big advantage of this approach
8is that all of the required memory barriers are included for you in8is that all of the required memory barriers are included for you in
9the list macros. This document describes several applications of RCU,9the list macros. This document describes several applications of RCU,
10with the best fits first.10with the best fits first.
11 11
12Example 1: Read-Side Action Taken Outside of Lock, No In-Place Updates12
13Example 1: Read-mostly list: Deferred Destruction
14-------------------------------------------------
15
16A widely used usecase for RCU lists in the kernel is lockless iteration over
17all processes in the system. ``task_struct::tasks`` represents the list node that
18links all the processes. The list can be traversed in parallel to any list
19additions or removals.
20
21The traversal of the list is done using ``for_each_process()`` which is defined
22by the 2 macros::
23
24 #define next_task(p) \
25 list_entry_rcu((p)->tasks.next, struct task_struct, tasks)
26
27 #define for_each_process(p) \
28 for (p = &init_task ; (p = next_task(p)) != &init_task ; )
29
30The code traversing the list of all processes typically looks like::
31
32 rcu_read_lock();
33 for_each_process(p) {
34 /* Do something with p */
35 }
36 rcu_read_unlock();
37
38The simplified code for removing a process from a task list is::
39
40 void release_task(struct task_struct *p)
41 {
42 write_lock(&tasklist_lock);
43 list_del_rcu(&p->tasks);
44 write_unlock(&tasklist_lock);
45 call_rcu(&p->rcu, delayed_put_task_struct);
46 }
47
48When a process exits, ``release_task()`` calls ``list_del_rcu(&p->tasks)`` under
49``tasklist_lock`` writer lock protection, to remove the task from the list of
50all tasks. The ``tasklist_lock`` prevents concurrent list additions/removals
51from corrupting the list. Readers using ``for_each_process()`` are not protected
52with the ``tasklist_lock``. To prevent readers from noticing changes in the list
53pointers, the ``task_struct`` object is freed only after one or more grace
54periods elapse (with the help of call_rcu()). This deferring of destruction
55ensures that any readers traversing the list will see valid ``p->tasks.next``
56pointers and deletion/freeing can happen in parallel with traversal of the list.
57This pattern is also called an **existence lock**, since RCU pins the object in
58memory until all existing readers finish.
59
60
61Example 2: Read-Side Action Taken Outside of Lock: No In-Place Updates
13----------------------------------------------------------------------62----------------------------------------------------------------------
14 63
15The best applications are cases where, if reader-writer locking were64The best applications are cases where, if reader-writer locking were
@@ -26,7 +75,7 @@ added or deleted, rather than being modified in place. · 10 unmodified lines
26 75
27A straightforward example of this use of RCU may be found in the76A straightforward example of this use of RCU may be found in the
28system-call auditing support. For example, a reader-writer locked77system-call auditing support. For example, a reader-writer locked
29implementation of audit_filter_task() might be as follows::78implementation of ``audit_filter_task()`` might be as follows::
30 79
31 static enum audit_state audit_filter_task(struct task_struct *tsk)80 static enum audit_state audit_filter_task(struct task_struct *tsk)
32 {81 {
@@ -34,7 +83,7 @@ implementation of audit_filter_task() might be as follows:: · 1 unmodified line
34 enum audit_state state;83 enum audit_state state;
35 84
36 read_lock(&auditsc_lock);85 read_lock(&auditsc_lock);
37 /* Note: audit_netlink_sem held by caller. */86 /* Note: audit_filter_mutex held by caller. */
38 list_for_each_entry(e, &audit_tsklist, list) {87 list_for_each_entry(e, &audit_tsklist, list) {
39 if (audit_filter_rules(tsk, &e->rule, NULL, &state)) {88 if (audit_filter_rules(tsk, &e->rule, NULL, &state)) {
40 read_unlock(&auditsc_lock);89 read_unlock(&auditsc_lock);
@@ -58,7 +107,7 @@ This means that RCU can be easily applied to the read side, as follows:: · 17 unmodified lines
58 enum audit_state state;107 enum audit_state state;
59 108
60 rcu_read_lock();109 rcu_read_lock();
61 /* Note: audit_netlink_sem held by caller. */110 /* Note: audit_filter_mutex held by caller. */
62 list_for_each_entry_rcu(e, &audit_tsklist, list) {111 list_for_each_entry_rcu(e, &audit_tsklist, list) {
63 if (audit_filter_rules(tsk, &e->rule, NULL, &state)) {112 if (audit_filter_rules(tsk, &e->rule, NULL, &state)) {
64 rcu_read_unlock();113 rcu_read_unlock();
@@ -69,18 +118,18 @@ This means that RCU can be easily applied to the read side, as follows:: · 4 unmodified lines
69 return AUDIT_BUILD_CONTEXT;118 return AUDIT_BUILD_CONTEXT;
70 }119 }
71 120
72The read_lock() and read_unlock() calls have become rcu_read_lock()121The ``read_lock()`` and ``read_unlock()`` calls have become rcu_read_lock()
73and rcu_read_unlock(), respectively, and the list_for_each_entry() has122and rcu_read_unlock(), respectively, and the list_for_each_entry() has
74become list_for_each_entry_rcu(). The _rcu() list-traversal primitives123become list_for_each_entry_rcu(). The **_rcu()** list-traversal primitives
75insert the read-side memory barriers that are required on DEC Alpha CPUs.124insert the read-side memory barriers that are required on DEC Alpha CPUs.
76 125
77The changes to the update side are also straightforward. A reader-writer126The changes to the update side are also straightforward. A reader-writer lock
78lock might be used as follows for deletion and insertion::127might be used as follows for deletion and insertion::
79 128
80 static inline int audit_del_rule(struct audit_rule *rule,129 static inline int audit_del_rule(struct audit_rule *rule,
81 struct list_head *list)130 struct list_head *list)
82 {131 {
83 struct audit_entry *e;132 struct audit_entry *e;
84 133
85 write_lock(&auditsc_lock);134 write_lock(&auditsc_lock);
86 list_for_each_entry(e, list, list) {135 list_for_each_entry(e, list, list) {
@@ -113,9 +162,9 @@ Following are the RCU equivalents for these two functions:: · 26 unmodified lines
113 static inline int audit_del_rule(struct audit_rule *rule,162 static inline int audit_del_rule(struct audit_rule *rule,
114 struct list_head *list)163 struct list_head *list)
115 {164 {
116 struct audit_entry *e;165 struct audit_entry *e;
117 166
118 /* Do not use the _rcu iterator here, since this is the only167 /* No need to use the _rcu iterator here, since this is the only
119 * deletion routine. */168 * deletion routine. */
120 list_for_each_entry(e, list, list) {169 list_for_each_entry(e, list, list) {
121 if (!audit_compare_rule(rule, &e->rule)) {170 if (!audit_compare_rule(rule, &e->rule)) {
@@ -139,45 +188,45 @@ Following are the RCU equivalents for these two functions:: · 17 unmodified lines
139 return 0;188 return 0;
140 }189 }
141 190
142Normally, the write_lock() and write_unlock() would be replaced by191Normally, the ``write_lock()`` and ``write_unlock()`` would be replaced by a
143a spin_lock() and a spin_unlock(), but in this case, all callers hold192spin_lock() and a spin_unlock(). But in this case, all callers hold
144audit_netlink_sem, so no additional locking is required. The auditsc_lock193``audit_filter_mutex``, so no additional locking is required. The
145can therefore be eliminated, since use of RCU eliminates the need for194``auditsc_lock`` can therefore be eliminated, since use of RCU eliminates the
146writers to exclude readers. Normally, the write_lock() calls would195need for writers to exclude readers.
147be converted into spin_lock() calls.
148 196
149The list_del(), list_add(), and list_add_tail() primitives have been197The list_del(), list_add(), and list_add_tail() primitives have been
150replaced by list_del_rcu(), list_add_rcu(), and list_add_tail_rcu().198replaced by list_del_rcu(), list_add_rcu(), and list_add_tail_rcu().
151The _rcu() list-manipulation primitives add memory barriers that are199The **_rcu()** list-manipulation primitives add memory barriers that are needed on
152needed on weakly ordered CPUs (most of them!). The list_del_rcu()200weakly ordered CPUs (most of them!). The list_del_rcu() primitive omits the
153primitive omits the pointer poisoning debug-assist code that would201pointer poisoning debug-assist code that would otherwise cause concurrent
154otherwise cause concurrent readers to fail spectacularly.202readers to fail spectacularly.
155 203
156So, when readers can tolerate stale data and when entries are either added204So, when readers can tolerate stale data and when entries are either added or
157or deleted, without in-place modification, it is very easy to use RCU!205deleted, without in-place modification, it is very easy to use RCU!
158 206
159Example 2: Handling In-Place Updates207
208Example 3: Handling In-Place Updates
160------------------------------------209------------------------------------
161 210
162The system-call auditing code does not update auditing rules in place.211The system-call auditing code does not update auditing rules in place. However,
163However, if it did, reader-writer-locked code to do so might look as212if it did, the reader-writer-locked code to do so might look as follows
164follows (presumably, the field_count is only permitted to decrease,213(assuming only ``field_count`` is updated, otherwise, the added fields would
165otherwise, the added fields would need to be filled in)::214need to be filled in)::
166 215
167 static inline int audit_upd_rule(struct audit_rule *rule,216 static inline int audit_upd_rule(struct audit_rule *rule,
168 struct list_head *list,217 struct list_head *list,
169 __u32 newaction,218 __u32 newaction,
170 __u32 newfield_count)219 __u32 newfield_count)
171 {220 {
172 struct audit_entry *e;221 struct audit_entry *e;
173 struct audit_newentry *ne;222 struct audit_entry *ne;
174 223
175 write_lock(&auditsc_lock);224 write_lock(&auditsc_lock);
176 /* Note: audit_netlink_sem held by caller. */225 /* Note: audit_filter_mutex held by caller. */
177 list_for_each_entry(e, list, list) {226 list_for_each_entry(e, list, list) {
178 if (!audit_compare_rule(rule, &e->rule)) {227 if (!audit_compare_rule(rule, &e->rule)) {
179 e->rule.action = newaction;228 e->rule.action = newaction;
180 e->rule.file_count = newfield_count;229 e->rule.field_count = newfield_count;
181 write_unlock(&auditsc_lock);230 write_unlock(&auditsc_lock);
182 return 0;231 return 0;
183 }232 }
@@ -188,16 +237,16 @@ otherwise, the added fields would need to be filled in):: · 4 unmodified lines
188 237
189The RCU version creates a copy, updates the copy, then replaces the old238The RCU version creates a copy, updates the copy, then replaces the old
190entry with the newly updated entry. This sequence of actions, allowing239entry with the newly updated entry. This sequence of actions, allowing
191concurrent reads while doing a copy to perform an update, is what gives240concurrent reads while making a copy to perform an update, is what gives
192RCU ("read-copy update") its name. The RCU code is as follows::241RCU (*read-copy update*) its name. The RCU code is as follows::
193 242
194 static inline int audit_upd_rule(struct audit_rule *rule,243 static inline int audit_upd_rule(struct audit_rule *rule,
195 struct list_head *list,244 struct list_head *list,
196 __u32 newaction,245 __u32 newaction,
197 __u32 newfield_count)246 __u32 newfield_count)
198 {247 {
199 struct audit_entry *e;248 struct audit_entry *e;
200 struct audit_newentry *ne;249 struct audit_entry *ne;
201 250
202 list_for_each_entry(e, list, list) {251 list_for_each_entry(e, list, list) {
203 if (!audit_compare_rule(rule, &e->rule)) {252 if (!audit_compare_rule(rule, &e->rule)) {
@@ -206,7 +255,7 @@ RCU ("read-copy update") its name. The RCU code is as follows:: · 2 unmodified lines
206 return -ENOMEM;255 return -ENOMEM;
207 audit_copy_rule(&ne->rule, &e->rule);256 audit_copy_rule(&ne->rule, &e->rule);
208 ne->rule.action = newaction;257 ne->rule.action = newaction;
209 ne->rule.file_count = newfield_count;258 ne->rule.field_count = newfield_count;
210 list_replace_rcu(&e->list, &ne->list);259 list_replace_rcu(&e->list, &ne->list);
211 call_rcu(&e->rcu, audit_free_rule);260 call_rcu(&e->rcu, audit_free_rule);
212 return 0;261 return 0;
@@ -215,34 +264,45 @@ RCU ("read-copy update") its name. The RCU code is as follows:: · 2 unmodified lines
215 return -EFAULT; /* No matching rule */264 return -EFAULT; /* No matching rule */
216 }265 }
217 266
218Again, this assumes that the caller holds audit_netlink_sem. Normally,267Again, this assumes that the caller holds ``audit_filter_mutex``. Normally, the
219the reader-writer lock would become a spinlock in this sort of code.268writer lock would become a spinlock in this sort of code.
220 269
221Example 3: Eliminating Stale Data270Another use of this pattern can be found in the openswitch driver's *connection
271tracking table* code in ``ct_limit_set()``. The table holds connection tracking
272entries and has a limit on the maximum entries. There is one such table
273per-zone and hence one *limit* per zone. The zones are mapped to their limits
274through a hashtable using an RCU-managed hlist for the hash chains. When a new
275limit is set, a new limit object is allocated and ``ct_limit_set()`` is called
276to replace the old limit object with the new one using list_replace_rcu().
277The old limit object is then freed after a grace period using kfree_rcu().
278
279
280Example 4: Eliminating Stale Data
222---------------------------------281---------------------------------
223 282
224The auditing examples above tolerate stale data, as do most algorithms283The auditing example above tolerates stale data, as do most algorithms
225that are tracking external state. Because there is a delay from the284that are tracking external state. Because there is a delay from the
226time the external state changes before Linux becomes aware of the change,285time the external state changes before Linux becomes aware of the change,
227additional RCU-induced staleness is normally not a problem.286additional RCU-induced staleness is generally not a problem.
228 287
229However, there are many examples where stale data cannot be tolerated.288However, there are many examples where stale data cannot be tolerated.
230One example in the Linux kernel is the System V IPC (see the ipc_lock()289One example in the Linux kernel is the System V IPC (see the shm_lock()
231function in ipc/util.c). This code checks a "deleted" flag under a290function in ipc/shm.c). This code checks a *deleted* flag under a
232per-entry spinlock, and, if the "deleted" flag is set, pretends that the291per-entry spinlock, and, if the *deleted* flag is set, pretends that the
233entry does not exist. For this to be helpful, the search function must292entry does not exist. For this to be helpful, the search function must
234return holding the per-entry spinlock, as ipc_lock() does in fact do.293return holding the per-entry spinlock, as shm_lock() does in fact do.
294
295.. _quick_quiz:
235 296
236Quick Quiz:297Quick Quiz:
237 Why does the search function need to return holding the per-entry lock for298 For the deleted-flag technique to be helpful, why is it necessary
238 this deleted-flag technique to be helpful?299 to hold the per-entry lock while returning from the search function?
239 300
240:ref:`Answer to Quick Quiz <answer_quick_quiz_list>`301:ref:`Answer to Quick Quiz <quick_quiz_answer>`
241 302
242If the system-call audit module were to ever need to reject stale data,303If the system-call audit module were to ever need to reject stale data, one way
243one way to accomplish this would be to add a "deleted" flag and a "lock"304to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to the
244spinlock to the audit_entry structure, and modify audit_filter_task()305audit_entry structure, and modify ``audit_filter_task()`` as follows::
245as follows::
246 306
247 static enum audit_state audit_filter_task(struct task_struct *tsk)307 static enum audit_state audit_filter_task(struct task_struct *tsk)
248 {308 {
@@ -267,20 +327,20 @@ as follows:: · 18 unmodified lines
267 }327 }
268 328
269Note that this example assumes that entries are only added and deleted.329Note that this example assumes that entries are only added and deleted.
270Additional mechanism is required to deal correctly with the330Additional mechanism is required to deal correctly with the update-in-place
271update-in-place performed by audit_upd_rule(). For one thing,331performed by ``audit_upd_rule()``. For one thing, ``audit_upd_rule()`` would
272audit_upd_rule() would need additional memory barriers to ensure332need additional memory barriers to ensure that the list_add_rcu() was really
273that the list_add_rcu() was really executed before the list_del_rcu().333executed before the list_del_rcu().
274 334
275The audit_del_rule() function would need to set the "deleted"335The ``audit_del_rule()`` function would need to set the ``deleted`` flag under the
276flag under the spinlock as follows::336spinlock as follows::
277 337
278 static inline int audit_del_rule(struct audit_rule *rule,338 static inline int audit_del_rule(struct audit_rule *rule,
279 struct list_head *list)339 struct list_head *list)
280 {340 {
281 struct audit_entry *e;341 struct audit_entry *e;
282 342
283 /* Do not need to use the _rcu iterator here, since this343 /* No need to use the _rcu iterator here, since this
284 * is the only deletion routine. */344 * is the only deletion routine. */
285 list_for_each_entry(e, list, list) {345 list_for_each_entry(e, list, list) {
286 if (!audit_compare_rule(rule, &e->rule)) {346 if (!audit_compare_rule(rule, &e->rule)) {
@@ -295,6 +355,91 @@ flag under the spinlock as follows:: · 8 unmodified lines
295 return -EFAULT; /* No matching rule */355 return -EFAULT; /* No matching rule */
296 }356 }
297 357
358This too assumes that the caller holds ``audit_filter_mutex``.
359
360
361Example 5: Skipping Stale Objects
362---------------------------------
363
364For some usecases, reader performance can be improved by skipping stale objects
365during read-side list traversal if the object in concern is pending destruction
366after one or more grace periods. One such example can be found in the timerfd
367subsystem. When a ``CLOCK_REALTIME`` clock is reprogrammed - for example due to
368setting of the system time, then all programmed timerfds that depend on this
369clock get triggered and processes waiting on them to expire are woken up in
370advance of their scheduled expiry. To facilitate this, all such timers are added
371to an RCU-managed ``cancel_list`` when they are setup in
372``timerfd_setup_cancel()``::
373
374 static void timerfd_setup_cancel(struct timerfd_ctx *ctx, int flags)
375 {
376 spin_lock(&ctx->cancel_lock);
377 if ((ctx->clockid == CLOCK_REALTIME &&
378 (flags & TFD_TIMER_ABSTIME) && (flags & TFD_TIMER_CANCEL_ON_SET)) {
379 if (!ctx->might_cancel) {
380 ctx->might_cancel = true;
381 spin_lock(&cancel_lock);
382 list_add_rcu(&ctx->clist, &cancel_list);
383 spin_unlock(&cancel_lock);
384 }
385 }
386 spin_unlock(&ctx->cancel_lock);
387 }
388
389When a timerfd is freed (fd is closed), then the ``might_cancel`` flag of the
390timerfd object is cleared, the object removed from the ``cancel_list`` and
391destroyed::
392
393 int timerfd_release(struct inode *inode, struct file *file)
394 {
395 struct timerfd_ctx *ctx = file->private_data;
396
397 spin_lock(&ctx->cancel_lock);
398 if (ctx->might_cancel) {
399 ctx->might_cancel = false;
400 spin_lock(&cancel_lock);
401 list_del_rcu(&ctx->clist);
402 spin_unlock(&cancel_lock);
403 }
404 spin_unlock(&ctx->cancel_lock);
405
406 hrtimer_cancel(&ctx->t.tmr);
407 kfree_rcu(ctx, rcu);
408 return 0;
409 }
410
411If the ``CLOCK_REALTIME`` clock is set, for example by a time server, the
412hrtimer framework calls ``timerfd_clock_was_set()`` which walks the
413``cancel_list`` and wakes up processes waiting on the timerfd. While iterating
414the ``cancel_list``, the ``might_cancel`` flag is consulted to skip stale
415objects::
416
417 void timerfd_clock_was_set(void)
418 {
419 struct timerfd_ctx *ctx;
420 unsigned long flags;
421
422 rcu_read_lock();
423 list_for_each_entry_rcu(ctx, &cancel_list, clist) {
424 if (!ctx->might_cancel)
425 continue;
426 spin_lock_irqsave(&ctx->wqh.lock, flags);
427 if (ctx->moffs != ktime_mono_to_real(0)) {
428 ctx->moffs = KTIME_MAX;
429 ctx->ticks++;
430 wake_up_locked_poll(&ctx->wqh, EPOLLIN);
431 }
432 spin_unlock_irqrestore(&ctx->wqh.lock, flags);
433 }
434 rcu_read_unlock();
435 }
436
437The key point here is, because RCU-traversal of the ``cancel_list`` happens
438while objects are being added and removed to the list, sometimes the traversal
439can step on an object that has been removed from the list. In this example, it
440is seen that it is better to skip such objects using a flag.
441
442
298Summary443Summary
299-------444-------
300 445
@@ -303,19 +448,21 @@ the most amenable to use of RCU. The simplest case is where entries are · 2 unmodified lines
303either added or deleted from the data structure (or atomically modified448either added or deleted from the data structure (or atomically modified
304in place), but non-atomic in-place modifications can be handled by making449in place), but non-atomic in-place modifications can be handled by making
305a copy, updating the copy, then replacing the original with the copy.450a copy, updating the copy, then replacing the original with the copy.
306If stale data cannot be tolerated, then a "deleted" flag may be used451If stale data cannot be tolerated, then a *deleted* flag may be used
307in conjunction with a per-entry spinlock in order to allow the search452in conjunction with a per-entry spinlock in order to allow the search
308function to reject newly deleted data.453function to reject newly deleted data.
309 454
310.. _answer_quick_quiz_list:455.. _quick_quiz_answer:
311 456
312Answer to Quick Quiz:457Answer to Quick Quiz:
313 Why does the search function need to return holding the per-entry458 For the deleted-flag technique to be helpful, why is it necessary
314 lock for this deleted-flag technique to be helpful?459 to hold the per-entry lock while returning from the search function?
315 460
316 If the search function drops the per-entry lock before returning,461 If the search function drops the per-entry lock before returning,
317 then the caller will be processing stale data in any case. If it462 then the caller will be processing stale data in any case. If it
318 is really OK to be processing stale data, then you don't need a463 is really OK to be processing stale data, then you don't need a
319 "deleted" flag. If processing stale data really is a problem,464 *deleted* flag. If processing stale data really is a problem,
320 then you need to hold the per-entry lock across all of the code465 then you need to hold the per-entry lock across all of the code
321 that uses the value that was returned.466 that uses the value that was returned.
467
468:ref:`Back to Quick Quiz <quick_quiz>`
Documentation/RCU/rcu.rst+9−9
@@ -11,8 +11,8 @@ must be long enough that any readers accessing the item being deleted have · 10 unmodified lines
11since dropped their references. For example, an RCU-protected deletion11since dropped their references. For example, an RCU-protected deletion
12from a linked list would first remove the item from the list, wait for12from a linked list would first remove the item from the list, wait for
13a grace period to elapse, then free the element. See the13a grace period to elapse, then free the element. See the
14Documentation/RCU/listRCU.rst file for more information on using RCU with14:ref:`Documentation/RCU/listRCU.rst <list_rcu_doc>` for more information on
15linked lists.15using RCU with linked lists.
16 16
17Frequently Asked Questions17Frequently Asked Questions
18--------------------------18--------------------------
@@ -50,7 +50,7 @@ Frequently Asked Questions · 31 unmodified lines
50- If I am running on a uniprocessor kernel, which can only do one50- If I am running on a uniprocessor kernel, which can only do one
51 thing at a time, why should I wait for a grace period?51 thing at a time, why should I wait for a grace period?
52 52
53 See the Documentation/RCU/UP.rst file for more information.53 See :ref:`Documentation/RCU/UP.rst <up_doc>` for more information.
54 54
55- How can I see where RCU is currently used in the Linux kernel?55- How can I see where RCU is currently used in the Linux kernel?
56 56
@@ -68,18 +68,18 @@ Frequently Asked Questions · 11 unmodified lines
68 68
69- Why the name "RCU"?69- Why the name "RCU"?
70 70
71 "RCU" stands for "read-copy update". The file Documentation/RCU/listRCU.rst71 "RCU" stands for "read-copy update".
72 has more information on where this name came from, search for72 :ref:`Documentation/RCU/listRCU.rst <list_rcu_doc>` has more information on where
73 "read-copy update" to find it.73 this name came from, search for "read-copy update" to find it.
74 74
75- I hear that RCU is patented? What is with that?75- I hear that RCU is patented? What is with that?
76 76
77 Yes, it is. There are several known patents related to RCU,77 Yes, it is. There are several known patents related to RCU,
78 search for the string "Patent" in RTFP.txt to find them.78 search for the string "Patent" in Documentation/RCU/RTFP.txt to find them.
79 Of these, one was allowed to lapse by the assignee, and the79 Of these, one was allowed to lapse by the assignee, and the
80 others have been contributed to the Linux kernel under GPL.80 others have been contributed to the Linux kernel under GPL.
81 There are now also LGPL implementations of user-level RCU81 There are now also LGPL implementations of user-level RCU
82 available (http://liburcu.org/).82 available (https://liburcu.org/).
83 83
84- I hear that RCU needs work in order to support realtime kernels?84- I hear that RCU needs work in order to support realtime kernels?
85 85
@@ -88,5 +88,5 @@ Frequently Asked Questions · 2 unmodified lines
88 88
89- Where can I find more information on RCU?89- Where can I find more information on RCU?
90 90
91 See the RTFP.txt file in this directory.91 See the Documentation/RCU/RTFP.txt file.
92 Or point your browser at (http://www.rdrop.com/users/paulmck/RCU/).92 Or point your browser at (http://www.rdrop.com/users/paulmck/RCU/).
Documentation/RCU/torture.txt+140−7
@@ -124,9 +124,14 @@ using a dynamically allocated srcu_struct (hence "srcud-" rather than · 123 unmodified lines
124debugging. The final "T" entry contains the totals of the counters.124debugging. The final "T" entry contains the totals of the counters.
125 125
126 126
127USAGE127USAGE ON SPECIFIC KERNEL BUILDS
128 128
129The following script may be used to torture RCU:129It is sometimes desirable to torture RCU on a specific kernel build,
130for example, when preparing to put that kernel build into production.
131In that case, the kernel should be built with CONFIG_RCU_TORTURE_TEST=m
132so that the test can be started using modprobe and terminated using rmmod.
133
134For example, the following script may be used to torture RCU:
130 135
131 #!/bin/sh136 #!/bin/sh
132 137
@@ -142,8 +147,136 @@ checked for such errors. The "rmmod" command forces a "SUCCESS", · 9 unmodified lines
142two are self-explanatory, while the last indicates that while there147two are self-explanatory, while the last indicates that while there
143were no RCU failures, CPU-hotplug problems were detected.148were no RCU failures, CPU-hotplug problems were detected.
144 149
145However, the tools/testing/selftests/rcutorture/bin/kvm.sh script150
146provides better automation, including automatic failure analysis.151USAGE ON MAINLINE KERNELS
147It assumes a qemu/kvm-enabled platform, and runs guest OSes out of initrd.152
148See tools/testing/selftests/rcutorture/doc/initrd.txt for instructions153When using rcutorture to test changes to RCU itself, it is often
149on setting up such an initrd.154necessary to build a number of kernels in order to test that change
155across a broad range of combinations of the relevant Kconfig options
156and of the relevant kernel boot parameters. In this situation, use
157of modprobe and rmmod can be quite time-consuming and error-prone.
158
159Therefore, the tools/testing/selftests/rcutorture/bin/kvm.sh
160script is available for mainline testing for x86, arm64, and
161powerpc. By default, it will run the series of tests specified by
162tools/testing/selftests/rcutorture/configs/rcu/CFLIST, with each test
163running for 30 minutes within a guest OS using a minimal userspace
164supplied by an automatically generated initrd. After the tests are
165complete, the resulting build products and console output are analyzed
166for errors and the results of the runs are summarized.
167
168On larger systems, rcutorture testing can be accelerated by passing the
169--cpus argument to kvm.sh. For example, on a 64-CPU system, "--cpus 43"
170would use up to 43 CPUs to run tests concurrently, which as of v5.4 would
171complete all the scenarios in two batches, reducing the time to complete
172from about eight hours to about one hour (not counting the time to build
173the sixteen kernels). The "--dryrun sched" argument will not run tests,
174but rather tell you how the tests would be scheduled into batches. This
175can be useful when working out how many CPUs to specify in the --cpus
176argument.
177
178Not all changes require that all scenarios be run. For example, a change
179to Tree SRCU might run only the SRCU-N and SRCU-P scenarios using the
180--configs argument to kvm.sh as follows: "--configs 'SRCU-N SRCU-P'".
181Large systems can run multiple copies of of the full set of scenarios,
182for example, a system with 448 hardware threads can run five instances
183of the full set concurrently. To make this happen:
184
185 kvm.sh --cpus 448 --configs '5*CFLIST'
186
187Alternatively, such a system can run 56 concurrent instances of a single
188eight-CPU scenario:
189
190 kvm.sh --cpus 448 --configs '56*TREE04'
191
192Or 28 concurrent instances of each of two eight-CPU scenarios:
193
194 kvm.sh --cpus 448 --configs '28*TREE03 28*TREE04'
195
196Of course, each concurrent instance will use memory, which can be
197limited using the --memory argument, which defaults to 512M. Small
198values for memory may require disabling the callback-flooding tests
199using the --bootargs parameter discussed below.
200
201Sometimes additional debugging is useful, and in such cases the --kconfig
202parameter to kvm.sh may be used, for example, "--kconfig 'CONFIG_KASAN=y'".
203
204Kernel boot arguments can also be supplied, for example, to control
205rcutorture's module parameters. For example, to test a change to RCU's
206CPU stall-warning code, use "--bootargs 'rcutorture.stall_cpu=30'".
207This will of course result in the scripting reporting a failure, namely
208the resuling RCU CPU stall warning. As noted above, reducing memory may
209require disabling rcutorture's callback-flooding tests:
210
211 kvm.sh --cpus 448 --configs '56*TREE04' --memory 128M \
212 --bootargs 'rcutorture.fwd_progress=0'
213
214Sometimes all that is needed is a full set of kernel builds. This is
215what the --buildonly argument does.
216
217Finally, the --trust-make argument allows each kernel build to reuse what
218it can from the previous kernel build.
219
220There are additional more arcane arguments that are documented in the
221source code of the kvm.sh script.
222
223If a run contains failures, the number of buildtime and runtime failures
224is listed at the end of the kvm.sh output, which you really should redirect
225to a file. The build products and console output of each run is kept in
226tools/testing/selftests/rcutorture/res in timestamped directories. A
227given directory can be supplied to kvm-find-errors.sh in order to have
228it cycle you through summaries of errors and full error logs. For example:
229
230 tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh \
231 tools/testing/selftests/rcutorture/res/2020.01.20-15.54.23
232
233However, it is often more convenient to access the files directly.
234Files pertaining to all scenarios in a run reside in the top-level
235directory (2020.01.20-15.54.23 in the example above), while per-scenario
236files reside in a subdirectory named after the scenario (for example,
237"TREE04"). If a given scenario ran more than once (as in "--configs
238'56*TREE04'" above), the directories corresponding to the second and
239subsequent runs of that scenario include a sequence number, for example,
240"TREE04.2", "TREE04.3", and so on.
241
242The most frequently used file in the top-level directory is testid.txt.
243If the test ran in a git repository, then this file contains the commit
244that was tested and any uncommitted changes in diff format.
245
246The most frequently used files in each per-scenario-run directory are:
247
248.config: This file contains the Kconfig options.
249
250Make.out: This contains build output for a specific scenario.
251
252console.log: This contains the console output for a specific scenario.
253 This file may be examined once the kernel has booted, but
254 it might not exist if the build failed.
255
256vmlinux: This contains the kernel, which can be useful with tools like
257 objdump and gdb.
258
259A number of additional files are available, but are less frequently used.
260Many are intended for debugging of rcutorture itself or of its scripting.
261
262As of v5.4, a successful run with the default set of scenarios produces
263the following summary at the end of the run on a 12-CPU system:
264
265SRCU-N ------- 804233 GPs (148.932/s) [srcu: g10008272 f0x0 ]
266SRCU-P ------- 202320 GPs (37.4667/s) [srcud: g1809476 f0x0 ]
267SRCU-t ------- 1122086 GPs (207.794/s) [srcu: g0 f0x0 ]
268SRCU-u ------- 1111285 GPs (205.794/s) [srcud: g1 f0x0 ]
269TASKS01 ------- 19666 GPs (3.64185/s) [tasks: g0 f0x0 ]
270TASKS02 ------- 20541 GPs (3.80389/s) [tasks: g0 f0x0 ]
271TASKS03 ------- 19416 GPs (3.59556/s) [tasks: g0 f0x0 ]
272TINY01 ------- 836134 GPs (154.84/s) [rcu: g0 f0x0 ] n_max_cbs: 34198
273TINY02 ------- 850371 GPs (157.476/s) [rcu: g0 f0x0 ] n_max_cbs: 2631
274TREE01 ------- 162625 GPs (30.1157/s) [rcu: g1124169 f0x0 ]
275TREE02 ------- 333003 GPs (61.6672/s) [rcu: g2647753 f0x0 ] n_max_cbs: 35844
276TREE03 ------- 306623 GPs (56.782/s) [rcu: g2975325 f0x0 ] n_max_cbs: 1496497
277CPU count limited from 16 to 12
278TREE04 ------- 246149 GPs (45.5831/s) [rcu: g1695737 f0x0 ] n_max_cbs: 434961
279TREE05 ------- 314603 GPs (58.2598/s) [rcu: g2257741 f0x2 ] n_max_cbs: 193997
280TREE07 ------- 167347 GPs (30.9902/s) [rcu: g1079021 f0x0 ] n_max_cbs: 478732
281CPU count limited from 16 to 12
282TREE09 ------- 752238 GPs (139.303/s) [rcu: g13075057 f0x0 ] n_max_cbs: 99011
Documentation/admin-guide/kernel-parameters.txt+19−0
@@ -4005,6 +4005,15 @@ · 4004 unmodified lines
4005 Set threshold of queued RCU callbacks below which4005 Set threshold of queued RCU callbacks below which
4006 batch limiting is re-enabled.4006 batch limiting is re-enabled.
4007 4007
4008 rcutree.qovld= [KNL]
4009 Set threshold of queued RCU callbacks beyond which
4010 RCU's force-quiescent-state scan will aggressively
4011 enlist help from cond_resched() and sched IPIs to
4012 help CPUs more quickly reach quiescent states.
4013 Set to less than zero to make this be set based
4014 on rcutree.qhimark at boot time and to zero to
4015 disable more aggressive help enlistment.
4016
4008 rcutree.rcu_idle_gp_delay= [KNL]4017 rcutree.rcu_idle_gp_delay= [KNL]
4009 Set wakeup interval for idle CPUs that have4018 Set wakeup interval for idle CPUs that have
4010 RCU callbacks (RCU_FAST_NO_HZ=y).4019 RCU callbacks (RCU_FAST_NO_HZ=y).
@@ -4220,6 +4229,12 @@ · 209 unmodified lines
4220 rcupdate.rcu_cpu_stall_suppress= [KNL]4229 rcupdate.rcu_cpu_stall_suppress= [KNL]
4221 Suppress RCU CPU stall warning messages.4230 Suppress RCU CPU stall warning messages.
4222 4231
4232 rcupdate.rcu_cpu_stall_suppress_at_boot= [KNL]
4233 Suppress RCU CPU stall warning messages and
4234 rcutorture writer stall warnings that occur
4235 during early boot, that is, during the time
4236 before the init task is spawned.
4237
4223 rcupdate.rcu_cpu_stall_timeout= [KNL]4238 rcupdate.rcu_cpu_stall_timeout= [KNL]
4224 Set timeout for RCU CPU stall warning messages.4239 Set timeout for RCU CPU stall warning messages.
4225 4240
@@ -4892,6 +4907,10 @@ · 666 unmodified lines
4892 topology updates sent by the hypervisor to this4907 topology updates sent by the hypervisor to this
4893 LPAR.4908 LPAR.
4894 4909
4910 torture.disable_onoff_at_boot= [KNL]
4911 Prevent the CPU-hotplug component of torturing
4912 until after init has spawned.
4913
4895 tp720= [HW,PS2]4914 tp720= [HW,PS2]
4896 4915
4897 tpm_suspend_pcr=[HW,TPM]4916 tpm_suspend_pcr=[HW,TPM]
Documentation/memory-barriers.txt+4−4
@@ -185,7 +185,7 @@ As a further example, consider this sequence of events: · 184 unmodified lines
185 =============== ===============185 =============== ===============
186 { A == 1, B == 2, C == 3, P == &A, Q == &C }186 { A == 1, B == 2, C == 3, P == &A, Q == &C }
187 B = 4; Q = P;187 B = 4; Q = P;
188 P = &B D = *Q;188 P = &B; D = *Q;
189 189
190There is an obvious data dependency here, as the value loaded into D depends on190There is an obvious data dependency here, as the value loaded into D depends on
191the address retrieved from P by CPU 2. At the end of the sequence, any of the191the address retrieved from P by CPU 2. At the end of the sequence, any of the
@@ -569,7 +569,7 @@ following sequence of events: · 377 unmodified lines
569 { A == 1, B == 2, C == 3, P == &A, Q == &C }569 { A == 1, B == 2, C == 3, P == &A, Q == &C }
570 B = 4;570 B = 4;
571 <write barrier>571 <write barrier>
572 WRITE_ONCE(P, &B)572 WRITE_ONCE(P, &B);
573 Q = READ_ONCE(P);573 Q = READ_ONCE(P);
574 D = *Q;574 D = *Q;
575 575
@@ -1721,7 +1721,7 @@ of optimizations: · 1145 unmodified lines
1721 and WRITE_ONCE() are more selective: With READ_ONCE() and1721 and WRITE_ONCE() are more selective: With READ_ONCE() and
1722 WRITE_ONCE(), the compiler need only forget the contents of the1722 WRITE_ONCE(), the compiler need only forget the contents of the
1723 indicated memory locations, while with barrier() the compiler must1723 indicated memory locations, while with barrier() the compiler must
1724 discard the value of all memory locations that it has currented1724 discard the value of all memory locations that it has currently
1725 cached in any machine registers. Of course, the compiler must also1725 cached in any machine registers. Of course, the compiler must also
1726 respect the order in which the READ_ONCE()s and WRITE_ONCE()s occur,1726 respect the order in which the READ_ONCE()s and WRITE_ONCE()s occur,
1727 though the CPU of course need not do so.1727 though the CPU of course need not do so.
@@ -1833,7 +1833,7 @@ Aside: In the case of data dependencies, the compiler would be expected · 105 unmodified lines
1833to issue the loads in the correct order (eg. `a[b]` would have to load1833to issue the loads in the correct order (eg. `a[b]` would have to load
1834the value of b before loading a[b]), however there is no guarantee in1834the value of b before loading a[b]), however there is no guarantee in
1835the C specification that the compiler may not speculate the value of b1835the C specification that the compiler may not speculate the value of b
1836(eg. is equal to 1) and load a before b (eg. tmp = a[1]; if (b != 1)1836(eg. is equal to 1) and load a[b] before b (eg. tmp = a[1]; if (b != 1)
1837tmp = a[b]; ). There is also the problem of a compiler reloading b after1837tmp = a[b]; ). There is also the problem of a compiler reloading b after
1838having loaded a[b], thus having a newer copy of b than a[b]. A consensus1838having loaded a[b], thus having a newer copy of b than a[b]. A consensus
1839has not yet been reached about these problems, however the READ_ONCE()1839has not yet been reached about these problems, however the READ_ONCE()
fs/nfs/dir.c+1−1
@@ -2489,7 +2489,7 @@ static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre · 2488 unmodified lines
2489 rcu_read_lock();2489 rcu_read_lock();
2490 if (nfsi->cache_validity & NFS_INO_INVALID_ACCESS)2490 if (nfsi->cache_validity & NFS_INO_INVALID_ACCESS)
2491 goto out;2491 goto out;
2492 lh = rcu_dereference(nfsi->access_cache_entry_lru.prev);2492 lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
2493 cache = list_entry(lh, struct nfs_access_entry, lru);2493 cache = list_entry(lh, struct nfs_access_entry, lru);
2494 if (lh == &nfsi->access_cache_entry_lru ||2494 if (lh == &nfsi->access_cache_entry_lru ||
2495 cred_fscmp(cred, cache->cred) != 0)2495 cred_fscmp(cred, cache->cred) != 0)
include/linux/rculist.h+2−2
@@ -60,9 +60,9 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list) · 59 unmodified lines
60#define __list_check_rcu(dummy, cond, extra...) \60#define __list_check_rcu(dummy, cond, extra...) \
61 ({ \61 ({ \
62 check_arg_count_one(extra); \62 check_arg_count_one(extra); \
63 RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \63 RCU_LOCKDEP_WARN(!(cond) && !rcu_read_lock_any_held(), \
64 "RCU-list traversed in non-reader section!"); \64 "RCU-list traversed in non-reader section!"); \
65 })65 })
66#else66#else
67#define __list_check_rcu(dummy, cond, extra...) \67#define __list_check_rcu(dummy, cond, extra...) \
68 ({ check_arg_count_one(extra); })68 ({ check_arg_count_one(extra); })
include/linux/rcutiny.h+1−0
@@ -83,6 +83,7 @@ void rcu_scheduler_starting(void); · 82 unmodified lines
83static inline void rcu_scheduler_starting(void) { }83static inline void rcu_scheduler_starting(void) { }
84#endif /* #else #ifndef CONFIG_SRCU */84#endif /* #else #ifndef CONFIG_SRCU */
85static inline void rcu_end_inkernel_boot(void) { }85static inline void rcu_end_inkernel_boot(void) { }
86static inline bool rcu_inkernel_boot_has_ended(void) { return true; }
86static inline bool rcu_is_watching(void) { return true; }87static inline bool rcu_is_watching(void) { return true; }
87static inline void rcu_momentary_dyntick_idle(void) { }88static inline void rcu_momentary_dyntick_idle(void) { }
88static inline void kfree_rcu_scheduler_running(void) { }89static inline void kfree_rcu_scheduler_running(void) { }
include/linux/rcutree.h+1−0
@@ -54,6 +54,7 @@ void exit_rcu(void); · 53 unmodified lines
54void rcu_scheduler_starting(void);54void rcu_scheduler_starting(void);
55extern int rcu_scheduler_active __read_mostly;55extern int rcu_scheduler_active __read_mostly;
56void rcu_end_inkernel_boot(void);56void rcu_end_inkernel_boot(void);
57bool rcu_inkernel_boot_has_ended(void);
57bool rcu_is_watching(void);58bool rcu_is_watching(void);
58#ifndef CONFIG_PREEMPTION59#ifndef CONFIG_PREEMPTION
59void rcu_all_qs(void);60void rcu_all_qs(void);
include/linux/timer.h+1−1
@@ -164,7 +164,7 @@ static inline void destroy_timer_on_stack(struct timer_list *timer) { } · 163 unmodified lines
164 */164 */
165static inline int timer_pending(const struct timer_list * timer)165static inline int timer_pending(const struct timer_list * timer)
166{166{
167 return timer->entry.pprev != NULL;167 return !hlist_unhashed_lockless(&timer->entry);
168}168}
169 169
170extern void add_timer_on(struct timer_list *timer, int cpu);170extern void add_timer_on(struct timer_list *timer, int cpu);
include/trace/events/rcu.h+29−0
@@ -623,6 +623,34 @@ TRACE_EVENT_RCU(rcu_invoke_kfree_callback, · 622 unmodified lines
623 __entry->rcuname, __entry->rhp, __entry->offset)623 __entry->rcuname, __entry->rhp, __entry->offset)
624);624);
625 625
626/*
627 * Tracepoint for the invocation of a single RCU callback of the special
628 * kfree_bulk() form. The first argument is the RCU flavor, the second
629 * argument is a number of elements in array to free, the third is an
630 * address of the array holding nr_records entries.
631 */
632TRACE_EVENT_RCU(rcu_invoke_kfree_bulk_callback,
633
634 TP_PROTO(const char *rcuname, unsigned long nr_records, void **p),
635
636 TP_ARGS(rcuname, nr_records, p),
637
638 TP_STRUCT__entry(
639 __field(const char *, rcuname)
640 __field(unsigned long, nr_records)
641 __field(void **, p)
642 ),
643
644 TP_fast_assign(
645 __entry->rcuname = rcuname;
646 __entry->nr_records = nr_records;
647 __entry->p = p;
648 ),
649
650 TP_printk("%s bulk=0x%p nr_records=%lu",
651 __entry->rcuname, __entry->p, __entry->nr_records)
652);
653
626/*654/*
627 * Tracepoint for exiting rcu_do_batch after RCU callbacks have been655 * Tracepoint for exiting rcu_do_batch after RCU callbacks have been
628 * invoked. The first argument is the name of the RCU flavor,656 * invoked. The first argument is the name of the RCU flavor,
@@ -712,6 +740,7 @@ TRACE_EVENT_RCU(rcu_torture_read, · 83 unmodified lines
712 * "Begin": rcu_barrier() started.740 * "Begin": rcu_barrier() started.
713 * "EarlyExit": rcu_barrier() piggybacked, thus early exit.741 * "EarlyExit": rcu_barrier() piggybacked, thus early exit.
714 * "Inc1": rcu_barrier() piggyback check counter incremented.742 * "Inc1": rcu_barrier() piggyback check counter incremented.
743 * "OfflineNoCBQ": rcu_barrier() found offline no-CBs CPU with callbacks.
715 * "OnlineQ": rcu_barrier() found online CPU with callbacks.744 * "OnlineQ": rcu_barrier() found online CPU with callbacks.
716 * "OnlineNQ": rcu_barrier() found online CPU, no callbacks.745 * "OnlineNQ": rcu_barrier() found online CPU, no callbacks.
717 * "IRQ": An rcu_barrier_callback() callback posted on remote CPU.746 * "IRQ": An rcu_barrier_callback() callback posted on remote CPU.
kernel/locking/locktorture.c+8−7
@@ -618,7 +618,7 @@ static struct lock_torture_ops percpu_rwsem_lock_ops = { · 617 unmodified lines
618static int lock_torture_writer(void *arg)618static int lock_torture_writer(void *arg)
619{619{
620 struct lock_stress_stats *lwsp = arg;620 struct lock_stress_stats *lwsp = arg;
621 static DEFINE_TORTURE_RANDOM(rand);621 DEFINE_TORTURE_RANDOM(rand);
622 622
623 VERBOSE_TOROUT_STRING("lock_torture_writer task started");623 VERBOSE_TOROUT_STRING("lock_torture_writer task started");
624 set_user_nice(current, MAX_NICE);624 set_user_nice(current, MAX_NICE);
@@ -655,7 +655,7 @@ static int lock_torture_writer(void *arg) · 30 unmodified lines
655static int lock_torture_reader(void *arg)655static int lock_torture_reader(void *arg)
656{656{
657 struct lock_stress_stats *lrsp = arg;657 struct lock_stress_stats *lrsp = arg;
658 static DEFINE_TORTURE_RANDOM(rand);658 DEFINE_TORTURE_RANDOM(rand);
659 659
660 VERBOSE_TOROUT_STRING("lock_torture_reader task started");660 VERBOSE_TOROUT_STRING("lock_torture_reader task started");
661 set_user_nice(current, MAX_NICE);661 set_user_nice(current, MAX_NICE);
@@ -696,15 +696,16 @@ static void __torture_print_stats(char *page, · 34 unmodified lines
696 if (statp[i].n_lock_fail)696 if (statp[i].n_lock_fail)
697 fail = true;697 fail = true;
698 sum += statp[i].n_lock_acquired;698 sum += statp[i].n_lock_acquired;
699 if (max < statp[i].n_lock_fail)699 if (max < statp[i].n_lock_acquired)
700 max = statp[i].n_lock_fail;700 max = statp[i].n_lock_acquired;
701 if (min > statp[i].n_lock_fail)701 if (min > statp[i].n_lock_acquired)
702 min = statp[i].n_lock_fail;702 min = statp[i].n_lock_acquired;
703 }703 }
704 page += sprintf(page,704 page += sprintf(page,
705 "%s: Total: %lld Max/Min: %ld/%ld %s Fail: %d %s\n",705 "%s: Total: %lld Max/Min: %ld/%ld %s Fail: %d %s\n",
706 write ? "Writes" : "Reads ",706 write ? "Writes" : "Reads ",
707 sum, max, min, max / 2 > min ? "???" : "",707 sum, max, min,
708 !onoff_interval && max / 2 > min ? "???" : "",
708 fail, fail ? "!!!" : "");709 fail, fail ? "!!!" : "");
709 if (fail)710 if (fail)
710 atomic_inc(&cxt.n_lock_torture_errors);711 atomic_inc(&cxt.n_lock_torture_errors);
kernel/locking/rtmutex.c+1−1
@@ -57,7 +57,7 @@ rt_mutex_set_owner(struct rt_mutex *lock, struct task_struct *owner) · 56 unmodified lines
57 if (rt_mutex_has_waiters(lock))57 if (rt_mutex_has_waiters(lock))
58 val |= RT_MUTEX_HAS_WAITERS;58 val |= RT_MUTEX_HAS_WAITERS;
59 59
60 lock->owner = (struct task_struct *)val;60 WRITE_ONCE(lock->owner, (struct task_struct *)val);
61}61}
62 62
63static inline void clear_rt_mutex_waiters(struct rt_mutex *lock)63static inline void clear_rt_mutex_waiters(struct rt_mutex *lock)
kernel/rcu/Makefile+4−0
@@ -3,6 +3,10 @@ · 2 unmodified lines
3# and is generally not a function of system call inputs.3# and is generally not a function of system call inputs.
4KCOV_INSTRUMENT := n4KCOV_INSTRUMENT := n
5 5
6ifeq ($(CONFIG_KCSAN),y)
7KBUILD_CFLAGS += -g -fno-omit-frame-pointer
8endif
9
6obj-y += update.o sync.o10obj-y += update.o sync.o
7obj-$(CONFIG_TREE_SRCU) += srcutree.o11obj-$(CONFIG_TREE_SRCU) += srcutree.o
8obj-$(CONFIG_TINY_SRCU) += srcutiny.o12obj-$(CONFIG_TINY_SRCU) += srcutiny.o
kernel/rcu/rcu.h+21−2
@@ -198,6 +198,13 @@ static inline void debug_rcu_head_unqueue(struct rcu_head *head) · 197 unmodified lines
198}198}
199#endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */199#endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
200 200
201extern int rcu_cpu_stall_suppress_at_boot;
202
203static inline bool rcu_stall_is_suppressed_at_boot(void)
204{
205 return rcu_cpu_stall_suppress_at_boot && !rcu_inkernel_boot_has_ended();
206}
207
201#ifdef CONFIG_RCU_STALL_COMMON208#ifdef CONFIG_RCU_STALL_COMMON
202 209
203extern int rcu_cpu_stall_ftrace_dump;210extern int rcu_cpu_stall_ftrace_dump;
@@ -205,6 +212,11 @@ extern int rcu_cpu_stall_suppress; · 1 unmodified line
205extern int rcu_cpu_stall_timeout;212extern int rcu_cpu_stall_timeout;
206int rcu_jiffies_till_stall_check(void);213int rcu_jiffies_till_stall_check(void);
207 214
215static inline bool rcu_stall_is_suppressed(void)
216{
217 return rcu_stall_is_suppressed_at_boot() || rcu_cpu_stall_suppress;
218}
219
208#define rcu_ftrace_dump_stall_suppress() \220#define rcu_ftrace_dump_stall_suppress() \
209do { \221do { \
210 if (!rcu_cpu_stall_suppress) \222 if (!rcu_cpu_stall_suppress) \
@@ -218,6 +230,11 @@ do { \ · 7 unmodified lines
218} while (0)230} while (0)
219 231
220#else /* #endif #ifdef CONFIG_RCU_STALL_COMMON */232#else /* #endif #ifdef CONFIG_RCU_STALL_COMMON */
233
234static inline bool rcu_stall_is_suppressed(void)
235{
236 return rcu_stall_is_suppressed_at_boot();
237}
221#define rcu_ftrace_dump_stall_suppress()238#define rcu_ftrace_dump_stall_suppress()
222#define rcu_ftrace_dump_stall_unsuppress()239#define rcu_ftrace_dump_stall_unsuppress()
223#endif /* #ifdef CONFIG_RCU_STALL_COMMON */240#endif /* #ifdef CONFIG_RCU_STALL_COMMON */
@@ -325,7 +342,8 @@ static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt) · 101 unmodified lines
325 * Iterate over all possible CPUs in a leaf RCU node.342 * Iterate over all possible CPUs in a leaf RCU node.
326 */343 */
327#define for_each_leaf_node_possible_cpu(rnp, cpu) \344#define for_each_leaf_node_possible_cpu(rnp, cpu) \
328 for ((cpu) = cpumask_next((rnp)->grplo - 1, cpu_possible_mask); \345 for (WARN_ON_ONCE(!rcu_is_leaf_node(rnp)), \
346 (cpu) = cpumask_next((rnp)->grplo - 1, cpu_possible_mask); \
329 (cpu) <= rnp->grphi; \347 (cpu) <= rnp->grphi; \
330 (cpu) = cpumask_next((cpu), cpu_possible_mask))348 (cpu) = cpumask_next((cpu), cpu_possible_mask))
331 349
@@ -335,7 +353,8 @@ static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt) · 3 unmodified lines
335#define rcu_find_next_bit(rnp, cpu, mask) \353#define rcu_find_next_bit(rnp, cpu, mask) \
336 ((rnp)->grplo + find_next_bit(&(mask), BITS_PER_LONG, (cpu)))354 ((rnp)->grplo + find_next_bit(&(mask), BITS_PER_LONG, (cpu)))
337#define for_each_leaf_node_cpu_mask(rnp, cpu, mask) \355#define for_each_leaf_node_cpu_mask(rnp, cpu, mask) \
338 for ((cpu) = rcu_find_next_bit((rnp), 0, (mask)); \356 for (WARN_ON_ONCE(!rcu_is_leaf_node(rnp)), \
357 (cpu) = rcu_find_next_bit((rnp), 0, (mask)); \
339 (cpu) <= rnp->grphi; \358 (cpu) <= rnp->grphi; \
340 (cpu) = rcu_find_next_bit((rnp), (cpu) + 1 - (rnp->grplo), (mask)))359 (cpu) = rcu_find_next_bit((rnp), (cpu) + 1 - (rnp->grplo), (mask)))
341 360
kernel/rcu/rcu_segcblist.c+1−3
@@ -182,7 +182,7 @@ void rcu_segcblist_offload(struct rcu_segcblist *rsclp) · 181 unmodified lines
182bool rcu_segcblist_ready_cbs(struct rcu_segcblist *rsclp)182bool rcu_segcblist_ready_cbs(struct rcu_segcblist *rsclp)
183{183{
184 return rcu_segcblist_is_enabled(rsclp) &&184 return rcu_segcblist_is_enabled(rsclp) &&
185 &rsclp->head != rsclp->tails[RCU_DONE_TAIL];185 &rsclp->head != READ_ONCE(rsclp->tails[RCU_DONE_TAIL]);
186}186}
187 187
188/*188/*
@@ -381,8 +381,6 @@ void rcu_segcblist_insert_pend_cbs(struct rcu_segcblist *rsclp, · 192 unmodified lines
381 return; /* Nothing to do. */381 return; /* Nothing to do. */
382 WRITE_ONCE(*rsclp->tails[RCU_NEXT_TAIL], rclp->head);382 WRITE_ONCE(*rsclp->tails[RCU_NEXT_TAIL], rclp->head);
383 WRITE_ONCE(rsclp->tails[RCU_NEXT_TAIL], rclp->tail);383 WRITE_ONCE(rsclp->tails[RCU_NEXT_TAIL], rclp->tail);
384 rclp->head = NULL;
385 rclp->tail = &rclp->head;
386}384}
387 385
388/*386/*
kernel/rcu/rcuperf.c+12−2
@@ -12,6 +12,7 @@ · 11 unmodified lines
12#include <linux/types.h>12#include <linux/types.h>
13#include <linux/kernel.h>13#include <linux/kernel.h>
14#include <linux/init.h>14#include <linux/init.h>
15#include <linux/mm.h>
15#include <linux/module.h>16#include <linux/module.h>
16#include <linux/kthread.h>17#include <linux/kthread.h>
17#include <linux/err.h>18#include <linux/err.h>
@@ -611,6 +612,7 @@ kfree_perf_thread(void *arg) · 593 unmodified lines
611 long me = (long)arg;612 long me = (long)arg;
612 struct kfree_obj *alloc_ptr;613 struct kfree_obj *alloc_ptr;
613 u64 start_time, end_time;614 u64 start_time, end_time;
615 long long mem_begin, mem_during = 0;
614 616
615 VERBOSE_PERFOUT_STRING("kfree_perf_thread task started");617 VERBOSE_PERFOUT_STRING("kfree_perf_thread task started");
616 set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));618 set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));
@@ -626,6 +628,12 @@ kfree_perf_thread(void *arg) · 9 unmodified lines
626 }628 }
627 629
628 do {630 do {
631 if (!mem_during) {
632 mem_during = mem_begin = si_mem_available();
633 } else if (loop % (kfree_loops / 4) == 0) {
634 mem_during = (mem_during + si_mem_available()) / 2;
635 }
636
629 for (i = 0; i < kfree_alloc_num; i++) {637 for (i = 0; i < kfree_alloc_num; i++) {
630 alloc_ptr = kmalloc(sizeof(struct kfree_obj), GFP_KERNEL);638 alloc_ptr = kmalloc(sizeof(struct kfree_obj), GFP_KERNEL);
631 if (!alloc_ptr)639 if (!alloc_ptr)
@@ -645,9 +653,11 @@ kfree_perf_thread(void *arg) · 13 unmodified lines
645 else653 else
646 b_rcu_gp_test_finished = cur_ops->get_gp_seq();654 b_rcu_gp_test_finished = cur_ops->get_gp_seq();
647 655
648 pr_alert("Total time taken by all kfree'ers: %llu ns, loops: %d, batches: %ld\n",656 pr_alert("Total time taken by all kfree'ers: %llu ns, loops: %d, batches: %ld, memory footprint: %lldMB\n",
649 (unsigned long long)(end_time - start_time), kfree_loops,657 (unsigned long long)(end_time - start_time), kfree_loops,
650 rcuperf_seq_diff(b_rcu_gp_test_finished, b_rcu_gp_test_started));658 rcuperf_seq_diff(b_rcu_gp_test_finished, b_rcu_gp_test_started),
659 (mem_begin - mem_during) >> (20 - PAGE_SHIFT));
660
651 if (shutdown) {661 if (shutdown) {
652 smp_mb(); /* Assign before wake. */662 smp_mb(); /* Assign before wake. */
653 wake_up(&shutdown_wq);663 wake_up(&shutdown_wq);
kernel/rcu/rcutorture.c+50−17
@@ -339,7 +339,7 @@ rcu_read_delay(struct torture_random_state *rrsp, struct rt_read_seg *rtrsp) · 338 unmodified lines
339 * period, and we want a long delay occasionally to trigger339 * period, and we want a long delay occasionally to trigger
340 * force_quiescent_state. */340 * force_quiescent_state. */
341 341
342 if (!rcu_fwd_cb_nodelay &&342 if (!READ_ONCE(rcu_fwd_cb_nodelay) &&
343 !(torture_random(rrsp) % (nrealreaders * 2000 * longdelay_ms))) {343 !(torture_random(rrsp) % (nrealreaders * 2000 * longdelay_ms))) {
344 started = cur_ops->get_gp_seq();344 started = cur_ops->get_gp_seq();
345 ts = rcu_trace_clock_local();345 ts = rcu_trace_clock_local();
@@ -375,11 +375,12 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp) · 29 unmodified lines
375{375{
376 int i;376 int i;
377 377
378 i = rp->rtort_pipe_count;378 i = READ_ONCE(rp->rtort_pipe_count);
379 if (i > RCU_TORTURE_PIPE_LEN)379 if (i > RCU_TORTURE_PIPE_LEN)
380 i = RCU_TORTURE_PIPE_LEN;380 i = RCU_TORTURE_PIPE_LEN;
381 atomic_inc(&rcu_torture_wcount[i]);381 atomic_inc(&rcu_torture_wcount[i]);
382 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {382 WRITE_ONCE(rp->rtort_pipe_count, i + 1);
383 if (rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
383 rp->rtort_mbtest = 0;384 rp->rtort_mbtest = 0;
384 return true;385 return true;
385 }386 }
@@ -1015,7 +1016,8 @@ rcu_torture_writer(void *arg) · 629 unmodified lines
1015 if (i > RCU_TORTURE_PIPE_LEN)1016 if (i > RCU_TORTURE_PIPE_LEN)
1016 i = RCU_TORTURE_PIPE_LEN;1017 i = RCU_TORTURE_PIPE_LEN;
1017 atomic_inc(&rcu_torture_wcount[i]);1018 atomic_inc(&rcu_torture_wcount[i]);
1018 old_rp->rtort_pipe_count++;1019 WRITE_ONCE(old_rp->rtort_pipe_count,
1020 old_rp->rtort_pipe_count + 1);
1019 switch (synctype[torture_random(&rand) % nsynctypes]) {1021 switch (synctype[torture_random(&rand) % nsynctypes]) {
1020 case RTWS_DEF_FREE:1022 case RTWS_DEF_FREE:
1021 rcu_torture_writer_state = RTWS_DEF_FREE;1023 rcu_torture_writer_state = RTWS_DEF_FREE;
@@ -1067,7 +1069,8 @@ rcu_torture_writer(void *arg) · 45 unmodified lines
1067 if (stutter_wait("rcu_torture_writer") &&1069 if (stutter_wait("rcu_torture_writer") &&
1068 !READ_ONCE(rcu_fwd_cb_nodelay) &&1070 !READ_ONCE(rcu_fwd_cb_nodelay) &&
1069 !cur_ops->slow_gps &&1071 !cur_ops->slow_gps &&
1070 !torture_must_stop())1072 !torture_must_stop() &&
1073 rcu_inkernel_boot_has_ended())
1071 for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++)1074 for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++)
1072 if (list_empty(&rcu_tortures[i].rtort_free) &&1075 if (list_empty(&rcu_tortures[i].rtort_free) &&
1073 rcu_access_pointer(rcu_torture_current) !=1076 rcu_access_pointer(rcu_torture_current) !=
@@ -1290,7 +1293,7 @@ static bool rcu_torture_one_read(struct torture_random_state *trsp) · 216 unmodified lines
1290 atomic_inc(&n_rcu_torture_mberror);1293 atomic_inc(&n_rcu_torture_mberror);
1291 rtrsp = rcutorture_loop_extend(&readstate, trsp, rtrsp);1294 rtrsp = rcutorture_loop_extend(&readstate, trsp, rtrsp);
1292 preempt_disable();1295 preempt_disable();
1293 pipe_count = p->rtort_pipe_count;1296 pipe_count = READ_ONCE(p->rtort_pipe_count);
1294 if (pipe_count > RCU_TORTURE_PIPE_LEN) {1297 if (pipe_count > RCU_TORTURE_PIPE_LEN) {
1295 /* Should not happen, but... */1298 /* Should not happen, but... */
1296 pipe_count = RCU_TORTURE_PIPE_LEN;1299 pipe_count = RCU_TORTURE_PIPE_LEN;
@@ -1404,14 +1407,15 @@ rcu_torture_stats_print(void) · 107 unmodified lines
1404 int i;1407 int i;
1405 long pipesummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };1408 long pipesummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
1406 long batchsummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };1409 long batchsummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
1410 struct rcu_torture *rtcp;
1407 static unsigned long rtcv_snap = ULONG_MAX;1411 static unsigned long rtcv_snap = ULONG_MAX;
1408 static bool splatted;1412 static bool splatted;
1409 struct task_struct *wtp;1413 struct task_struct *wtp;
1410 1414
1411 for_each_possible_cpu(cpu) {1415 for_each_possible_cpu(cpu) {
1412 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {1416 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
1413 pipesummary[i] += per_cpu(rcu_torture_count, cpu)[i];1417 pipesummary[i] += READ_ONCE(per_cpu(rcu_torture_count, cpu)[i]);
1414 batchsummary[i] += per_cpu(rcu_torture_batch, cpu)[i];1418 batchsummary[i] += READ_ONCE(per_cpu(rcu_torture_batch, cpu)[i]);
1415 }1419 }
1416 }1420 }
1417 for (i = RCU_TORTURE_PIPE_LEN - 1; i >= 0; i--) {1421 for (i = RCU_TORTURE_PIPE_LEN - 1; i >= 0; i--) {
@@ -1420,9 +1424,10 @@ rcu_torture_stats_print(void) · 2 unmodified lines
1420 }1424 }
1421 1425
1422 pr_alert("%s%s ", torture_type, TORTURE_FLAG);1426 pr_alert("%s%s ", torture_type, TORTURE_FLAG);
1427 rtcp = rcu_access_pointer(rcu_torture_current);
1423 pr_cont("rtc: %p %s: %lu tfle: %d rta: %d rtaf: %d rtf: %d ",1428 pr_cont("rtc: %p %s: %lu tfle: %d rta: %d rtaf: %d rtf: %d ",
1424 rcu_torture_current,1429 rtcp,
1425 rcu_torture_current ? "ver" : "VER",1430 rtcp && !rcu_stall_is_suppressed_at_boot() ? "ver" : "VER",
1426 rcu_torture_current_version,1431 rcu_torture_current_version,
1427 list_empty(&rcu_torture_freelist),1432 list_empty(&rcu_torture_freelist),
1428 atomic_read(&n_rcu_torture_alloc),1433 atomic_read(&n_rcu_torture_alloc),
@@ -1478,7 +1483,8 @@ rcu_torture_stats_print(void) · 49 unmodified lines
1478 if (cur_ops->stats)1483 if (cur_ops->stats)
1479 cur_ops->stats();1484 cur_ops->stats();
1480 if (rtcv_snap == rcu_torture_current_version &&1485 if (rtcv_snap == rcu_torture_current_version &&
1481 rcu_torture_current != NULL) {1486 rcu_access_pointer(rcu_torture_current) &&
1487 !rcu_stall_is_suppressed()) {
1482 int __maybe_unused flags = 0;1488 int __maybe_unused flags = 0;
1483 unsigned long __maybe_unused gp_seq = 0;1489 unsigned long __maybe_unused gp_seq = 0;
1484 1490
@@ -1993,8 +1999,11 @@ static int rcu_torture_fwd_prog(void *args) · 508 unmodified lines
1993 schedule_timeout_interruptible(fwd_progress_holdoff * HZ);1999 schedule_timeout_interruptible(fwd_progress_holdoff * HZ);
1994 WRITE_ONCE(rcu_fwd_emergency_stop, false);2000 WRITE_ONCE(rcu_fwd_emergency_stop, false);
1995 register_oom_notifier(&rcutorture_oom_nb);2001 register_oom_notifier(&rcutorture_oom_nb);
1996 rcu_torture_fwd_prog_nr(rfp, &tested, &tested_tries);2002 if (!IS_ENABLED(CONFIG_TINY_RCU) ||
1997 rcu_torture_fwd_prog_cr(rfp);2003 rcu_inkernel_boot_has_ended())
2004 rcu_torture_fwd_prog_nr(rfp, &tested, &tested_tries);
2005 if (rcu_inkernel_boot_has_ended())
2006 rcu_torture_fwd_prog_cr(rfp);
1998 unregister_oom_notifier(&rcutorture_oom_nb);2007 unregister_oom_notifier(&rcutorture_oom_nb);
1999 2008
2000 /* Avoid slow periods, better to test when busy. */2009 /* Avoid slow periods, better to test when busy. */
@@ -2044,6 +2053,14 @@ static void rcu_torture_barrier_cbf(struct rcu_head *rcu) · 43 unmodified lines
2044 atomic_inc(&barrier_cbs_invoked);2053 atomic_inc(&barrier_cbs_invoked);
2045}2054}
2046 2055
2056/* IPI handler to get callback posted on desired CPU, if online. */
2057static void rcu_torture_barrier1cb(void *rcu_void)
2058{
2059 struct rcu_head *rhp = rcu_void;
2060
2061 cur_ops->call(rhp, rcu_torture_barrier_cbf);
2062}
2063
2047/* kthread function to register callbacks used to test RCU barriers. */2064/* kthread function to register callbacks used to test RCU barriers. */
2048static int rcu_torture_barrier_cbs(void *arg)2065static int rcu_torture_barrier_cbs(void *arg)
2049{2066{
@@ -2067,9 +2084,11 @@ static int rcu_torture_barrier_cbs(void *arg) · 17 unmodified lines
2067 * The above smp_load_acquire() ensures barrier_phase load2084 * The above smp_load_acquire() ensures barrier_phase load
2068 * is ordered before the following ->call().2085 * is ordered before the following ->call().
2069 */2086 */
2070 local_irq_disable(); /* Just to test no-irq call_rcu(). */2087 if (smp_call_function_single(myid, rcu_torture_barrier1cb,
2071 cur_ops->call(&rcu, rcu_torture_barrier_cbf);2088 &rcu, 1)) {
2072 local_irq_enable();2089 // IPI failed, so use direct call from current CPU.
2090 cur_ops->call(&rcu, rcu_torture_barrier_cbf);
2091 }
2073 if (atomic_dec_and_test(&barrier_cbs_count))2092 if (atomic_dec_and_test(&barrier_cbs_count))
2074 wake_up(&barrier_wq);2093 wake_up(&barrier_wq);
2075 } while (!torture_must_stop());2094 } while (!torture_must_stop());
@@ -2105,7 +2124,21 @@ static int rcu_torture_barrier(void *arg) · 29 unmodified lines
2105 pr_err("barrier_cbs_invoked = %d, n_barrier_cbs = %d\n",2124 pr_err("barrier_cbs_invoked = %d, n_barrier_cbs = %d\n",
2106 atomic_read(&barrier_cbs_invoked),2125 atomic_read(&barrier_cbs_invoked),
2107 n_barrier_cbs);2126 n_barrier_cbs);
2108 WARN_ON_ONCE(1);2127 WARN_ON(1);
2128 // Wait manually for the remaining callbacks
2129 i = 0;
2130 do {
2131 if (WARN_ON(i++ > HZ))
2132 i = INT_MIN;
2133 schedule_timeout_interruptible(1);
2134 cur_ops->cb_barrier();
2135 } while (atomic_read(&barrier_cbs_invoked) !=
2136 n_barrier_cbs &&
2137 !torture_must_stop());
2138 smp_mb(); // Can't trust ordering if broken.
2139 if (!torture_must_stop())
2140 pr_err("Recovered: barrier_cbs_invoked = %d\n",
2141 atomic_read(&barrier_cbs_invoked));
2109 } else {2142 } else {
2110 n_barrier_successes++;2143 n_barrier_successes++;
2111 }2144 }
kernel/rcu/srcutree.c+10−8
@@ -5,7 +5,7 @@ · 4 unmodified lines
5 * Copyright (C) IBM Corporation, 20065 * Copyright (C) IBM Corporation, 2006
6 * Copyright (C) Fujitsu, 20126 * Copyright (C) Fujitsu, 2012
7 *7 *
8 * Author: Paul McKenney <paulmck@linux.ibm.com>8 * Authors: Paul McKenney <paulmck@linux.ibm.com>
9 * Lai Jiangshan <laijs@cn.fujitsu.com>9 * Lai Jiangshan <laijs@cn.fujitsu.com>
10 *10 *
11 * For detailed explanation of Read-Copy Update mechanism see -11 * For detailed explanation of Read-Copy Update mechanism see -
@@ -450,7 +450,7 @@ static void srcu_gp_start(struct srcu_struct *ssp) · 438 unmodified lines
450 spin_unlock_rcu_node(sdp); /* Interrupts remain disabled. */450 spin_unlock_rcu_node(sdp); /* Interrupts remain disabled. */
451 smp_mb(); /* Order prior store to ->srcu_gp_seq_needed vs. GP start. */451 smp_mb(); /* Order prior store to ->srcu_gp_seq_needed vs. GP start. */
452 rcu_seq_start(&ssp->srcu_gp_seq);452 rcu_seq_start(&ssp->srcu_gp_seq);
453 state = rcu_seq_state(READ_ONCE(ssp->srcu_gp_seq));453 state = rcu_seq_state(ssp->srcu_gp_seq);
454 WARN_ON_ONCE(state != SRCU_STATE_SCAN1);454 WARN_ON_ONCE(state != SRCU_STATE_SCAN1);
455}455}
456 456
@@ -534,7 +534,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) · 77 unmodified lines
534 rcu_seq_end(&ssp->srcu_gp_seq);534 rcu_seq_end(&ssp->srcu_gp_seq);
535 gpseq = rcu_seq_current(&ssp->srcu_gp_seq);535 gpseq = rcu_seq_current(&ssp->srcu_gp_seq);
536 if (ULONG_CMP_LT(ssp->srcu_gp_seq_needed_exp, gpseq))536 if (ULONG_CMP_LT(ssp->srcu_gp_seq_needed_exp, gpseq))
537 ssp->srcu_gp_seq_needed_exp = gpseq;537 WRITE_ONCE(ssp->srcu_gp_seq_needed_exp, gpseq);
538 spin_unlock_irq_rcu_node(ssp);538 spin_unlock_irq_rcu_node(ssp);
539 mutex_unlock(&ssp->srcu_gp_mutex);539 mutex_unlock(&ssp->srcu_gp_mutex);
540 /* A new grace period can start at this point. But only one. */540 /* A new grace period can start at this point. But only one. */
@@ -550,7 +550,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) · 9 unmodified lines
550 snp->srcu_have_cbs[idx] = gpseq;550 snp->srcu_have_cbs[idx] = gpseq;
551 rcu_seq_set_state(&snp->srcu_have_cbs[idx], 1);551 rcu_seq_set_state(&snp->srcu_have_cbs[idx], 1);
552 if (ULONG_CMP_LT(snp->srcu_gp_seq_needed_exp, gpseq))552 if (ULONG_CMP_LT(snp->srcu_gp_seq_needed_exp, gpseq))
553 snp->srcu_gp_seq_needed_exp = gpseq;553 WRITE_ONCE(snp->srcu_gp_seq_needed_exp, gpseq);
554 mask = snp->srcu_data_have_cbs[idx];554 mask = snp->srcu_data_have_cbs[idx];
555 snp->srcu_data_have_cbs[idx] = 0;555 snp->srcu_data_have_cbs[idx] = 0;
556 spin_unlock_irq_rcu_node(snp);556 spin_unlock_irq_rcu_node(snp);
@@ -614,7 +614,7 @@ static void srcu_funnel_exp_start(struct srcu_struct *ssp, struct srcu_node *snp · 57 unmodified lines
614 }614 }
615 spin_lock_irqsave_rcu_node(ssp, flags);615 spin_lock_irqsave_rcu_node(ssp, flags);
616 if (ULONG_CMP_LT(ssp->srcu_gp_seq_needed_exp, s))616 if (ULONG_CMP_LT(ssp->srcu_gp_seq_needed_exp, s))
617 ssp->srcu_gp_seq_needed_exp = s;617 WRITE_ONCE(ssp->srcu_gp_seq_needed_exp, s);
618 spin_unlock_irqrestore_rcu_node(ssp, flags);618 spin_unlock_irqrestore_rcu_node(ssp, flags);
619}619}
620 620
@@ -660,7 +660,7 @@ static void srcu_funnel_gp_start(struct srcu_struct *ssp, struct srcu_data *sdp, · 39 unmodified lines
660 if (snp == sdp->mynode)660 if (snp == sdp->mynode)
661 snp->srcu_data_have_cbs[idx] |= sdp->grpmask;661 snp->srcu_data_have_cbs[idx] |= sdp->grpmask;
662 if (!do_norm && ULONG_CMP_LT(snp->srcu_gp_seq_needed_exp, s))662 if (!do_norm && ULONG_CMP_LT(snp->srcu_gp_seq_needed_exp, s))
663 snp->srcu_gp_seq_needed_exp = s;663 WRITE_ONCE(snp->srcu_gp_seq_needed_exp, s);
664 spin_unlock_irqrestore_rcu_node(snp, flags);664 spin_unlock_irqrestore_rcu_node(snp, flags);
665 }665 }
666 666
@@ -674,7 +674,7 @@ static void srcu_funnel_gp_start(struct srcu_struct *ssp, struct srcu_data *sdp, · 7 unmodified lines
674 smp_store_release(&ssp->srcu_gp_seq_needed, s); /*^^^*/674 smp_store_release(&ssp->srcu_gp_seq_needed, s); /*^^^*/
675 }675 }
676 if (!do_norm && ULONG_CMP_LT(ssp->srcu_gp_seq_needed_exp, s))676 if (!do_norm && ULONG_CMP_LT(ssp->srcu_gp_seq_needed_exp, s))
677 ssp->srcu_gp_seq_needed_exp = s;677 WRITE_ONCE(ssp->srcu_gp_seq_needed_exp, s);
678 678
679 /* If grace period not already done and none in progress, start it. */679 /* If grace period not already done and none in progress, start it. */
680 if (!rcu_seq_done(&ssp->srcu_gp_seq, s) &&680 if (!rcu_seq_done(&ssp->srcu_gp_seq, s) &&
@@ -1079,7 +1079,7 @@ EXPORT_SYMBOL_GPL(srcu_barrier); · 398 unmodified lines
1079 */1079 */
1080unsigned long srcu_batches_completed(struct srcu_struct *ssp)1080unsigned long srcu_batches_completed(struct srcu_struct *ssp)
1081{1081{
1082 return ssp->srcu_idx;1082 return READ_ONCE(ssp->srcu_idx);
1083}1083}
1084EXPORT_SYMBOL_GPL(srcu_batches_completed);1084EXPORT_SYMBOL_GPL(srcu_batches_completed);
1085 1085
@@ -1130,7 +1130,9 @@ static void srcu_advance_state(struct srcu_struct *ssp) · 44 unmodified lines
1130 return; /* readers present, retry later. */1130 return; /* readers present, retry later. */
1131 }1131 }
1132 srcu_flip(ssp);1132 srcu_flip(ssp);
1133 spin_lock_irq_rcu_node(ssp);
1133 rcu_seq_set_state(&ssp->srcu_gp_seq, SRCU_STATE_SCAN2);1134 rcu_seq_set_state(&ssp->srcu_gp_seq, SRCU_STATE_SCAN2);
1135 spin_unlock_irq_rcu_node(ssp);
1134 }1136 }
1135 1137
1136 if (rcu_seq_state(READ_ONCE(ssp->srcu_gp_seq)) == SRCU_STATE_SCAN2) {1138 if (rcu_seq_state(READ_ONCE(ssp->srcu_gp_seq)) == SRCU_STATE_SCAN2) {
kernel/rcu/tree.c+339−113
@@ -1,12 +1,12 @@
1// SPDX-License-Identifier: GPL-2.0+1// SPDX-License-Identifier: GPL-2.0+
2/*2/*
3 * Read-Copy Update mechanism for mutual exclusion3 * Read-Copy Update mechanism for mutual exclusion (tree-based version)
4 *4 *
5 * Copyright IBM Corporation, 20085 * Copyright IBM Corporation, 2008
6 *6 *
7 * Authors: Dipankar Sarma <dipankar@in.ibm.com>7 * Authors: Dipankar Sarma <dipankar@in.ibm.com>
8 * Manfred Spraul <manfred@colorfullife.com>8 * Manfred Spraul <manfred@colorfullife.com>
9 * Paul E. McKenney <paulmck@linux.ibm.com> Hierarchical version9 * Paul E. McKenney <paulmck@linux.ibm.com>
10 *10 *
11 * Based on the original work by Paul McKenney <paulmck@linux.ibm.com>11 * Based on the original work by Paul McKenney <paulmck@linux.ibm.com>
12 * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.12 * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
@@ -150,6 +150,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) · 137 unmodified lines
150static void invoke_rcu_core(void);150static void invoke_rcu_core(void);
151static void rcu_report_exp_rdp(struct rcu_data *rdp);151static void rcu_report_exp_rdp(struct rcu_data *rdp);
152static void sync_sched_exp_online_cleanup(int cpu);152static void sync_sched_exp_online_cleanup(int cpu);
153static void check_cb_ovld_locked(struct rcu_data *rdp, struct rcu_node *rnp);
153 154
154/* rcuc/rcub kthread realtime priority */155/* rcuc/rcub kthread realtime priority */
155static int kthread_prio = IS_ENABLED(CONFIG_RCU_BOOST) ? 1 : 0;156static int kthread_prio = IS_ENABLED(CONFIG_RCU_BOOST) ? 1 : 0;
@@ -342,14 +343,17 @@ bool rcu_eqs_special_set(int cpu) · 186 unmodified lines
342{343{
343 int old;344 int old;
344 int new;345 int new;
346 int new_old;
345 struct rcu_data *rdp = &per_cpu(rcu_data, cpu);347 struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
346 348
349 new_old = atomic_read(&rdp->dynticks);
347 do {350 do {
348 old = atomic_read(&rdp->dynticks);351 old = new_old;
349 if (old & RCU_DYNTICK_CTRL_CTR)352 if (old & RCU_DYNTICK_CTRL_CTR)
350 return false;353 return false;
351 new = old | RCU_DYNTICK_CTRL_MASK;354 new = old | RCU_DYNTICK_CTRL_MASK;
352 } while (atomic_cmpxchg(&rdp->dynticks, old, new) != old);355 new_old = atomic_cmpxchg(&rdp->dynticks, old, new);
356 } while (new_old != old);
353 return true;357 return true;
354}358}
355 359
@@ -410,10 +414,15 @@ static long blimit = DEFAULT_RCU_BLIMIT; · 54 unmodified lines
410static long qhimark = DEFAULT_RCU_QHIMARK;414static long qhimark = DEFAULT_RCU_QHIMARK;
411#define DEFAULT_RCU_QLOMARK 100 /* Once only this many pending, use blimit. */415#define DEFAULT_RCU_QLOMARK 100 /* Once only this many pending, use blimit. */
412static long qlowmark = DEFAULT_RCU_QLOMARK;416static long qlowmark = DEFAULT_RCU_QLOMARK;
417#define DEFAULT_RCU_QOVLD_MULT 2
418#define DEFAULT_RCU_QOVLD (DEFAULT_RCU_QOVLD_MULT * DEFAULT_RCU_QHIMARK)
419static long qovld = DEFAULT_RCU_QOVLD; /* If this many pending, hammer QS. */
420static long qovld_calc = -1; /* No pre-initialization lock acquisitions! */
413 421
414module_param(blimit, long, 0444);422module_param(blimit, long, 0444);
415module_param(qhimark, long, 0444);423module_param(qhimark, long, 0444);
416module_param(qlowmark, long, 0444);424module_param(qlowmark, long, 0444);
425module_param(qovld, long, 0444);
417 426
418static ulong jiffies_till_first_fqs = ULONG_MAX;427static ulong jiffies_till_first_fqs = ULONG_MAX;
419static ulong jiffies_till_next_fqs = ULONG_MAX;428static ulong jiffies_till_next_fqs = ULONG_MAX;
@@ -818,11 +827,12 @@ static __always_inline void rcu_nmi_enter_common(bool irq) · 398 unmodified lines
818 incby = 1;827 incby = 1;
819 } else if (tick_nohz_full_cpu(rdp->cpu) &&828 } else if (tick_nohz_full_cpu(rdp->cpu) &&
820 rdp->dynticks_nmi_nesting == DYNTICK_IRQ_NONIDLE &&829 rdp->dynticks_nmi_nesting == DYNTICK_IRQ_NONIDLE &&
821 READ_ONCE(rdp->rcu_urgent_qs) && !rdp->rcu_forced_tick) {830 READ_ONCE(rdp->rcu_urgent_qs) &&
831 !READ_ONCE(rdp->rcu_forced_tick)) {
822 raw_spin_lock_rcu_node(rdp->mynode);832 raw_spin_lock_rcu_node(rdp->mynode);
823 // Recheck under lock.833 // Recheck under lock.
824 if (rdp->rcu_urgent_qs && !rdp->rcu_forced_tick) {834 if (rdp->rcu_urgent_qs && !rdp->rcu_forced_tick) {
825 rdp->rcu_forced_tick = true;835 WRITE_ONCE(rdp->rcu_forced_tick, true);
826 tick_dep_set_cpu(rdp->cpu, TICK_DEP_BIT_RCU);836 tick_dep_set_cpu(rdp->cpu, TICK_DEP_BIT_RCU);
827 }837 }
828 raw_spin_unlock_rcu_node(rdp->mynode);838 raw_spin_unlock_rcu_node(rdp->mynode);
@@ -899,7 +909,7 @@ static void rcu_disable_urgency_upon_qs(struct rcu_data *rdp) · 70 unmodified lines
899 WRITE_ONCE(rdp->rcu_need_heavy_qs, false);909 WRITE_ONCE(rdp->rcu_need_heavy_qs, false);
900 if (tick_nohz_full_cpu(rdp->cpu) && rdp->rcu_forced_tick) {910 if (tick_nohz_full_cpu(rdp->cpu) && rdp->rcu_forced_tick) {
901 tick_dep_clear_cpu(rdp->cpu, TICK_DEP_BIT_RCU);911 tick_dep_clear_cpu(rdp->cpu, TICK_DEP_BIT_RCU);
902 rdp->rcu_forced_tick = false;912 WRITE_ONCE(rdp->rcu_forced_tick, false);
903 }913 }
904}914}
905 915
@@ -1072,7 +1082,8 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp) · 166 unmodified lines
1072 rnhqp = &per_cpu(rcu_data.rcu_need_heavy_qs, rdp->cpu);1082 rnhqp = &per_cpu(rcu_data.rcu_need_heavy_qs, rdp->cpu);
1073 if (!READ_ONCE(*rnhqp) &&1083 if (!READ_ONCE(*rnhqp) &&
1074 (time_after(jiffies, rcu_state.gp_start + jtsq * 2) ||1084 (time_after(jiffies, rcu_state.gp_start + jtsq * 2) ||
1075 time_after(jiffies, rcu_state.jiffies_resched))) {1085 time_after(jiffies, rcu_state.jiffies_resched) ||
1086 rcu_state.cbovld)) {
1076 WRITE_ONCE(*rnhqp, true);1087 WRITE_ONCE(*rnhqp, true);
1077 /* Store rcu_need_heavy_qs before rcu_urgent_qs. */1088 /* Store rcu_need_heavy_qs before rcu_urgent_qs. */
1078 smp_store_release(ruqp, true);1089 smp_store_release(ruqp, true);
@@ -1089,8 +1100,8 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp) · 10 unmodified lines
1089 * So hit them over the head with the resched_cpu() hammer!1100 * So hit them over the head with the resched_cpu() hammer!
1090 */1101 */
1091 if (tick_nohz_full_cpu(rdp->cpu) &&1102 if (tick_nohz_full_cpu(rdp->cpu) &&
1092 time_after(jiffies,1103 (time_after(jiffies, READ_ONCE(rdp->last_fqs_resched) + jtsq * 3) ||
1093 READ_ONCE(rdp->last_fqs_resched) + jtsq * 3)) {1104 rcu_state.cbovld)) {
1094 WRITE_ONCE(*ruqp, true);1105 WRITE_ONCE(*ruqp, true);
1095 resched_cpu(rdp->cpu);1106 resched_cpu(rdp->cpu);
1096 WRITE_ONCE(rdp->last_fqs_resched, jiffies);1107 WRITE_ONCE(rdp->last_fqs_resched, jiffies);
@@ -1126,8 +1137,9 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp) · 29 unmodified lines
1126static void trace_rcu_this_gp(struct rcu_node *rnp, struct rcu_data *rdp,1137static void trace_rcu_this_gp(struct rcu_node *rnp, struct rcu_data *rdp,
1127 unsigned long gp_seq_req, const char *s)1138 unsigned long gp_seq_req, const char *s)
1128{1139{
1129 trace_rcu_future_grace_period(rcu_state.name, rnp->gp_seq, gp_seq_req,1140 trace_rcu_future_grace_period(rcu_state.name, READ_ONCE(rnp->gp_seq),
1130 rnp->level, rnp->grplo, rnp->grphi, s);1141 gp_seq_req, rnp->level,
1142 rnp->grplo, rnp->grphi, s);
1131}1143}
1132 1144
1133/*1145/*
@@ -1174,7 +1186,7 @@ static bool rcu_start_this_gp(struct rcu_node *rnp_start, struct rcu_data *rdp, · 40 unmodified lines
1174 TPS("Prestarted"));1186 TPS("Prestarted"));
1175 goto unlock_out;1187 goto unlock_out;
1176 }1188 }
1177 rnp->gp_seq_needed = gp_seq_req;1189 WRITE_ONCE(rnp->gp_seq_needed, gp_seq_req);
1178 if (rcu_seq_state(rcu_seq_current(&rnp->gp_seq))) {1190 if (rcu_seq_state(rcu_seq_current(&rnp->gp_seq))) {
1179 /*1191 /*
1180 * We just marked the leaf or internal node, and a1192 * We just marked the leaf or internal node, and a
@@ -1199,18 +1211,18 @@ static bool rcu_start_this_gp(struct rcu_node *rnp_start, struct rcu_data *rdp, · 18 unmodified lines
1199 }1211 }
1200 trace_rcu_this_gp(rnp, rdp, gp_seq_req, TPS("Startedroot"));1212 trace_rcu_this_gp(rnp, rdp, gp_seq_req, TPS("Startedroot"));
1201 WRITE_ONCE(rcu_state.gp_flags, rcu_state.gp_flags | RCU_GP_FLAG_INIT);1213 WRITE_ONCE(rcu_state.gp_flags, rcu_state.gp_flags | RCU_GP_FLAG_INIT);
1202 rcu_state.gp_req_activity = jiffies;1214 WRITE_ONCE(rcu_state.gp_req_activity, jiffies);
1203 if (!rcu_state.gp_kthread) {1215 if (!READ_ONCE(rcu_state.gp_kthread)) {
1204 trace_rcu_this_gp(rnp, rdp, gp_seq_req, TPS("NoGPkthread"));1216 trace_rcu_this_gp(rnp, rdp, gp_seq_req, TPS("NoGPkthread"));
1205 goto unlock_out;1217 goto unlock_out;
1206 }1218 }
1207 trace_rcu_grace_period(rcu_state.name, READ_ONCE(rcu_state.gp_seq), TPS("newreq"));1219 trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq, TPS("newreq"));
1208 ret = true; /* Caller must wake GP kthread. */1220 ret = true; /* Caller must wake GP kthread. */
1209unlock_out:1221unlock_out:
1210 /* Push furthest requested GP to leaf node and rcu_data structure. */1222 /* Push furthest requested GP to leaf node and rcu_data structure. */
1211 if (ULONG_CMP_LT(gp_seq_req, rnp->gp_seq_needed)) {1223 if (ULONG_CMP_LT(gp_seq_req, rnp->gp_seq_needed)) {
1212 rnp_start->gp_seq_needed = rnp->gp_seq_needed;1224 WRITE_ONCE(rnp_start->gp_seq_needed, rnp->gp_seq_needed);
1213 rdp->gp_seq_needed = rnp->gp_seq_needed;1225 WRITE_ONCE(rdp->gp_seq_needed, rnp->gp_seq_needed);
1214 }1226 }
1215 if (rnp != rnp_start)1227 if (rnp != rnp_start)
1216 raw_spin_unlock_rcu_node(rnp);1228 raw_spin_unlock_rcu_node(rnp);
@@ -1235,12 +1247,13 @@ static bool rcu_future_gp_cleanup(struct rcu_node *rnp) · 18 unmodified lines
1235}1247}
1236 1248
1237/*1249/*
1238 * Awaken the grace-period kthread. Don't do a self-awaken (unless in1250 * Awaken the grace-period kthread. Don't do a self-awaken (unless in an
1239 * an interrupt or softirq handler), and don't bother awakening when there1251 * interrupt or softirq handler, in which case we just might immediately
1240 * is nothing for the grace-period kthread to do (as in several CPUs raced1252 * sleep upon return, resulting in a grace-period hang), and don't bother
1241 * to awaken, and we lost), and finally don't try to awaken a kthread that1253 * awakening when there is nothing for the grace-period kthread to do
1242 * has not yet been created. If all those checks are passed, track some1254 * (as in several CPUs raced to awaken, we lost), and finally don't try
1243 * debug information and awaken.1255 * to awaken a kthread that has not yet been created. If all those checks
1256 * are passed, track some debug information and awaken.
1244 *1257 *
1245 * So why do the self-wakeup when in an interrupt or softirq handler1258 * So why do the self-wakeup when in an interrupt or softirq handler
1246 * in the grace-period kthread's context? Because the kthread might have1259 * in the grace-period kthread's context? Because the kthread might have
@@ -1250,10 +1263,10 @@ static bool rcu_future_gp_cleanup(struct rcu_node *rnp) · 3 unmodified lines
1250 */1263 */
1251static void rcu_gp_kthread_wake(void)1264static void rcu_gp_kthread_wake(void)
1252{1265{
1253 if ((current == rcu_state.gp_kthread &&1266 struct task_struct *t = READ_ONCE(rcu_state.gp_kthread);
1254 !in_irq() && !in_serving_softirq()) ||1267
1255 !READ_ONCE(rcu_state.gp_flags) ||1268 if ((current == t && !in_irq() && !in_serving_softirq()) ||
1256 !rcu_state.gp_kthread)1269 !READ_ONCE(rcu_state.gp_flags) || !t)
1257 return;1270 return;
1258 WRITE_ONCE(rcu_state.gp_wake_time, jiffies);1271 WRITE_ONCE(rcu_state.gp_wake_time, jiffies);
1259 WRITE_ONCE(rcu_state.gp_wake_seq, READ_ONCE(rcu_state.gp_seq));1272 WRITE_ONCE(rcu_state.gp_wake_seq, READ_ONCE(rcu_state.gp_seq));
@@ -1321,7 +1334,7 @@ static void rcu_accelerate_cbs_unlocked(struct rcu_node *rnp, · 61 unmodified lines
1321 1334
1322 rcu_lockdep_assert_cblist_protected(rdp);1335 rcu_lockdep_assert_cblist_protected(rdp);
1323 c = rcu_seq_snap(&rcu_state.gp_seq);1336 c = rcu_seq_snap(&rcu_state.gp_seq);
1324 if (!rdp->gpwrap && ULONG_CMP_GE(rdp->gp_seq_needed, c)) {1337 if (!READ_ONCE(rdp->gpwrap) && ULONG_CMP_GE(rdp->gp_seq_needed, c)) {
1325 /* Old request still live, so mark recent callbacks. */1338 /* Old request still live, so mark recent callbacks. */
1326 (void)rcu_segcblist_accelerate(&rdp->cblist, c);1339 (void)rcu_segcblist_accelerate(&rdp->cblist, c);
1327 return;1340 return;
@@ -1386,7 +1399,7 @@ static void __maybe_unused rcu_advance_cbs_nowake(struct rcu_node *rnp, · 58 unmodified lines
1386static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp)1399static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp)
1387{1400{
1388 bool ret = false;1401 bool ret = false;
1389 bool need_gp;1402 bool need_qs;
1390 const bool offloaded = IS_ENABLED(CONFIG_RCU_NOCB_CPU) &&1403 const bool offloaded = IS_ENABLED(CONFIG_RCU_NOCB_CPU) &&
1391 rcu_segcblist_is_offloaded(&rdp->cblist);1404 rcu_segcblist_is_offloaded(&rdp->cblist);
1392 1405
@@ -1400,10 +1413,13 @@ static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp) · 7 unmodified lines
1400 unlikely(READ_ONCE(rdp->gpwrap))) {1413 unlikely(READ_ONCE(rdp->gpwrap))) {
1401 if (!offloaded)1414 if (!offloaded)
1402 ret = rcu_advance_cbs(rnp, rdp); /* Advance CBs. */1415 ret = rcu_advance_cbs(rnp, rdp); /* Advance CBs. */
1416 rdp->core_needs_qs = false;
1403 trace_rcu_grace_period(rcu_state.name, rdp->gp_seq, TPS("cpuend"));1417 trace_rcu_grace_period(rcu_state.name, rdp->gp_seq, TPS("cpuend"));
1404 } else {1418 } else {
1405 if (!offloaded)1419 if (!offloaded)
1406 ret = rcu_accelerate_cbs(rnp, rdp); /* Recent CBs. */1420 ret = rcu_accelerate_cbs(rnp, rdp); /* Recent CBs. */
1421 if (rdp->core_needs_qs)
1422 rdp->core_needs_qs = !!(rnp->qsmask & rdp->grpmask);
1407 }1423 }
1408 1424
1409 /* Now handle the beginnings of any new-to-this-CPU grace periods. */1425 /* Now handle the beginnings of any new-to-this-CPU grace periods. */
@@ -1415,14 +1431,14 @@ static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp) · 5 unmodified lines
1415 * go looking for one.1431 * go looking for one.
1416 */1432 */
1417 trace_rcu_grace_period(rcu_state.name, rnp->gp_seq, TPS("cpustart"));1433 trace_rcu_grace_period(rcu_state.name, rnp->gp_seq, TPS("cpustart"));
1418 need_gp = !!(rnp->qsmask & rdp->grpmask);1434 need_qs = !!(rnp->qsmask & rdp->grpmask);
1419 rdp->cpu_no_qs.b.norm = need_gp;1435 rdp->cpu_no_qs.b.norm = need_qs;
1420 rdp->core_needs_qs = need_gp;1436 rdp->core_needs_qs = need_qs;
1421 zero_cpu_stall_ticks(rdp);1437 zero_cpu_stall_ticks(rdp);
1422 }1438 }
1423 rdp->gp_seq = rnp->gp_seq; /* Remember new grace-period state. */1439 rdp->gp_seq = rnp->gp_seq; /* Remember new grace-period state. */
1424 if (ULONG_CMP_LT(rdp->gp_seq_needed, rnp->gp_seq_needed) || rdp->gpwrap)1440 if (ULONG_CMP_LT(rdp->gp_seq_needed, rnp->gp_seq_needed) || rdp->gpwrap)
1425 rdp->gp_seq_needed = rnp->gp_seq_needed;1441 WRITE_ONCE(rdp->gp_seq_needed, rnp->gp_seq_needed);
1426 WRITE_ONCE(rdp->gpwrap, false);1442 WRITE_ONCE(rdp->gpwrap, false);
1427 rcu_gpnum_ovf(rnp, rdp);1443 rcu_gpnum_ovf(rnp, rdp);
1428 return ret;1444 return ret;
@@ -1651,8 +1667,7 @@ static void rcu_gp_fqs_loop(void) · 222 unmodified lines
1651 WRITE_ONCE(rcu_state.jiffies_kick_kthreads,1667 WRITE_ONCE(rcu_state.jiffies_kick_kthreads,
1652 jiffies + (j ? 3 * j : 2));1668 jiffies + (j ? 3 * j : 2));
1653 }1669 }
1654 trace_rcu_grace_period(rcu_state.name,1670 trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq,
1655 READ_ONCE(rcu_state.gp_seq),
1656 TPS("fqswait"));1671 TPS("fqswait"));
1657 rcu_state.gp_state = RCU_GP_WAIT_FQS;1672 rcu_state.gp_state = RCU_GP_WAIT_FQS;
1658 ret = swait_event_idle_timeout_exclusive(1673 ret = swait_event_idle_timeout_exclusive(
@@ -1666,13 +1681,11 @@ static void rcu_gp_fqs_loop(void) · 7 unmodified lines
1666 /* If time for quiescent-state forcing, do it. */1681 /* If time for quiescent-state forcing, do it. */
1667 if (ULONG_CMP_GE(jiffies, rcu_state.jiffies_force_qs) ||1682 if (ULONG_CMP_GE(jiffies, rcu_state.jiffies_force_qs) ||
1668 (gf & RCU_GP_FLAG_FQS)) {1683 (gf & RCU_GP_FLAG_FQS)) {
1669 trace_rcu_grace_period(rcu_state.name,1684 trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq,
1670 READ_ONCE(rcu_state.gp_seq),
1671 TPS("fqsstart"));1685 TPS("fqsstart"));
1672 rcu_gp_fqs(first_gp_fqs);1686 rcu_gp_fqs(first_gp_fqs);
1673 first_gp_fqs = false;1687 first_gp_fqs = false;
1674 trace_rcu_grace_period(rcu_state.name,1688 trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq,
1675 READ_ONCE(rcu_state.gp_seq),
1676 TPS("fqsend"));1689 TPS("fqsend"));
1677 cond_resched_tasks_rcu_qs();1690 cond_resched_tasks_rcu_qs();
1678 WRITE_ONCE(rcu_state.gp_activity, jiffies);1691 WRITE_ONCE(rcu_state.gp_activity, jiffies);
@@ -1683,8 +1696,7 @@ static void rcu_gp_fqs_loop(void) · 4 unmodified lines
1683 cond_resched_tasks_rcu_qs();1696 cond_resched_tasks_rcu_qs();
1684 WRITE_ONCE(rcu_state.gp_activity, jiffies);1697 WRITE_ONCE(rcu_state.gp_activity, jiffies);
1685 WARN_ON(signal_pending(current));1698 WARN_ON(signal_pending(current));
1686 trace_rcu_grace_period(rcu_state.name,1699 trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq,
1687 READ_ONCE(rcu_state.gp_seq),
1688 TPS("fqswaitsig"));1700 TPS("fqswaitsig"));
1689 ret = 1; /* Keep old FQS timing. */1701 ret = 1; /* Keep old FQS timing. */
1690 j = jiffies;1702 j = jiffies;
@@ -1701,8 +1713,9 @@ static void rcu_gp_fqs_loop(void) · 10 unmodified lines
1701 */1713 */
1702static void rcu_gp_cleanup(void)1714static void rcu_gp_cleanup(void)
1703{1715{
1704 unsigned long gp_duration;1716 int cpu;
1705 bool needgp = false;1717 bool needgp = false;
1718 unsigned long gp_duration;
1706 unsigned long new_gp_seq;1719 unsigned long new_gp_seq;
1707 bool offloaded;1720 bool offloaded;
1708 struct rcu_data *rdp;1721 struct rcu_data *rdp;
@@ -1748,6 +1761,12 @@ static void rcu_gp_cleanup(void) · 39 unmodified lines
1748 needgp = __note_gp_changes(rnp, rdp) || needgp;1761 needgp = __note_gp_changes(rnp, rdp) || needgp;
1749 /* smp_mb() provided by prior unlock-lock pair. */1762 /* smp_mb() provided by prior unlock-lock pair. */
1750 needgp = rcu_future_gp_cleanup(rnp) || needgp;1763 needgp = rcu_future_gp_cleanup(rnp) || needgp;
1764 // Reset overload indication for CPUs no longer overloaded
1765 if (rcu_is_leaf_node(rnp))
1766 for_each_leaf_node_cpu_mask(rnp, cpu, rnp->cbovldmask) {
1767 rdp = per_cpu_ptr(&rcu_data, cpu);
1768 check_cb_ovld_locked(rdp, rnp);
1769 }
1751 sq = rcu_nocb_gp_get(rnp);1770 sq = rcu_nocb_gp_get(rnp);
1752 raw_spin_unlock_irq_rcu_node(rnp);1771 raw_spin_unlock_irq_rcu_node(rnp);
1753 rcu_nocb_gp_cleanup(sq);1772 rcu_nocb_gp_cleanup(sq);
@@ -1774,9 +1793,9 @@ static void rcu_gp_cleanup(void) · 20 unmodified lines
1774 rcu_segcblist_is_offloaded(&rdp->cblist);1793 rcu_segcblist_is_offloaded(&rdp->cblist);
1775 if ((offloaded || !rcu_accelerate_cbs(rnp, rdp)) && needgp) {1794 if ((offloaded || !rcu_accelerate_cbs(rnp, rdp)) && needgp) {
1776 WRITE_ONCE(rcu_state.gp_flags, RCU_GP_FLAG_INIT);1795 WRITE_ONCE(rcu_state.gp_flags, RCU_GP_FLAG_INIT);
1777 rcu_state.gp_req_activity = jiffies;1796 WRITE_ONCE(rcu_state.gp_req_activity, jiffies);
1778 trace_rcu_grace_period(rcu_state.name,1797 trace_rcu_grace_period(rcu_state.name,
1779 READ_ONCE(rcu_state.gp_seq),1798 rcu_state.gp_seq,
1780 TPS("newreq"));1799 TPS("newreq"));
1781 } else {1800 } else {
1782 WRITE_ONCE(rcu_state.gp_flags,1801 WRITE_ONCE(rcu_state.gp_flags,
@@ -1795,8 +1814,7 @@ static int __noreturn rcu_gp_kthread(void *unused) · 12 unmodified lines
1795 1814
1796 /* Handle grace-period start. */1815 /* Handle grace-period start. */
1797 for (;;) {1816 for (;;) {
1798 trace_rcu_grace_period(rcu_state.name,1817 trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq,
1799 READ_ONCE(rcu_state.gp_seq),
1800 TPS("reqwait"));1818 TPS("reqwait"));
1801 rcu_state.gp_state = RCU_GP_WAIT_GPS;1819 rcu_state.gp_state = RCU_GP_WAIT_GPS;
1802 swait_event_idle_exclusive(rcu_state.gp_wq,1820 swait_event_idle_exclusive(rcu_state.gp_wq,
@@ -1809,8 +1827,7 @@ static int __noreturn rcu_gp_kthread(void *unused) · 6 unmodified lines
1809 cond_resched_tasks_rcu_qs();1827 cond_resched_tasks_rcu_qs();
1810 WRITE_ONCE(rcu_state.gp_activity, jiffies);1828 WRITE_ONCE(rcu_state.gp_activity, jiffies);
1811 WARN_ON(signal_pending(current));1829 WARN_ON(signal_pending(current));
1812 trace_rcu_grace_period(rcu_state.name,1830 trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq,
1813 READ_ONCE(rcu_state.gp_seq),
1814 TPS("reqwaitsig"));1831 TPS("reqwaitsig"));
1815 }1832 }
1816 1833
@@ -1881,7 +1898,7 @@ static void rcu_report_qs_rnp(unsigned long mask, struct rcu_node *rnp, · 64 unmodified lines
1881 WARN_ON_ONCE(oldmask); /* Any child must be all zeroed! */1898 WARN_ON_ONCE(oldmask); /* Any child must be all zeroed! */
1882 WARN_ON_ONCE(!rcu_is_leaf_node(rnp) &&1899 WARN_ON_ONCE(!rcu_is_leaf_node(rnp) &&
1883 rcu_preempt_blocked_readers_cgp(rnp));1900 rcu_preempt_blocked_readers_cgp(rnp));
1884 rnp->qsmask &= ~mask;1901 WRITE_ONCE(rnp->qsmask, rnp->qsmask & ~mask);
1885 trace_rcu_quiescent_state_report(rcu_state.name, rnp->gp_seq,1902 trace_rcu_quiescent_state_report(rcu_state.name, rnp->gp_seq,
1886 mask, rnp->qsmask, rnp->level,1903 mask, rnp->qsmask, rnp->level,
1887 rnp->grplo, rnp->grphi,1904 rnp->grplo, rnp->grphi,
@@ -1904,7 +1921,7 @@ static void rcu_report_qs_rnp(unsigned long mask, struct rcu_node *rnp, · 16 unmodified lines
1904 rnp_c = rnp;1921 rnp_c = rnp;
1905 rnp = rnp->parent;1922 rnp = rnp->parent;
1906 raw_spin_lock_irqsave_rcu_node(rnp, flags);1923 raw_spin_lock_irqsave_rcu_node(rnp, flags);
1907 oldmask = rnp_c->qsmask;1924 oldmask = READ_ONCE(rnp_c->qsmask);
1908 }1925 }
1909 1926
1910 /*1927 /*
@@ -1987,6 +2004,8 @@ rcu_report_qs_rdp(int cpu, struct rcu_data *rdp) · 76 unmodified lines
1987 return;2004 return;
1988 }2005 }
1989 mask = rdp->grpmask;2006 mask = rdp->grpmask;
2007 if (rdp->cpu == smp_processor_id())
2008 rdp->core_needs_qs = false;
1990 if ((rnp->qsmask & mask) == 0) {2009 if ((rnp->qsmask & mask) == 0) {
1991 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);2010 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
1992 } else {2011 } else {
@@ -2052,7 +2071,7 @@ int rcutree_dying_cpu(unsigned int cpu) · 59 unmodified lines
2052 return 0;2071 return 0;
2053 2072
2054 blkd = !!(rnp->qsmask & rdp->grpmask);2073 blkd = !!(rnp->qsmask & rdp->grpmask);
2055 trace_rcu_grace_period(rcu_state.name, rnp->gp_seq,2074 trace_rcu_grace_period(rcu_state.name, READ_ONCE(rnp->gp_seq),
2056 blkd ? TPS("cpuofl") : TPS("cpuofl-bgp"));2075 blkd ? TPS("cpuofl") : TPS("cpuofl-bgp"));
2057 return 0;2076 return 0;
2058}2077}
@@ -2294,10 +2313,13 @@ static void force_qs_rnp(int (*f)(struct rcu_data *rdp)) · 235 unmodified lines
2294 struct rcu_data *rdp;2313 struct rcu_data *rdp;
2295 struct rcu_node *rnp;2314 struct rcu_node *rnp;
2296 2315
2316 rcu_state.cbovld = rcu_state.cbovldnext;
2317 rcu_state.cbovldnext = false;
2297 rcu_for_each_leaf_node(rnp) {2318 rcu_for_each_leaf_node(rnp) {
2298 cond_resched_tasks_rcu_qs();2319 cond_resched_tasks_rcu_qs();
2299 mask = 0;2320 mask = 0;
2300 raw_spin_lock_irqsave_rcu_node(rnp, flags);2321 raw_spin_lock_irqsave_rcu_node(rnp, flags);
2322 rcu_state.cbovldnext |= !!rnp->cbovldmask;
2301 if (rnp->qsmask == 0) {2323 if (rnp->qsmask == 0) {
2302 if (!IS_ENABLED(CONFIG_PREEMPT_RCU) ||2324 if (!IS_ENABLED(CONFIG_PREEMPT_RCU) ||
2303 rcu_preempt_blocked_readers_cgp(rnp)) {2325 rcu_preempt_blocked_readers_cgp(rnp)) {
@@ -2579,11 +2601,48 @@ static void rcu_leak_callback(struct rcu_head *rhp) · 275 unmodified lines
2579}2601}
2580 2602
2581/*2603/*
2582 * Helper function for call_rcu() and friends. The cpu argument will2604 * Check and if necessary update the leaf rcu_node structure's
2583 * normally be -1, indicating "currently running CPU". It may specify2605 * ->cbovldmask bit corresponding to the current CPU based on that CPU's
2584 * a CPU only if that CPU is a no-CBs CPU. Currently, only rcu_barrier()2606 * number of queued RCU callbacks. The caller must hold the leaf rcu_node
2585 * is expected to specify a CPU.2607 * structure's ->lock.
2586 */2608 */
2609static void check_cb_ovld_locked(struct rcu_data *rdp, struct rcu_node *rnp)
2610{
2611 raw_lockdep_assert_held_rcu_node(rnp);
2612 if (qovld_calc <= 0)
2613 return; // Early boot and wildcard value set.
2614 if (rcu_segcblist_n_cbs(&rdp->cblist) >= qovld_calc)
2615 WRITE_ONCE(rnp->cbovldmask, rnp->cbovldmask | rdp->grpmask);
2616 else
2617 WRITE_ONCE(rnp->cbovldmask, rnp->cbovldmask & ~rdp->grpmask);
2618}
2619
2620/*
2621 * Check and if necessary update the leaf rcu_node structure's
2622 * ->cbovldmask bit corresponding to the current CPU based on that CPU's
2623 * number of queued RCU callbacks. No locks need be held, but the
2624 * caller must have disabled interrupts.
2625 *
2626 * Note that this function ignores the possibility that there are a lot
2627 * of callbacks all of which have already seen the end of their respective
2628 * grace periods. This omission is due to the need for no-CBs CPUs to
2629 * be holding ->nocb_lock to do this check, which is too heavy for a
2630 * common-case operation.
2631 */
2632static void check_cb_ovld(struct rcu_data *rdp)
2633{
2634 struct rcu_node *const rnp = rdp->mynode;
2635
2636 if (qovld_calc <= 0 ||
2637 ((rcu_segcblist_n_cbs(&rdp->cblist) >= qovld_calc) ==
2638 !!(READ_ONCE(rnp->cbovldmask) & rdp->grpmask)))
2639 return; // Early boot wildcard value or already set correctly.
2640 raw_spin_lock_rcu_node(rnp);
2641 check_cb_ovld_locked(rdp, rnp);
2642 raw_spin_unlock_rcu_node(rnp);
2643}
2644
2645/* Helper function for call_rcu() and friends. */
2587static void2646static void
2588__call_rcu(struct rcu_head *head, rcu_callback_t func)2647__call_rcu(struct rcu_head *head, rcu_callback_t func)
2589{2648{
@@ -2621,9 +2680,10 @@ __call_rcu(struct rcu_head *head, rcu_callback_t func) · 31 unmodified lines
2621 rcu_segcblist_init(&rdp->cblist);2680 rcu_segcblist_init(&rdp->cblist);
2622 }2681 }
2623 2682
2683 check_cb_ovld(rdp);
2624 if (rcu_nocb_try_bypass(rdp, head, &was_alldone, flags))2684 if (rcu_nocb_try_bypass(rdp, head, &was_alldone, flags))
2625 return; // Enqueued onto ->nocb_bypass, so just leave.2685 return; // Enqueued onto ->nocb_bypass, so just leave.
2626 /* If we get here, rcu_nocb_try_bypass() acquired ->nocb_lock. */2686 // If no-CBs CPU gets here, rcu_nocb_try_bypass() acquired ->nocb_lock.
2627 rcu_segcblist_enqueue(&rdp->cblist, head);2687 rcu_segcblist_enqueue(&rdp->cblist, head);
2628 if (__is_kfree_rcu_offset((unsigned long)func))2688 if (__is_kfree_rcu_offset((unsigned long)func))
2629 trace_rcu_kfree_callback(rcu_state.name, head,2689 trace_rcu_kfree_callback(rcu_state.name, head,
@@ -2689,22 +2749,47 @@ EXPORT_SYMBOL_GPL(call_rcu); · 59 unmodified lines
2689#define KFREE_DRAIN_JIFFIES (HZ / 50)2749#define KFREE_DRAIN_JIFFIES (HZ / 50)
2690#define KFREE_N_BATCHES 22750#define KFREE_N_BATCHES 2
2691 2751
2752/*
2753 * This macro defines how many entries the "records" array
2754 * will contain. It is based on the fact that the size of
2755 * kfree_rcu_bulk_data structure becomes exactly one page.
2756 */
2757#define KFREE_BULK_MAX_ENTR ((PAGE_SIZE / sizeof(void *)) - 3)
2758
2759/**
2760 * struct kfree_rcu_bulk_data - single block to store kfree_rcu() pointers
2761 * @nr_records: Number of active pointers in the array
2762 * @records: Array of the kfree_rcu() pointers
2763 * @next: Next bulk object in the block chain
2764 * @head_free_debug: For debug, when CONFIG_DEBUG_OBJECTS_RCU_HEAD is set
2765 */
2766struct kfree_rcu_bulk_data {
2767 unsigned long nr_records;
2768 void *records[KFREE_BULK_MAX_ENTR];
2769 struct kfree_rcu_bulk_data *next;
2770 struct rcu_head *head_free_debug;
2771};
2772
2692/**2773/**
2693 * struct kfree_rcu_cpu_work - single batch of kfree_rcu() requests2774 * struct kfree_rcu_cpu_work - single batch of kfree_rcu() requests
2694 * @rcu_work: Let queue_rcu_work() invoke workqueue handler after grace period2775 * @rcu_work: Let queue_rcu_work() invoke workqueue handler after grace period
2695 * @head_free: List of kfree_rcu() objects waiting for a grace period2776 * @head_free: List of kfree_rcu() objects waiting for a grace period
2777 * @bhead_free: Bulk-List of kfree_rcu() objects waiting for a grace period
2696 * @krcp: Pointer to @kfree_rcu_cpu structure2778 * @krcp: Pointer to @kfree_rcu_cpu structure
2697 */2779 */
2698 2780
2699struct kfree_rcu_cpu_work {2781struct kfree_rcu_cpu_work {
2700 struct rcu_work rcu_work;2782 struct rcu_work rcu_work;
2701 struct rcu_head *head_free;2783 struct rcu_head *head_free;
2784 struct kfree_rcu_bulk_data *bhead_free;
2702 struct kfree_rcu_cpu *krcp;2785 struct kfree_rcu_cpu *krcp;
2703};2786};
2704 2787
2705/**2788/**
2706 * struct kfree_rcu_cpu - batch up kfree_rcu() requests for RCU grace period2789 * struct kfree_rcu_cpu - batch up kfree_rcu() requests for RCU grace period
2707 * @head: List of kfree_rcu() objects not yet waiting for a grace period2790 * @head: List of kfree_rcu() objects not yet waiting for a grace period
2791 * @bhead: Bulk-List of kfree_rcu() objects not yet waiting for a grace period
2792 * @bcached: Keeps at most one object for later reuse when build chain blocks
2708 * @krw_arr: Array of batches of kfree_rcu() objects waiting for a grace period2793 * @krw_arr: Array of batches of kfree_rcu() objects waiting for a grace period
2709 * @lock: Synchronize access to this structure2794 * @lock: Synchronize access to this structure
2710 * @monitor_work: Promote @head to @head_free after KFREE_DRAIN_JIFFIES2795 * @monitor_work: Promote @head to @head_free after KFREE_DRAIN_JIFFIES
@@ -2718,6 +2803,8 @@ struct kfree_rcu_cpu_work { · 7 unmodified lines
2718 */2803 */
2719struct kfree_rcu_cpu {2804struct kfree_rcu_cpu {
2720 struct rcu_head *head;2805 struct rcu_head *head;
2806 struct kfree_rcu_bulk_data *bhead;
2807 struct kfree_rcu_bulk_data *bcached;
2721 struct kfree_rcu_cpu_work krw_arr[KFREE_N_BATCHES];2808 struct kfree_rcu_cpu_work krw_arr[KFREE_N_BATCHES];
2722 spinlock_t lock;2809 spinlock_t lock;
2723 struct delayed_work monitor_work;2810 struct delayed_work monitor_work;
@@ -2727,14 +2814,24 @@ struct kfree_rcu_cpu { · 3 unmodified lines
2727 2814
2728static DEFINE_PER_CPU(struct kfree_rcu_cpu, krc);2815static DEFINE_PER_CPU(struct kfree_rcu_cpu, krc);
2729 2816
2817static __always_inline void
2818debug_rcu_head_unqueue_bulk(struct rcu_head *head)
2819{
2820#ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
2821 for (; head; head = head->next)
2822 debug_rcu_head_unqueue(head);
2823#endif
2824}
2825
2730/*2826/*
2731 * This function is invoked in workqueue context after a grace period.2827 * This function is invoked in workqueue context after a grace period.
2732 * It frees all the objects queued on ->head_free.2828 * It frees all the objects queued on ->bhead_free or ->head_free.
2733 */2829 */
2734static void kfree_rcu_work(struct work_struct *work)2830static void kfree_rcu_work(struct work_struct *work)
2735{2831{
2736 unsigned long flags;2832 unsigned long flags;
2737 struct rcu_head *head, *next;2833 struct rcu_head *head, *next;
2834 struct kfree_rcu_bulk_data *bhead, *bnext;
2738 struct kfree_rcu_cpu *krcp;2835 struct kfree_rcu_cpu *krcp;
2739 struct kfree_rcu_cpu_work *krwp;2836 struct kfree_rcu_cpu_work *krwp;
2740 2837
@@ -2744,22 +2841,44 @@ static void kfree_rcu_work(struct work_struct *work) · 3 unmodified lines
2744 spin_lock_irqsave(&krcp->lock, flags);2841 spin_lock_irqsave(&krcp->lock, flags);
2745 head = krwp->head_free;2842 head = krwp->head_free;
2746 krwp->head_free = NULL;2843 krwp->head_free = NULL;
2844 bhead = krwp->bhead_free;
2845 krwp->bhead_free = NULL;
2747 spin_unlock_irqrestore(&krcp->lock, flags);2846 spin_unlock_irqrestore(&krcp->lock, flags);
2748 2847
2749 // List "head" is now private, so traverse locklessly.2848 /* "bhead" is now private, so traverse locklessly. */
2849 for (; bhead; bhead = bnext) {
2850 bnext = bhead->next;
2851
2852 debug_rcu_head_unqueue_bulk(bhead->head_free_debug);
2853
2854 rcu_lock_acquire(&rcu_callback_map);
2855 trace_rcu_invoke_kfree_bulk_callback(rcu_state.name,
2856 bhead->nr_records, bhead->records);
2857
2858 kfree_bulk(bhead->nr_records, bhead->records);
2859 rcu_lock_release(&rcu_callback_map);
2860
2861 if (cmpxchg(&krcp->bcached, NULL, bhead))
2862 free_page((unsigned long) bhead);
2863
2864 cond_resched_tasks_rcu_qs();
2865 }
2866
2867 /*
2868 * Emergency case only. It can happen under low memory
2869 * condition when an allocation gets failed, so the "bulk"
2870 * path can not be temporary maintained.
2871 */
2750 for (; head; head = next) {2872 for (; head; head = next) {
2751 unsigned long offset = (unsigned long)head->func;2873 unsigned long offset = (unsigned long)head->func;
2752 2874
2753 next = head->next;2875 next = head->next;
2754 // Potentially optimize with kfree_bulk in future.
2755 debug_rcu_head_unqueue(head);2876 debug_rcu_head_unqueue(head);
2756 rcu_lock_acquire(&rcu_callback_map);2877 rcu_lock_acquire(&rcu_callback_map);
2757 trace_rcu_invoke_kfree_callback(rcu_state.name, head, offset);2878 trace_rcu_invoke_kfree_callback(rcu_state.name, head, offset);
2758 2879
2759 if (!WARN_ON_ONCE(!__is_kfree_rcu_offset(offset))) {2880 if (!WARN_ON_ONCE(!__is_kfree_rcu_offset(offset)))
2760 /* Could be optimized with kfree_bulk() in future. */
2761 kfree((void *)head - offset);2881 kfree((void *)head - offset);
2762 }
2763 2882
2764 rcu_lock_release(&rcu_callback_map);2883 rcu_lock_release(&rcu_callback_map);
2765 cond_resched_tasks_rcu_qs();2884 cond_resched_tasks_rcu_qs();
@@ -2774,26 +2893,48 @@ static void kfree_rcu_work(struct work_struct *work) · 8 unmodified lines
2774 */2893 */
2775static inline bool queue_kfree_rcu_work(struct kfree_rcu_cpu *krcp)2894static inline bool queue_kfree_rcu_work(struct kfree_rcu_cpu *krcp)
2776{2895{
2896 struct kfree_rcu_cpu_work *krwp;
2897 bool queued = false;
2777 int i;2898 int i;
2778 struct kfree_rcu_cpu_work *krwp = NULL;
2779 2899
2780 lockdep_assert_held(&krcp->lock);2900 lockdep_assert_held(&krcp->lock);
2781 for (i = 0; i < KFREE_N_BATCHES; i++)
2782 if (!krcp->krw_arr[i].head_free) {
2783 krwp = &(krcp->krw_arr[i]);
2784 break;
2785 }
2786 2901
2787 // If a previous RCU batch is in progress, we cannot immediately2902 for (i = 0; i < KFREE_N_BATCHES; i++) {
2788 // queue another one, so return false to tell caller to retry.2903 krwp = &(krcp->krw_arr[i]);
2789 if (!krwp)
2790 return false;
2791 2904
2792 krwp->head_free = krcp->head;2905 /*
2793 krcp->head = NULL;2906 * Try to detach bhead or head and attach it over any
2794 INIT_RCU_WORK(&krwp->rcu_work, kfree_rcu_work);2907 * available corresponding free channel. It can be that
2795 queue_rcu_work(system_wq, &krwp->rcu_work);2908 * a previous RCU batch is in progress, it means that
2796 return true;2909 * immediately to queue another one is not possible so
2910 * return false to tell caller to retry.
2911 */
2912 if ((krcp->bhead && !krwp->bhead_free) ||
2913 (krcp->head && !krwp->head_free)) {
2914 /* Channel 1. */
2915 if (!krwp->bhead_free) {
2916 krwp->bhead_free = krcp->bhead;
2917 krcp->bhead = NULL;
2918 }
2919
2920 /* Channel 2. */
2921 if (!krwp->head_free) {
2922 krwp->head_free = krcp->head;
2923 krcp->head = NULL;
2924 }
2925
2926 /*
2927 * One work is per one batch, so there are two "free channels",
2928 * "bhead_free" and "head_free" the batch can handle. It can be
2929 * that the work is in the pending state when two channels have
2930 * been detached following each other, one by one.
2931 */
2932 queue_rcu_work(system_wq, &krwp->rcu_work);
2933 queued = true;
2934 }
2935 }
2936
2937 return queued;
2797}2938}
2798 2939
2799static inline void kfree_rcu_drain_unlock(struct kfree_rcu_cpu *krcp,2940static inline void kfree_rcu_drain_unlock(struct kfree_rcu_cpu *krcp,
@@ -2830,19 +2971,65 @@ static void kfree_rcu_monitor(struct work_struct *work) · 30 unmodified lines
2830 spin_unlock_irqrestore(&krcp->lock, flags);2971 spin_unlock_irqrestore(&krcp->lock, flags);
2831}2972}
2832 2973
2974static inline bool
2975kfree_call_rcu_add_ptr_to_bulk(struct kfree_rcu_cpu *krcp,
2976 struct rcu_head *head, rcu_callback_t func)
2977{
2978 struct kfree_rcu_bulk_data *bnode;
2979
2980 if (unlikely(!krcp->initialized))
2981 return false;
2982
2983 lockdep_assert_held(&krcp->lock);
2984
2985 /* Check if a new block is required. */
2986 if (!krcp->bhead ||
2987 krcp->bhead->nr_records == KFREE_BULK_MAX_ENTR) {
2988 bnode = xchg(&krcp->bcached, NULL);
2989 if (!bnode) {
2990 WARN_ON_ONCE(sizeof(struct kfree_rcu_bulk_data) > PAGE_SIZE);
2991
2992 bnode = (struct kfree_rcu_bulk_data *)
2993 __get_free_page(GFP_NOWAIT | __GFP_NOWARN);
2994 }
2995
2996 /* Switch to emergency path. */
2997 if (unlikely(!bnode))
2998 return false;
2999
3000 /* Initialize the new block. */
3001 bnode->nr_records = 0;
3002 bnode->next = krcp->bhead;
3003 bnode->head_free_debug = NULL;
3004
3005 /* Attach it to the head. */
3006 krcp->bhead = bnode;
3007 }
3008
3009#ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
3010 head->func = func;
3011 head->next = krcp->bhead->head_free_debug;
3012 krcp->bhead->head_free_debug = head;
3013#endif
3014
3015 /* Finally insert. */
3016 krcp->bhead->records[krcp->bhead->nr_records++] =
3017 (void *) head - (unsigned long) func;
3018
3019 return true;
3020}
3021
2833/*3022/*
2834 * Queue a request for lazy invocation of kfree() after a grace period.3023 * Queue a request for lazy invocation of kfree_bulk()/kfree() after a grace
3024 * period. Please note there are two paths are maintained, one is the main one
3025 * that uses kfree_bulk() interface and second one is emergency one, that is
3026 * used only when the main path can not be maintained temporary, due to memory
3027 * pressure.
2835 *3028 *
2836 * Each kfree_call_rcu() request is added to a batch. The batch will be drained3029 * Each kfree_call_rcu() request is added to a batch. The batch will be drained
2837 * every KFREE_DRAIN_JIFFIES number of jiffies. All the objects in the batch3030 * every KFREE_DRAIN_JIFFIES number of jiffies. All the objects in the batch will
2838 * will be kfree'd in workqueue context. This allows us to:3031 * be free'd in workqueue context. This allows us to: batch requests together to
2839 *3032 * reduce the number of grace periods during heavy kfree_rcu() load.
2840 * 1. Batch requests together to reduce the number of grace periods during
2841 * heavy kfree_rcu() load.
2842 *
2843 * 2. It makes it possible to use kfree_bulk() on a large number of
2844 * kfree_rcu() requests thus reducing cache misses and the per-object
2845 * overhead of kfree().
2846 */3033 */
2847void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func)3034void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
2848{3035{
@@ -2861,9 +3048,16 @@ void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func) · 12 unmodified lines
2861 __func__, head);3048 __func__, head);
2862 goto unlock_return;3049 goto unlock_return;
2863 }3050 }
2864 head->func = func;3051
2865 head->next = krcp->head;3052 /*
2866 krcp->head = head;3053 * Under high memory pressure GFP_NOWAIT can fail,
3054 * in that case the emergency path is maintained.
3055 */
3056 if (unlikely(!kfree_call_rcu_add_ptr_to_bulk(krcp, head, func))) {
3057 head->func = func;
3058 head->next = krcp->head;
3059 krcp->head = head;
3060 }
2867 3061
2868 // Set timer to drain after KFREE_DRAIN_JIFFIES.3062 // Set timer to drain after KFREE_DRAIN_JIFFIES.
2869 if (rcu_scheduler_active == RCU_SCHEDULER_RUNNING &&3063 if (rcu_scheduler_active == RCU_SCHEDULER_RUNNING &&
@@ -3075,24 +3269,32 @@ static void rcu_barrier_trace(const char *s, int cpu, unsigned long done) · 205 unmodified lines
3075/*3269/*
3076 * RCU callback function for rcu_barrier(). If we are last, wake3270 * RCU callback function for rcu_barrier(). If we are last, wake
3077 * up the task executing rcu_barrier().3271 * up the task executing rcu_barrier().
3272 *
3273 * Note that the value of rcu_state.barrier_sequence must be captured
3274 * before the atomic_dec_and_test(). Otherwise, if this CPU is not last,
3275 * other CPUs might count the value down to zero before this CPU gets
3276 * around to invoking rcu_barrier_trace(), which might result in bogus
3277 * data from the next instance of rcu_barrier().
3078 */3278 */
3079static void rcu_barrier_callback(struct rcu_head *rhp)3279static void rcu_barrier_callback(struct rcu_head *rhp)
3080{3280{
3281 unsigned long __maybe_unused s = rcu_state.barrier_sequence;
3282
3081 if (atomic_dec_and_test(&rcu_state.barrier_cpu_count)) {3283 if (atomic_dec_and_test(&rcu_state.barrier_cpu_count)) {
3082 rcu_barrier_trace(TPS("LastCB"), -1,3284 rcu_barrier_trace(TPS("LastCB"), -1, s);
3083 rcu_state.barrier_sequence);
3084 complete(&rcu_state.barrier_completion);3285 complete(&rcu_state.barrier_completion);
3085 } else {3286 } else {
3086 rcu_barrier_trace(TPS("CB"), -1, rcu_state.barrier_sequence);3287 rcu_barrier_trace(TPS("CB"), -1, s);
3087 }3288 }
3088}3289}
3089 3290
3090/*3291/*
3091 * Called with preemption disabled, and from cross-cpu IRQ context.3292 * Called with preemption disabled, and from cross-cpu IRQ context.
3092 */3293 */
3093static void rcu_barrier_func(void *unused)3294static void rcu_barrier_func(void *cpu_in)
3094{3295{
3095 struct rcu_data *rdp = raw_cpu_ptr(&rcu_data);3296 uintptr_t cpu = (uintptr_t)cpu_in;
3297 struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
3096 3298
3097 rcu_barrier_trace(TPS("IRQ"), -1, rcu_state.barrier_sequence);3299 rcu_barrier_trace(TPS("IRQ"), -1, rcu_state.barrier_sequence);
3098 rdp->barrier_head.func = rcu_barrier_callback;3300 rdp->barrier_head.func = rcu_barrier_callback;
@@ -3119,7 +3321,7 @@ static void rcu_barrier_func(void *unused) · 20 unmodified lines
3119 */3321 */
3120void rcu_barrier(void)3322void rcu_barrier(void)
3121{3323{
3122 int cpu;3324 uintptr_t cpu;
3123 struct rcu_data *rdp;3325 struct rcu_data *rdp;
3124 unsigned long s = rcu_seq_snap(&rcu_state.barrier_sequence);3326 unsigned long s = rcu_seq_snap(&rcu_state.barrier_sequence);
3125 3327
@@ -3142,13 +3344,14 @@ void rcu_barrier(void) · 16 unmodified lines
3142 rcu_barrier_trace(TPS("Inc1"), -1, rcu_state.barrier_sequence);3344 rcu_barrier_trace(TPS("Inc1"), -1, rcu_state.barrier_sequence);
3143 3345
3144 /*3346 /*
3145 * Initialize the count to one rather than to zero in order to3347 * Initialize the count to two rather than to zero in order
3146 * avoid a too-soon return to zero in case of a short grace period3348 * to avoid a too-soon return to zero in case of an immediate
3147 * (or preemption of this task). Exclude CPU-hotplug operations3349 * invocation of the just-enqueued callback (or preemption of
3148 * to ensure that no offline CPU has callbacks queued.3350 * this task). Exclude CPU-hotplug operations to ensure that no
3351 * offline non-offloaded CPU has callbacks queued.
3149 */3352 */
3150 init_completion(&rcu_state.barrier_completion);3353 init_completion(&rcu_state.barrier_completion);
3151 atomic_set(&rcu_state.barrier_cpu_count, 1);3354 atomic_set(&rcu_state.barrier_cpu_count, 2);
3152 get_online_cpus();3355 get_online_cpus();
3153 3356
3154 /*3357 /*
@@ -3158,13 +3361,23 @@ void rcu_barrier(void) · 3 unmodified lines
3158 */3361 */
3159 for_each_possible_cpu(cpu) {3362 for_each_possible_cpu(cpu) {
3160 rdp = per_cpu_ptr(&rcu_data, cpu);3363 rdp = per_cpu_ptr(&rcu_data, cpu);
3161 if (!cpu_online(cpu) &&3364 if (cpu_is_offline(cpu) &&
3162 !rcu_segcblist_is_offloaded(&rdp->cblist))3365 !rcu_segcblist_is_offloaded(&rdp->cblist))
3163 continue;3366 continue;
3164 if (rcu_segcblist_n_cbs(&rdp->cblist)) {3367 if (rcu_segcblist_n_cbs(&rdp->cblist) && cpu_online(cpu)) {
3165 rcu_barrier_trace(TPS("OnlineQ"), cpu,3368 rcu_barrier_trace(TPS("OnlineQ"), cpu,
3166 rcu_state.barrier_sequence);3369 rcu_state.barrier_sequence);
3167 smp_call_function_single(cpu, rcu_barrier_func, NULL, 1);3370 smp_call_function_single(cpu, rcu_barrier_func, (void *)cpu, 1);
3371 } else if (rcu_segcblist_n_cbs(&rdp->cblist) &&
3372 cpu_is_offline(cpu)) {
3373 rcu_barrier_trace(TPS("OfflineNoCBQ"), cpu,
3374 rcu_state.barrier_sequence);
3375 local_irq_disable();
3376 rcu_barrier_func((void *)cpu);
3377 local_irq_enable();
3378 } else if (cpu_is_offline(cpu)) {
3379 rcu_barrier_trace(TPS("OfflineNoCBNoQ"), cpu,
3380 rcu_state.barrier_sequence);
3168 } else {3381 } else {
3169 rcu_barrier_trace(TPS("OnlineNQ"), cpu,3382 rcu_barrier_trace(TPS("OnlineNQ"), cpu,
3170 rcu_state.barrier_sequence);3383 rcu_state.barrier_sequence);
@@ -3176,7 +3389,7 @@ void rcu_barrier(void) · 5 unmodified lines
3176 * Now that we have an rcu_barrier_callback() callback on each3389 * Now that we have an rcu_barrier_callback() callback on each
3177 * CPU, and thus each counted, remove the initial count.3390 * CPU, and thus each counted, remove the initial count.
3178 */3391 */
3179 if (atomic_dec_and_test(&rcu_state.barrier_cpu_count))3392 if (atomic_sub_and_test(2, &rcu_state.barrier_cpu_count))
3180 complete(&rcu_state.barrier_completion);3393 complete(&rcu_state.barrier_completion);
3181 3394
3182 /* Wait for all rcu_barrier_callback() callbacks to be invoked. */3395 /* Wait for all rcu_barrier_callback() callbacks to be invoked. */
@@ -3275,12 +3488,12 @@ int rcutree_prepare_cpu(unsigned int cpu) · 92 unmodified lines
3275 rnp = rdp->mynode;3488 rnp = rdp->mynode;
3276 raw_spin_lock_rcu_node(rnp); /* irqs already disabled. */3489 raw_spin_lock_rcu_node(rnp); /* irqs already disabled. */
3277 rdp->beenonline = true; /* We have now been online. */3490 rdp->beenonline = true; /* We have now been online. */
3278 rdp->gp_seq = rnp->gp_seq;3491 rdp->gp_seq = READ_ONCE(rnp->gp_seq);
3279 rdp->gp_seq_needed = rnp->gp_seq;3492 rdp->gp_seq_needed = rdp->gp_seq;
3280 rdp->cpu_no_qs.b.norm = true;3493 rdp->cpu_no_qs.b.norm = true;
3281 rdp->core_needs_qs = false;3494 rdp->core_needs_qs = false;
3282 rdp->rcu_iw_pending = false;3495 rdp->rcu_iw_pending = false;
3283 rdp->rcu_iw_gp_seq = rnp->gp_seq - 1;3496 rdp->rcu_iw_gp_seq = rdp->gp_seq - 1;
3284 trace_rcu_grace_period(rcu_state.name, rdp->gp_seq, TPS("cpuonl"));3497 trace_rcu_grace_period(rcu_state.name, rdp->gp_seq, TPS("cpuonl"));
3285 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);3498 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
3286 rcu_prepare_kthreads(cpu);3499 rcu_prepare_kthreads(cpu);
@@ -3378,7 +3591,7 @@ void rcu_cpu_starting(unsigned int cpu) · 91 unmodified lines
3378 rnp = rdp->mynode;3591 rnp = rdp->mynode;
3379 mask = rdp->grpmask;3592 mask = rdp->grpmask;
3380 raw_spin_lock_irqsave_rcu_node(rnp, flags);3593 raw_spin_lock_irqsave_rcu_node(rnp, flags);
3381 rnp->qsmaskinitnext |= mask;3594 WRITE_ONCE(rnp->qsmaskinitnext, rnp->qsmaskinitnext | mask);
3382 oldmask = rnp->expmaskinitnext;3595 oldmask = rnp->expmaskinitnext;
3383 rnp->expmaskinitnext |= mask;3596 rnp->expmaskinitnext |= mask;
3384 oldmask ^= rnp->expmaskinitnext;3597 oldmask ^= rnp->expmaskinitnext;
@@ -3431,7 +3644,7 @@ void rcu_report_dead(unsigned int cpu) · 46 unmodified lines
3431 rcu_report_qs_rnp(mask, rnp, rnp->gp_seq, flags);3644 rcu_report_qs_rnp(mask, rnp, rnp->gp_seq, flags);
3432 raw_spin_lock_irqsave_rcu_node(rnp, flags);3645 raw_spin_lock_irqsave_rcu_node(rnp, flags);
3433 }3646 }
3434 rnp->qsmaskinitnext &= ~mask;3647 WRITE_ONCE(rnp->qsmaskinitnext, rnp->qsmaskinitnext & ~mask);
3435 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);3648 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
3436 raw_spin_unlock(&rcu_state.ofl_lock);3649 raw_spin_unlock(&rcu_state.ofl_lock);
3437 3650
@@ -3545,7 +3758,10 @@ static int __init rcu_spawn_gp_kthread(void) · 107 unmodified lines
3545 }3758 }
3546 rnp = rcu_get_root();3759 rnp = rcu_get_root();
3547 raw_spin_lock_irqsave_rcu_node(rnp, flags);3760 raw_spin_lock_irqsave_rcu_node(rnp, flags);
3548 rcu_state.gp_kthread = t;3761 WRITE_ONCE(rcu_state.gp_activity, jiffies);
3762 WRITE_ONCE(rcu_state.gp_req_activity, jiffies);
3763 // Reset .gp_activity and .gp_req_activity before setting .gp_kthread.
3764 smp_store_release(&rcu_state.gp_kthread, t); /* ^^^ */
3549 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);3765 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
3550 wake_up_process(t);3766 wake_up_process(t);
3551 rcu_spawn_nocb_kthreads();3767 rcu_spawn_nocb_kthreads();
@@ -3769,8 +3985,11 @@ static void __init kfree_rcu_batch_init(void) · 217 unmodified lines
3769 struct kfree_rcu_cpu *krcp = per_cpu_ptr(&krc, cpu);3985 struct kfree_rcu_cpu *krcp = per_cpu_ptr(&krc, cpu);
3770 3986
3771 spin_lock_init(&krcp->lock);3987 spin_lock_init(&krcp->lock);
3772 for (i = 0; i < KFREE_N_BATCHES; i++)3988 for (i = 0; i < KFREE_N_BATCHES; i++) {
3989 INIT_RCU_WORK(&krcp->krw_arr[i].rcu_work, kfree_rcu_work);
3773 krcp->krw_arr[i].krcp = krcp;3990 krcp->krw_arr[i].krcp = krcp;
3991 }
3992
3774 INIT_DELAYED_WORK(&krcp->monitor_work, kfree_rcu_monitor);3993 INIT_DELAYED_WORK(&krcp->monitor_work, kfree_rcu_monitor);
3775 krcp->initialized = true;3994 krcp->initialized = true;
3776 }3995 }
@@ -3809,6 +4028,13 @@ void __init rcu_init(void) · 32 unmodified lines
3809 rcu_par_gp_wq = alloc_workqueue("rcu_par_gp", WQ_MEM_RECLAIM, 0);4028 rcu_par_gp_wq = alloc_workqueue("rcu_par_gp", WQ_MEM_RECLAIM, 0);
3810 WARN_ON(!rcu_par_gp_wq);4029 WARN_ON(!rcu_par_gp_wq);
3811 srcu_init();4030 srcu_init();
4031
4032 /* Fill in default value for rcutree.qovld boot parameter. */
4033 /* -After- the rcu_node ->lock fields are initialized! */
4034 if (qovld < 0)
4035 qovld_calc = DEFAULT_RCU_QOVLD_MULT * qhimark;
4036 else
4037 qovld_calc = qovld;
3812}4038}
3813 4039
3814#include "tree_stall.h"4040#include "tree_stall.h"
kernel/rcu/tree.h+4−0
@@ -68,6 +68,8 @@ struct rcu_node { · 67 unmodified lines
68 /* Online CPUs for next expedited GP. */68 /* Online CPUs for next expedited GP. */
69 /* Any CPU that has ever been online will */69 /* Any CPU that has ever been online will */
70 /* have its bit set. */70 /* have its bit set. */
71 unsigned long cbovldmask;
72 /* CPUs experiencing callback overload. */
71 unsigned long ffmask; /* Fully functional CPUs. */73 unsigned long ffmask; /* Fully functional CPUs. */
72 unsigned long grpmask; /* Mask to apply to parent qsmask. */74 unsigned long grpmask; /* Mask to apply to parent qsmask. */
73 /* Only one bit will be set in this mask. */75 /* Only one bit will be set in this mask. */
@@ -321,6 +323,8 @@ struct rcu_state { · 247 unmodified lines
321 atomic_t expedited_need_qs; /* # CPUs left to check in. */323 atomic_t expedited_need_qs; /* # CPUs left to check in. */
322 struct swait_queue_head expedited_wq; /* Wait for check-ins. */324 struct swait_queue_head expedited_wq; /* Wait for check-ins. */
323 int ncpus_snap; /* # CPUs seen last time. */325 int ncpus_snap; /* # CPUs seen last time. */
326 u8 cbovld; /* Callback overload now? */
327 u8 cbovldnext; /* ^ ^ next time? */
324 328
325 unsigned long jiffies_force_qs; /* Time at which to invoke */329 unsigned long jiffies_force_qs; /* Time at which to invoke */
326 /* force_quiescent_state(). */330 /* force_quiescent_state(). */
kernel/rcu/tree_exp.h+9−4
@@ -314,7 +314,7 @@ static bool exp_funnel_lock(unsigned long s) · 313 unmodified lines
314 sync_exp_work_done(s));314 sync_exp_work_done(s));
315 return true;315 return true;
316 }316 }
317 rnp->exp_seq_rq = s; /* Followers can wait on us. */317 WRITE_ONCE(rnp->exp_seq_rq, s); /* Followers can wait on us. */
318 spin_unlock(&rnp->exp_lock);318 spin_unlock(&rnp->exp_lock);
319 trace_rcu_exp_funnel_lock(rcu_state.name, rnp->level,319 trace_rcu_exp_funnel_lock(rcu_state.name, rnp->level,
320 rnp->grplo, rnp->grphi, TPS("nxtlvl"));320 rnp->grplo, rnp->grphi, TPS("nxtlvl"));
@@ -485,6 +485,7 @@ static bool synchronize_rcu_expedited_wait_once(long tlimit) · 164 unmodified lines
485static void synchronize_rcu_expedited_wait(void)485static void synchronize_rcu_expedited_wait(void)
486{486{
487 int cpu;487 int cpu;
488 unsigned long j;
488 unsigned long jiffies_stall;489 unsigned long jiffies_stall;
489 unsigned long jiffies_start;490 unsigned long jiffies_start;
490 unsigned long mask;491 unsigned long mask;
@@ -496,7 +497,7 @@ static void synchronize_rcu_expedited_wait(void) · 5 unmodified lines
496 trace_rcu_exp_grace_period(rcu_state.name, rcu_exp_gp_seq_endval(), TPS("startwait"));497 trace_rcu_exp_grace_period(rcu_state.name, rcu_exp_gp_seq_endval(), TPS("startwait"));
497 jiffies_stall = rcu_jiffies_till_stall_check();498 jiffies_stall = rcu_jiffies_till_stall_check();
498 jiffies_start = jiffies;499 jiffies_start = jiffies;
499 if (IS_ENABLED(CONFIG_NO_HZ_FULL)) {500 if (tick_nohz_full_enabled() && rcu_inkernel_boot_has_ended()) {
500 if (synchronize_rcu_expedited_wait_once(1))501 if (synchronize_rcu_expedited_wait_once(1))
501 return;502 return;
502 rcu_for_each_leaf_node(rnp) {503 rcu_for_each_leaf_node(rnp) {
@@ -508,12 +509,16 @@ static void synchronize_rcu_expedited_wait(void) · 5 unmodified lines
508 tick_dep_set_cpu(cpu, TICK_DEP_BIT_RCU_EXP);509 tick_dep_set_cpu(cpu, TICK_DEP_BIT_RCU_EXP);
509 }510 }
510 }511 }
512 j = READ_ONCE(jiffies_till_first_fqs);
513 if (synchronize_rcu_expedited_wait_once(j + HZ))
514 return;
515 WARN_ON_ONCE(IS_ENABLED(CONFIG_PREEMPT_RT));
511 }516 }
512 517
513 for (;;) {518 for (;;) {
514 if (synchronize_rcu_expedited_wait_once(jiffies_stall))519 if (synchronize_rcu_expedited_wait_once(jiffies_stall))
515 return;520 return;
516 if (rcu_cpu_stall_suppress)521 if (rcu_stall_is_suppressed())
517 continue;522 continue;
518 panic_on_rcu_stall();523 panic_on_rcu_stall();
519 pr_err("INFO: %s detected expedited stalls on CPUs/tasks: {",524 pr_err("INFO: %s detected expedited stalls on CPUs/tasks: {",
@@ -589,7 +594,7 @@ static void rcu_exp_wait_wake(unsigned long s) · 69 unmodified lines
589 spin_lock(&rnp->exp_lock);594 spin_lock(&rnp->exp_lock);
590 /* Recheck, avoid hang in case someone just arrived. */595 /* Recheck, avoid hang in case someone just arrived. */
591 if (ULONG_CMP_LT(rnp->exp_seq_rq, s))596 if (ULONG_CMP_LT(rnp->exp_seq_rq, s))
592 rnp->exp_seq_rq = s;597 WRITE_ONCE(rnp->exp_seq_rq, s);
593 spin_unlock(&rnp->exp_lock);598 spin_unlock(&rnp->exp_lock);
594 }599 }
595 smp_mb(); /* All above changes before wakeup. */600 smp_mb(); /* All above changes before wakeup. */
kernel/rcu/tree_plugin.h+16−9
@@ -56,6 +56,8 @@ static void __init rcu_bootup_announce_oddness(void) · 55 unmodified lines
56 pr_info("\tBoot-time adjustment of callback high-water mark to %ld.\n", qhimark);56 pr_info("\tBoot-time adjustment of callback high-water mark to %ld.\n", qhimark);
57 if (qlowmark != DEFAULT_RCU_QLOMARK)57 if (qlowmark != DEFAULT_RCU_QLOMARK)
58 pr_info("\tBoot-time adjustment of callback low-water mark to %ld.\n", qlowmark);58 pr_info("\tBoot-time adjustment of callback low-water mark to %ld.\n", qlowmark);
59 if (qovld != DEFAULT_RCU_QOVLD)
60 pr_info("\tBoot-time adjustment of callback overload level to %ld.\n", qovld);
59 if (jiffies_till_first_fqs != ULONG_MAX)61 if (jiffies_till_first_fqs != ULONG_MAX)
60 pr_info("\tBoot-time adjustment of first FQS scan delay to %ld jiffies.\n", jiffies_till_first_fqs);62 pr_info("\tBoot-time adjustment of first FQS scan delay to %ld jiffies.\n", jiffies_till_first_fqs);
61 if (jiffies_till_next_fqs != ULONG_MAX)63 if (jiffies_till_next_fqs != ULONG_MAX)
@@ -753,7 +755,7 @@ dump_blkd_tasks(struct rcu_node *rnp, int ncheck) · 691 unmodified lines
753 raw_lockdep_assert_held_rcu_node(rnp);755 raw_lockdep_assert_held_rcu_node(rnp);
754 pr_info("%s: grp: %d-%d level: %d ->gp_seq %ld ->completedqs %ld\n",756 pr_info("%s: grp: %d-%d level: %d ->gp_seq %ld ->completedqs %ld\n",
755 __func__, rnp->grplo, rnp->grphi, rnp->level,757 __func__, rnp->grplo, rnp->grphi, rnp->level,
756 (long)rnp->gp_seq, (long)rnp->completedqs);758 (long)READ_ONCE(rnp->gp_seq), (long)rnp->completedqs);
757 for (rnp1 = rnp; rnp1; rnp1 = rnp1->parent)759 for (rnp1 = rnp; rnp1; rnp1 = rnp1->parent)
758 pr_info("%s: %d:%d ->qsmask %#lx ->qsmaskinit %#lx ->qsmaskinitnext %#lx\n",760 pr_info("%s: %d:%d ->qsmask %#lx ->qsmaskinit %#lx ->qsmaskinitnext %#lx\n",
759 __func__, rnp1->grplo, rnp1->grphi, rnp1->qsmask, rnp1->qsmaskinit, rnp1->qsmaskinitnext);761 __func__, rnp1->grplo, rnp1->grphi, rnp1->qsmask, rnp1->qsmaskinit, rnp1->qsmaskinitnext);
@@ -1032,18 +1034,18 @@ static int rcu_boost_kthread(void *arg) · 272 unmodified lines
1032 1034
1033 trace_rcu_utilization(TPS("Start boost kthread@init"));1035 trace_rcu_utilization(TPS("Start boost kthread@init"));
1034 for (;;) {1036 for (;;) {
1035 rnp->boost_kthread_status = RCU_KTHREAD_WAITING;1037 WRITE_ONCE(rnp->boost_kthread_status, RCU_KTHREAD_WAITING);
1036 trace_rcu_utilization(TPS("End boost kthread@rcu_wait"));1038 trace_rcu_utilization(TPS("End boost kthread@rcu_wait"));
1037 rcu_wait(rnp->boost_tasks || rnp->exp_tasks);1039 rcu_wait(rnp->boost_tasks || rnp->exp_tasks);
1038 trace_rcu_utilization(TPS("Start boost kthread@rcu_wait"));1040 trace_rcu_utilization(TPS("Start boost kthread@rcu_wait"));
1039 rnp->boost_kthread_status = RCU_KTHREAD_RUNNING;1041 WRITE_ONCE(rnp->boost_kthread_status, RCU_KTHREAD_RUNNING);
1040 more2boost = rcu_boost(rnp);1042 more2boost = rcu_boost(rnp);
1041 if (more2boost)1043 if (more2boost)
1042 spincnt++;1044 spincnt++;
1043 else1045 else
1044 spincnt = 0;1046 spincnt = 0;
1045 if (spincnt > 10) {1047 if (spincnt > 10) {
1046 rnp->boost_kthread_status = RCU_KTHREAD_YIELDING;1048 WRITE_ONCE(rnp->boost_kthread_status, RCU_KTHREAD_YIELDING);
1047 trace_rcu_utilization(TPS("End boost kthread@rcu_yield"));1049 trace_rcu_utilization(TPS("End boost kthread@rcu_yield"));
1048 schedule_timeout_interruptible(2);1050 schedule_timeout_interruptible(2);
1049 trace_rcu_utilization(TPS("Start boost kthread@rcu_yield"));1051 trace_rcu_utilization(TPS("Start boost kthread@rcu_yield"));
@@ -1077,12 +1079,12 @@ static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags) · 27 unmodified lines
1077 (rnp->gp_tasks != NULL &&1079 (rnp->gp_tasks != NULL &&
1078 rnp->boost_tasks == NULL &&1080 rnp->boost_tasks == NULL &&
1079 rnp->qsmask == 0 &&1081 rnp->qsmask == 0 &&
1080 ULONG_CMP_GE(jiffies, rnp->boost_time))) {1082 (ULONG_CMP_GE(jiffies, rnp->boost_time) || rcu_state.cbovld))) {
1081 if (rnp->exp_tasks == NULL)1083 if (rnp->exp_tasks == NULL)
1082 rnp->boost_tasks = rnp->gp_tasks;1084 rnp->boost_tasks = rnp->gp_tasks;
1083 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);1085 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
1084 rcu_wake_cond(rnp->boost_kthread_task,1086 rcu_wake_cond(rnp->boost_kthread_task,
1085 rnp->boost_kthread_status);1087 READ_ONCE(rnp->boost_kthread_status));
1086 } else {1088 } else {
1087 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);1089 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
1088 }1090 }
@@ -1486,6 +1488,7 @@ module_param(nocb_nobypass_lim_per_jiffy, int, 0); · 397 unmodified lines
1486 * flag the contention.1488 * flag the contention.
1487 */1489 */
1488static void rcu_nocb_bypass_lock(struct rcu_data *rdp)1490static void rcu_nocb_bypass_lock(struct rcu_data *rdp)
1491 __acquires(&rdp->nocb_bypass_lock)
1489{1492{
1490 lockdep_assert_irqs_disabled();1493 lockdep_assert_irqs_disabled();
1491 if (raw_spin_trylock(&rdp->nocb_bypass_lock))1494 if (raw_spin_trylock(&rdp->nocb_bypass_lock))
@@ -1529,6 +1532,7 @@ static bool rcu_nocb_bypass_trylock(struct rcu_data *rdp) · 37 unmodified lines
1529 * Release the specified rcu_data structure's ->nocb_bypass_lock.1532 * Release the specified rcu_data structure's ->nocb_bypass_lock.
1530 */1533 */
1531static void rcu_nocb_bypass_unlock(struct rcu_data *rdp)1534static void rcu_nocb_bypass_unlock(struct rcu_data *rdp)
1535 __releases(&rdp->nocb_bypass_lock)
1532{1536{
1533 lockdep_assert_irqs_disabled();1537 lockdep_assert_irqs_disabled();
1534 raw_spin_unlock(&rdp->nocb_bypass_lock);1538 raw_spin_unlock(&rdp->nocb_bypass_lock);
@@ -1577,8 +1581,7 @@ static void rcu_nocb_unlock_irqrestore(struct rcu_data *rdp, · 42 unmodified lines
1577static void rcu_lockdep_assert_cblist_protected(struct rcu_data *rdp)1581static void rcu_lockdep_assert_cblist_protected(struct rcu_data *rdp)
1578{1582{
1579 lockdep_assert_irqs_disabled();1583 lockdep_assert_irqs_disabled();
1580 if (rcu_segcblist_is_offloaded(&rdp->cblist) &&1584 if (rcu_segcblist_is_offloaded(&rdp->cblist))
1581 cpu_online(rdp->cpu))
1582 lockdep_assert_held(&rdp->nocb_lock);1585 lockdep_assert_held(&rdp->nocb_lock);
1583}1586}
1584 1587
@@ -1930,6 +1933,7 @@ static void nocb_gp_wait(struct rcu_data *my_rdp) · 345 unmodified lines
1930 struct rcu_data *rdp;1933 struct rcu_data *rdp;
1931 struct rcu_node *rnp;1934 struct rcu_node *rnp;
1932 unsigned long wait_gp_seq = 0; // Suppress "use uninitialized" warning.1935 unsigned long wait_gp_seq = 0; // Suppress "use uninitialized" warning.
1936 bool wasempty = false;
1933 1937
1934 /*1938 /*
1935 * Each pass through the following loop checks for CBs and for the1939 * Each pass through the following loop checks for CBs and for the
@@ -1969,10 +1973,13 @@ static void nocb_gp_wait(struct rcu_data *my_rdp) · 33 unmodified lines
1969 rcu_seq_done(&rnp->gp_seq, cur_gp_seq))) {1973 rcu_seq_done(&rnp->gp_seq, cur_gp_seq))) {
1970 raw_spin_lock_rcu_node(rnp); /* irqs disabled. */1974 raw_spin_lock_rcu_node(rnp); /* irqs disabled. */
1971 needwake_gp = rcu_advance_cbs(rnp, rdp);1975 needwake_gp = rcu_advance_cbs(rnp, rdp);
1976 wasempty = rcu_segcblist_restempty(&rdp->cblist,
1977 RCU_NEXT_READY_TAIL);
1972 raw_spin_unlock_rcu_node(rnp); /* irqs disabled. */1978 raw_spin_unlock_rcu_node(rnp); /* irqs disabled. */
1973 }1979 }
1974 // Need to wait on some grace period?1980 // Need to wait on some grace period?
1975 WARN_ON_ONCE(!rcu_segcblist_restempty(&rdp->cblist,1981 WARN_ON_ONCE(wasempty &&
1982 !rcu_segcblist_restempty(&rdp->cblist,
1976 RCU_NEXT_READY_TAIL));1983 RCU_NEXT_READY_TAIL));
1977 if (rcu_segcblist_nextgp(&rdp->cblist, &cur_gp_seq)) {1984 if (rcu_segcblist_nextgp(&rdp->cblist, &cur_gp_seq)) {
1978 if (!needwait_gp ||1985 if (!needwait_gp ||
kernel/rcu/tree_stall.h+23−18
@@ -102,7 +102,7 @@ static void record_gp_stall_check_time(void) · 101 unmodified lines
102 unsigned long j = jiffies;102 unsigned long j = jiffies;
103 unsigned long j1;103 unsigned long j1;
104 104
105 rcu_state.gp_start = j;105 WRITE_ONCE(rcu_state.gp_start, j);
106 j1 = rcu_jiffies_till_stall_check();106 j1 = rcu_jiffies_till_stall_check();
107 /* Record ->gp_start before ->jiffies_stall. */107 /* Record ->gp_start before ->jiffies_stall. */
108 smp_store_release(&rcu_state.jiffies_stall, j + j1); /* ^^^ */108 smp_store_release(&rcu_state.jiffies_stall, j + j1); /* ^^^ */
@@ -383,7 +383,7 @@ static void print_other_cpu_stall(unsigned long gp_seq) · 274 unmodified lines
383 383
384 /* Kick and suppress, if so configured. */384 /* Kick and suppress, if so configured. */
385 rcu_stall_kick_kthreads();385 rcu_stall_kick_kthreads();
386 if (rcu_cpu_stall_suppress)386 if (rcu_stall_is_suppressed())
387 return;387 return;
388 388
389 /*389 /*
@@ -452,7 +452,7 @@ static void print_cpu_stall(void) · 62 unmodified lines
452 452
453 /* Kick and suppress, if so configured. */453 /* Kick and suppress, if so configured. */
454 rcu_stall_kick_kthreads();454 rcu_stall_kick_kthreads();
455 if (rcu_cpu_stall_suppress)455 if (rcu_stall_is_suppressed())
456 return;456 return;
457 457
458 /*458 /*
@@ -504,7 +504,7 @@ static void check_cpu_stall(struct rcu_data *rdp) · 45 unmodified lines
504 unsigned long js;504 unsigned long js;
505 struct rcu_node *rnp;505 struct rcu_node *rnp;
506 506
507 if ((rcu_cpu_stall_suppress && !rcu_kick_kthreads) ||507 if ((rcu_stall_is_suppressed() && !rcu_kick_kthreads) ||
508 !rcu_gp_in_progress())508 !rcu_gp_in_progress())
509 return;509 return;
510 rcu_stall_kick_kthreads();510 rcu_stall_kick_kthreads();
@@ -578,6 +578,7 @@ void show_rcu_gp_kthreads(void) · 67 unmodified lines
578 unsigned long jw;578 unsigned long jw;
579 struct rcu_data *rdp;579 struct rcu_data *rdp;
580 struct rcu_node *rnp;580 struct rcu_node *rnp;
581 struct task_struct *t = READ_ONCE(rcu_state.gp_kthread);
581 582
582 j = jiffies;583 j = jiffies;
583 ja = j - READ_ONCE(rcu_state.gp_activity);584 ja = j - READ_ONCE(rcu_state.gp_activity);
@@ -585,28 +586,28 @@ void show_rcu_gp_kthreads(void) · 1 unmodified line
585 jw = j - READ_ONCE(rcu_state.gp_wake_time);586 jw = j - READ_ONCE(rcu_state.gp_wake_time);
586 pr_info("%s: wait state: %s(%d) ->state: %#lx delta ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_wake_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_flags %#x\n",587 pr_info("%s: wait state: %s(%d) ->state: %#lx delta ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_wake_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_flags %#x\n",
587 rcu_state.name, gp_state_getname(rcu_state.gp_state),588 rcu_state.name, gp_state_getname(rcu_state.gp_state),
588 rcu_state.gp_state,589 rcu_state.gp_state, t ? t->state : 0x1ffffL,
589 rcu_state.gp_kthread ? rcu_state.gp_kthread->state : 0x1ffffL,
590 ja, jr, jw, (long)READ_ONCE(rcu_state.gp_wake_seq),590 ja, jr, jw, (long)READ_ONCE(rcu_state.gp_wake_seq),
591 (long)READ_ONCE(rcu_state.gp_seq),591 (long)READ_ONCE(rcu_state.gp_seq),
592 (long)READ_ONCE(rcu_get_root()->gp_seq_needed),592 (long)READ_ONCE(rcu_get_root()->gp_seq_needed),
593 READ_ONCE(rcu_state.gp_flags));593 READ_ONCE(rcu_state.gp_flags));
594 rcu_for_each_node_breadth_first(rnp) {594 rcu_for_each_node_breadth_first(rnp) {
595 if (ULONG_CMP_GE(rcu_state.gp_seq, rnp->gp_seq_needed))595 if (ULONG_CMP_GE(READ_ONCE(rcu_state.gp_seq),
596 READ_ONCE(rnp->gp_seq_needed)))
596 continue;597 continue;
597 pr_info("\trcu_node %d:%d ->gp_seq %ld ->gp_seq_needed %ld\n",598 pr_info("\trcu_node %d:%d ->gp_seq %ld ->gp_seq_needed %ld\n",
598 rnp->grplo, rnp->grphi, (long)rnp->gp_seq,599 rnp->grplo, rnp->grphi, (long)READ_ONCE(rnp->gp_seq),
599 (long)rnp->gp_seq_needed);600 (long)READ_ONCE(rnp->gp_seq_needed));
600 if (!rcu_is_leaf_node(rnp))601 if (!rcu_is_leaf_node(rnp))
601 continue;602 continue;
602 for_each_leaf_node_possible_cpu(rnp, cpu) {603 for_each_leaf_node_possible_cpu(rnp, cpu) {
603 rdp = per_cpu_ptr(&rcu_data, cpu);604 rdp = per_cpu_ptr(&rcu_data, cpu);
604 if (rdp->gpwrap ||605 if (READ_ONCE(rdp->gpwrap) ||
605 ULONG_CMP_GE(rcu_state.gp_seq,606 ULONG_CMP_GE(READ_ONCE(rcu_state.gp_seq),
606 rdp->gp_seq_needed))607 READ_ONCE(rdp->gp_seq_needed)))
607 continue;608 continue;
608 pr_info("\tcpu %d ->gp_seq_needed %ld\n",609 pr_info("\tcpu %d ->gp_seq_needed %ld\n",
609 cpu, (long)rdp->gp_seq_needed);610 cpu, (long)READ_ONCE(rdp->gp_seq_needed));
610 }611 }
611 }612 }
612 for_each_possible_cpu(cpu) {613 for_each_possible_cpu(cpu) {
@@ -631,7 +632,9 @@ static void rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp, · 18 unmodified lines
631 static atomic_t warned = ATOMIC_INIT(0);632 static atomic_t warned = ATOMIC_INIT(0);
632 633
633 if (!IS_ENABLED(CONFIG_PROVE_RCU) || rcu_gp_in_progress() ||634 if (!IS_ENABLED(CONFIG_PROVE_RCU) || rcu_gp_in_progress() ||
634 ULONG_CMP_GE(rnp_root->gp_seq, rnp_root->gp_seq_needed))635 ULONG_CMP_GE(READ_ONCE(rnp_root->gp_seq),
636 READ_ONCE(rnp_root->gp_seq_needed)) ||
637 !smp_load_acquire(&rcu_state.gp_kthread)) // Get stable kthread.
635 return;638 return;
636 j = jiffies; /* Expensive access, and in common case don't get here. */639 j = jiffies; /* Expensive access, and in common case don't get here. */
637 if (time_before(j, READ_ONCE(rcu_state.gp_req_activity) + gpssdelay) ||640 if (time_before(j, READ_ONCE(rcu_state.gp_req_activity) + gpssdelay) ||
@@ -642,7 +645,8 @@ static void rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp, · 4 unmodified lines
642 raw_spin_lock_irqsave_rcu_node(rnp, flags);645 raw_spin_lock_irqsave_rcu_node(rnp, flags);
643 j = jiffies;646 j = jiffies;
644 if (rcu_gp_in_progress() ||647 if (rcu_gp_in_progress() ||
645 ULONG_CMP_GE(rnp_root->gp_seq, rnp_root->gp_seq_needed) ||648 ULONG_CMP_GE(READ_ONCE(rnp_root->gp_seq),
649 READ_ONCE(rnp_root->gp_seq_needed)) ||
646 time_before(j, READ_ONCE(rcu_state.gp_req_activity) + gpssdelay) ||650 time_before(j, READ_ONCE(rcu_state.gp_req_activity) + gpssdelay) ||
647 time_before(j, READ_ONCE(rcu_state.gp_activity) + gpssdelay) ||651 time_before(j, READ_ONCE(rcu_state.gp_activity) + gpssdelay) ||
648 atomic_read(&warned)) {652 atomic_read(&warned)) {
@@ -655,9 +659,10 @@ static void rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp, · 6 unmodified lines
655 raw_spin_lock_rcu_node(rnp_root); /* irqs already disabled. */659 raw_spin_lock_rcu_node(rnp_root); /* irqs already disabled. */
656 j = jiffies;660 j = jiffies;
657 if (rcu_gp_in_progress() ||661 if (rcu_gp_in_progress() ||
658 ULONG_CMP_GE(rnp_root->gp_seq, rnp_root->gp_seq_needed) ||662 ULONG_CMP_GE(READ_ONCE(rnp_root->gp_seq),
659 time_before(j, rcu_state.gp_req_activity + gpssdelay) ||663 READ_ONCE(rnp_root->gp_seq_needed)) ||
660 time_before(j, rcu_state.gp_activity + gpssdelay) ||664 time_before(j, READ_ONCE(rcu_state.gp_req_activity) + gpssdelay) ||
665 time_before(j, READ_ONCE(rcu_state.gp_activity) + gpssdelay) ||
661 atomic_xchg(&warned, 1)) {666 atomic_xchg(&warned, 1)) {
662 if (rnp_root != rnp)667 if (rnp_root != rnp)
663 /* irqs remain disabled. */668 /* irqs remain disabled. */
kernel/rcu/update.c+23−5
@@ -183,6 +183,8 @@ void rcu_unexpedite_gp(void) · 182 unmodified lines
183}183}
184EXPORT_SYMBOL_GPL(rcu_unexpedite_gp);184EXPORT_SYMBOL_GPL(rcu_unexpedite_gp);
185 185
186static bool rcu_boot_ended __read_mostly;
187
186/*188/*
187 * Inform RCU of the end of the in-kernel boot sequence.189 * Inform RCU of the end of the in-kernel boot sequence.
188 */190 */
@@ -191,8 +193,18 @@ void rcu_end_inkernel_boot(void) · 2 unmodified lines
191 rcu_unexpedite_gp();193 rcu_unexpedite_gp();
192 if (rcu_normal_after_boot)194 if (rcu_normal_after_boot)
193 WRITE_ONCE(rcu_normal, 1);195 WRITE_ONCE(rcu_normal, 1);
196 rcu_boot_ended = 1;
194}197}
195 198
199/*
200 * Let rcutorture know when it is OK to turn it up to eleven.
201 */
202bool rcu_inkernel_boot_has_ended(void)
203{
204 return rcu_boot_ended;
205}
206EXPORT_SYMBOL_GPL(rcu_inkernel_boot_has_ended);
207
196#endif /* #ifndef CONFIG_TINY_RCU */208#endif /* #ifndef CONFIG_TINY_RCU */
197 209
198/*210/*
@@ -464,13 +476,19 @@ EXPORT_SYMBOL_GPL(rcutorture_sched_setaffinity); · 265 unmodified lines
464#ifdef CONFIG_RCU_STALL_COMMON476#ifdef CONFIG_RCU_STALL_COMMON
465int rcu_cpu_stall_ftrace_dump __read_mostly;477int rcu_cpu_stall_ftrace_dump __read_mostly;
466module_param(rcu_cpu_stall_ftrace_dump, int, 0644);478module_param(rcu_cpu_stall_ftrace_dump, int, 0644);
467int rcu_cpu_stall_suppress __read_mostly; /* 1 = suppress stall warnings. */479int rcu_cpu_stall_suppress __read_mostly; // !0 = suppress stall warnings.
468EXPORT_SYMBOL_GPL(rcu_cpu_stall_suppress);480EXPORT_SYMBOL_GPL(rcu_cpu_stall_suppress);
469module_param(rcu_cpu_stall_suppress, int, 0644);481module_param(rcu_cpu_stall_suppress, int, 0644);
470int rcu_cpu_stall_timeout __read_mostly = CONFIG_RCU_CPU_STALL_TIMEOUT;482int rcu_cpu_stall_timeout __read_mostly = CONFIG_RCU_CPU_STALL_TIMEOUT;
471module_param(rcu_cpu_stall_timeout, int, 0644);483module_param(rcu_cpu_stall_timeout, int, 0644);
472#endif /* #ifdef CONFIG_RCU_STALL_COMMON */484#endif /* #ifdef CONFIG_RCU_STALL_COMMON */
473 485
486// Suppress boot-time RCU CPU stall warnings and rcutorture writer stall
487// warnings. Also used by rcutorture even if stall warnings are excluded.
488int rcu_cpu_stall_suppress_at_boot __read_mostly; // !0 = suppress boot stalls.
489EXPORT_SYMBOL_GPL(rcu_cpu_stall_suppress_at_boot);
490module_param(rcu_cpu_stall_suppress_at_boot, int, 0444);
491
474#ifdef CONFIG_TASKS_RCU492#ifdef CONFIG_TASKS_RCU
475 493
476/*494/*
@@ -528,7 +546,7 @@ void call_rcu_tasks(struct rcu_head *rhp, rcu_callback_t func) · 51 unmodified lines
528 rhp->func = func;546 rhp->func = func;
529 raw_spin_lock_irqsave(&rcu_tasks_cbs_lock, flags);547 raw_spin_lock_irqsave(&rcu_tasks_cbs_lock, flags);
530 needwake = !rcu_tasks_cbs_head;548 needwake = !rcu_tasks_cbs_head;
531 *rcu_tasks_cbs_tail = rhp;549 WRITE_ONCE(*rcu_tasks_cbs_tail, rhp);
532 rcu_tasks_cbs_tail = &rhp->next;550 rcu_tasks_cbs_tail = &rhp->next;
533 raw_spin_unlock_irqrestore(&rcu_tasks_cbs_lock, flags);551 raw_spin_unlock_irqrestore(&rcu_tasks_cbs_lock, flags);
534 /* We can't create the thread unless interrupts are enabled. */552 /* We can't create the thread unless interrupts are enabled. */
@@ -658,7 +676,7 @@ static int __noreturn rcu_tasks_kthread(void *arg) · 123 unmodified lines
658 /* If there were none, wait a bit and start over. */676 /* If there were none, wait a bit and start over. */
659 if (!list) {677 if (!list) {
660 wait_event_interruptible(rcu_tasks_cbs_wq,678 wait_event_interruptible(rcu_tasks_cbs_wq,
661 rcu_tasks_cbs_head);679 READ_ONCE(rcu_tasks_cbs_head));
662 if (!rcu_tasks_cbs_head) {680 if (!rcu_tasks_cbs_head) {
663 WARN_ON(signal_pending(current));681 WARN_ON(signal_pending(current));
664 schedule_timeout_interruptible(HZ/10);682 schedule_timeout_interruptible(HZ/10);
@@ -801,7 +819,7 @@ static int __init rcu_spawn_tasks_kthread(void) · 136 unmodified lines
801core_initcall(rcu_spawn_tasks_kthread);819core_initcall(rcu_spawn_tasks_kthread);
802 820
803/* Do the srcu_read_lock() for the above synchronize_srcu(). */821/* Do the srcu_read_lock() for the above synchronize_srcu(). */
804void exit_tasks_rcu_start(void)822void exit_tasks_rcu_start(void) __acquires(&tasks_rcu_exit_srcu)
805{823{
806 preempt_disable();824 preempt_disable();
807 current->rcu_tasks_idx = __srcu_read_lock(&tasks_rcu_exit_srcu);825 current->rcu_tasks_idx = __srcu_read_lock(&tasks_rcu_exit_srcu);
@@ -809,7 +827,7 @@ void exit_tasks_rcu_start(void) · 1 unmodified line
809}827}
810 828
811/* Do the srcu_read_unlock() for the above synchronize_srcu(). */829/* Do the srcu_read_unlock() for the above synchronize_srcu(). */
812void exit_tasks_rcu_finish(void)830void exit_tasks_rcu_finish(void) __releases(&tasks_rcu_exit_srcu)
813{831{
814 preempt_disable();832 preempt_disable();
815 __srcu_read_unlock(&tasks_rcu_exit_srcu, current->rcu_tasks_idx);833 __srcu_read_unlock(&tasks_rcu_exit_srcu, current->rcu_tasks_idx);
kernel/time/timer.c+4−3
@@ -944,6 +944,7 @@ static struct timer_base *lock_timer_base(struct timer_list *timer, · 943 unmodified lines
944 944
945#define MOD_TIMER_PENDING_ONLY 0x01945#define MOD_TIMER_PENDING_ONLY 0x01
946#define MOD_TIMER_REDUCE 0x02946#define MOD_TIMER_REDUCE 0x02
947#define MOD_TIMER_NOTPENDING 0x04
947 948
948static inline int949static inline int
949__mod_timer(struct timer_list *timer, unsigned long expires, unsigned int options)950__mod_timer(struct timer_list *timer, unsigned long expires, unsigned int options)
@@ -960,7 +961,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, unsigned int option · 10 unmodified lines
960 * the timer is re-modified to have the same timeout or ends up in the961 * the timer is re-modified to have the same timeout or ends up in the
961 * same array bucket then just return:962 * same array bucket then just return:
962 */963 */
963 if (timer_pending(timer)) {964 if (!(options & MOD_TIMER_NOTPENDING) && timer_pending(timer)) {
964 /*965 /*
965 * The downside of this optimization is that it can result in966 * The downside of this optimization is that it can result in
966 * larger granularity than you would get from adding a new967 * larger granularity than you would get from adding a new
@@ -1133,7 +1134,7 @@ EXPORT_SYMBOL(timer_reduce); · 166 unmodified lines
1133void add_timer(struct timer_list *timer)1134void add_timer(struct timer_list *timer)
1134{1135{
1135 BUG_ON(timer_pending(timer));1136 BUG_ON(timer_pending(timer));
1136 mod_timer(timer, timer->expires);1137 __mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING);
1137}1138}
1138EXPORT_SYMBOL(add_timer);1139EXPORT_SYMBOL(add_timer);
1139 1140
@@ -1891,7 +1892,7 @@ signed long __sched schedule_timeout(signed long timeout) · 751 unmodified lines
1891 1892
1892 timer.task = current;1893 timer.task = current;
1893 timer_setup_on_stack(&timer.timer, process_timeout, 0);1894 timer_setup_on_stack(&timer.timer, process_timeout, 0);
1894 __mod_timer(&timer.timer, expire, 0);1895 __mod_timer(&timer.timer, expire, MOD_TIMER_NOTPENDING);
1895 schedule();1896 schedule();
1896 del_singleshot_timer_sync(&timer.timer);1897 del_singleshot_timer_sync(&timer.timer);
1897 1898
kernel/torture.c+25−4
@@ -42,6 +42,9 @@ · 41 unmodified lines
42MODULE_LICENSE("GPL");42MODULE_LICENSE("GPL");
43MODULE_AUTHOR("Paul E. McKenney <paulmck@linux.ibm.com>");43MODULE_AUTHOR("Paul E. McKenney <paulmck@linux.ibm.com>");
44 44
45static bool disable_onoff_at_boot;
46module_param(disable_onoff_at_boot, bool, 0444);
47
45static char *torture_type;48static char *torture_type;
46static int verbose;49static int verbose;
47 50
@@ -84,6 +87,7 @@ bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes, · 36 unmodified lines
84{87{
85 unsigned long delta;88 unsigned long delta;
86 int ret;89 int ret;
90 char *s;
87 unsigned long starttime;91 unsigned long starttime;
88 92
89 if (!cpu_online(cpu) || !cpu_is_hotpluggable(cpu))93 if (!cpu_online(cpu) || !cpu_is_hotpluggable(cpu))
@@ -99,10 +103,16 @@ bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes, · 9 unmodified lines
99 (*n_offl_attempts)++;103 (*n_offl_attempts)++;
100 ret = cpu_down(cpu);104 ret = cpu_down(cpu);
101 if (ret) {105 if (ret) {
106 s = "";
107 if (!rcu_inkernel_boot_has_ended() && ret == -EBUSY) {
108 // PCI probe frequently disables hotplug during boot.
109 (*n_offl_attempts)--;
110 s = " (-EBUSY forgiven during boot)";
111 }
102 if (verbose)112 if (verbose)
103 pr_alert("%s" TORTURE_FLAG113 pr_alert("%s" TORTURE_FLAG
104 "torture_onoff task: offline %d failed: errno %d\n",114 "torture_onoff task: offline %d failed%s: errno %d\n",
105 torture_type, cpu, ret);115 torture_type, cpu, s, ret);
106 } else {116 } else {
107 if (verbose > 1)117 if (verbose > 1)
108 pr_alert("%s" TORTURE_FLAG118 pr_alert("%s" TORTURE_FLAG
@@ -137,6 +147,7 @@ bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes, · 28 unmodified lines
137{147{
138 unsigned long delta;148 unsigned long delta;
139 int ret;149 int ret;
150 char *s;
140 unsigned long starttime;151 unsigned long starttime;
141 152
142 if (cpu_online(cpu) || !cpu_is_hotpluggable(cpu))153 if (cpu_online(cpu) || !cpu_is_hotpluggable(cpu))
@@ -150,10 +161,16 @@ bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes, · 7 unmodified lines
150 (*n_onl_attempts)++;161 (*n_onl_attempts)++;
151 ret = cpu_up(cpu);162 ret = cpu_up(cpu);
152 if (ret) {163 if (ret) {
164 s = "";
165 if (!rcu_inkernel_boot_has_ended() && ret == -EBUSY) {
166 // PCI probe frequently disables hotplug during boot.
167 (*n_onl_attempts)--;
168 s = " (-EBUSY forgiven during boot)";
169 }
153 if (verbose)170 if (verbose)
154 pr_alert("%s" TORTURE_FLAG171 pr_alert("%s" TORTURE_FLAG
155 "torture_onoff task: online %d failed: errno %d\n",172 "torture_onoff task: online %d failed%s: errno %d\n",
156 torture_type, cpu, ret);173 torture_type, cpu, s, ret);
157 } else {174 } else {
158 if (verbose > 1)175 if (verbose > 1)
159 pr_alert("%s" TORTURE_FLAG176 pr_alert("%s" TORTURE_FLAG
@@ -215,6 +232,10 @@ torture_onoff(void *arg) · 55 unmodified lines
215 VERBOSE_TOROUT_STRING("torture_onoff end holdoff");232 VERBOSE_TOROUT_STRING("torture_onoff end holdoff");
216 }233 }
217 while (!torture_must_stop()) {234 while (!torture_must_stop()) {
235 if (disable_onoff_at_boot && !rcu_inkernel_boot_has_ended()) {
236 schedule_timeout_interruptible(HZ / 10);
237 continue;
238 }
218 cpu = (torture_random(&rand) >> 4) % (maxcpu + 1);239 cpu = (torture_random(&rand) >> 4) % (maxcpu + 1);
219 if (!torture_offline(cpu,240 if (!torture_offline(cpu,
220 &n_offline_attempts, &n_offline_successes,241 &n_offline_attempts, &n_offline_successes,
tools/testing/selftests/rcutorture/bin/functions.sh+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
12# Returns 1 if the specified boot-parameter string tells rcutorture to12# Returns 1 if the specified boot-parameter string tells rcutorture to
13# test CPU-hotplug operations.13# test CPU-hotplug operations.
14bootparam_hotplug_cpu () {14bootparam_hotplug_cpu () {
15 echo "$1" | grep -q "rcutorture\.onoff_"15 echo "$1" | grep -q "torture\.onoff_"
16}16}
17 17
18# checkarg --argname argtype $# arg mustmatch cannotmatch18# checkarg --argname argtype $# arg mustmatch cannotmatch
tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh+2−0
@@ -20,7 +20,9 @@ · 19 unmodified lines
20rundir="${1}"20rundir="${1}"
21if test -z "$rundir" -o ! -d "$rundir"21if test -z "$rundir" -o ! -d "$rundir"
22then22then
23 echo Directory "$rundir" not found.
23 echo Usage: $0 directory24 echo Usage: $0 directory
25 exit 1
24fi26fi
25editor=${EDITOR-vi}27editor=${EDITOR-vi}
26 28
tools/testing/selftests/rcutorture/bin/kvm-recheck.sh+16−1
@@ -13,6 +13,9 @@ · 12 unmodified lines
13#13#
14# Authors: Paul E. McKenney <paulmck@linux.ibm.com>14# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
15 15
16T=/tmp/kvm-recheck.sh.$$
17trap 'rm -f $T' 0 2
18
16PATH=`pwd`/tools/testing/selftests/rcutorture/bin:$PATH; export PATH19PATH=`pwd`/tools/testing/selftests/rcutorture/bin:$PATH; export PATH
17. functions.sh20. functions.sh
18for rd in "$@"21for rd in "$@"
@@ -68,4 +71,16 @@ do · 49 unmodified lines
68 fi71 fi
69 done72 done
70done73done
71EDITOR=echo kvm-find-errors.sh "${@: -1}" > /dev/null 2>&174EDITOR=echo kvm-find-errors.sh "${@: -1}" > $T 2>&1
75ret=$?
76builderrors="`tr ' ' '\012' < $T | grep -c '/Make.out.diags'`"
77if test "$builderrors" -gt 0
78then
79 echo $builderrors runs with build errors.
80fi
81runerrors="`tr ' ' '\012' < $T | grep -c '/console.log.diags'`"
82if test "$runerrors" -gt 0
83then
84 echo $runerrors runs with runtime errors.
85fi
86exit $ret
tools/testing/selftests/rcutorture/bin/kvm.sh+1−1
@@ -39,7 +39,7 @@ TORTURE_TRUST_MAKE="" · 38 unmodified lines
39resdir=""39resdir=""
40configs=""40configs=""
41cpus=041cpus=0
42ds=`date +%Y.%m.%d-%H:%M:%S`42ds=`date +%Y.%m.%d-%H.%M.%S`
43jitter="-1"43jitter="-1"
44 44
45usage () {45usage () {
tools/testing/selftests/rcutorture/configs/rcu/CFcommon+2−0
@@ -3,3 +3,5 @@ CONFIG_PRINTK_TIME=y · 2 unmodified lines
3CONFIG_HYPERVISOR_GUEST=y3CONFIG_HYPERVISOR_GUEST=y
4CONFIG_PARAVIRT=y4CONFIG_PARAVIRT=y
5CONFIG_KVM_GUEST=y5CONFIG_KVM_GUEST=y
6CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC=n
7CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY=n
tools/testing/selftests/rcutorture/configs/rcu/TREE10+18−0
@@ -0,0 +1,18 @@
1CONFIG_SMP=y
2CONFIG_NR_CPUS=100
3CONFIG_PREEMPT_NONE=y
4CONFIG_PREEMPT_VOLUNTARY=n
5CONFIG_PREEMPT=n
6#CHECK#CONFIG_TREE_RCU=y
7CONFIG_HZ_PERIODIC=n
8CONFIG_NO_HZ_IDLE=y
9CONFIG_NO_HZ_FULL=n
10CONFIG_RCU_FAST_NO_HZ=n
11CONFIG_RCU_TRACE=n
12CONFIG_RCU_NOCB_CPU=n
13CONFIG_DEBUG_LOCK_ALLOC=n
14CONFIG_PROVE_LOCKING=n
15#CHECK#CONFIG_PROVE_RCU=n
16CONFIG_DEBUG_OBJECTS=n
17CONFIG_DEBUG_OBJECTS_RCU_HEAD=n
18CONFIG_RCU_EXPERT=n