History

Merge branches 'doc.2021.11.30c', 'exp.2021.12.07a', 'fastnohz.2021.11.30c', 'fixes.2021.11.30c', 'nocb.2021.12.09a', 'nolibc.2021.11.30c', 'tasks.2021.12.09a', 'torture.2021.12.07a' and 'torturescript.2021.11.30c' into HEAD

doc.2021.11.30c: Documentation updates. exp.2021.12.07a: Expedited-grace-period fixes. fastnohz.2021.11.30c: Remove CONFIG_RCU_FAST_NO_HZ. fixes.2021.11.30c: Miscellaneous fixes. nocb.2021.12.09a: No-CB CPU updates. nolibc.2021.11.30c: Tiny in-kernel library updates. tasks.2021.12.09a: RCU-tasks updates, including update-side scalability. torture.2021.12.07a: Torture-test in-kernel module updates. torturescript.2021.11.30c: Torture-test scripting updates.

Paul E. McKenney committed 4 years ago

Commit f80fe669 parents 5861dad 81f6d49 bc849e9 1f8da40 10d4703 b0fe9de fd796e4 53b541f 90b21bc51 files · +1089 −719Browse files

Unified · Split

51 files
  1. Documentation/RCU/stallwarn.rst +0 −11
  2. Documentation/admin-guide/kernel-parameters.txt +52 −18
  3. Documentation/timers/no_hz.rst +3 −7
  4. include/linux/rcu_segcblist.h +37 −14
  5. include/linux/rcupdate.h +28 −22
  6. include/linux/rcutiny.h +1 −1
  7. include/linux/srcu.h +2 −1
  8. include/linux/torture.h +2 −7
  9. kernel/locking/locktorture.c +2 −2
  10. kernel/rcu/Kconfig +1 −19
  11. kernel/rcu/rcu_segcblist.c +4 −6
  12. kernel/rcu/rcu_segcblist.h +7 −5
  13. kernel/rcu/rcuscale.c +7 −7
  14. kernel/rcu/rcutorture.c +174 −60
  15. kernel/rcu/refscale.c +24 −26
  16. kernel/rcu/srcutiny.c +1 −1
  17. kernel/rcu/tasks.h +394 −82
  18. kernel/rcu/tree.c +86 −45
  19. kernel/rcu/tree.h +15 −16
  20. kernel/rcu/tree_exp.h +9 −5
  21. kernel/rcu/tree_nocb.h +106 −54
  22. kernel/rcu/tree_plugin.h +33 −217
  23. kernel/rcu/tree_stall.h +2 −25
  24. kernel/scftorture.c +6 −10
  25. kernel/torture.c +2 −2
  26. tools/include/nolibc/nolibc.h +60 −26
  27. tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh +2 −2
  28. tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh +1 −1
  29. tools/testing/selftests/rcutorture/bin/kvm-remote.sh +15 −8
  30. tools/testing/selftests/rcutorture/bin/kvm.sh +6 −3
  31. tools/testing/selftests/rcutorture/bin/parse-build.sh +2 −1
  32. tools/testing/selftests/rcutorture/configs/rcu/TASKS01.boot +1 −0
  33. tools/testing/selftests/rcutorture/configs/rcu/TRACE01.boot +1 −0
  34. tools/testing/selftests/rcutorture/configs/rcu/TRACE02.boot +1 −0
  35. tools/testing/selftests/rcutorture/configs/rcu/TREE01 +0 −1
  36. tools/testing/selftests/rcutorture/configs/rcu/TREE02 +0 −1
  37. tools/testing/selftests/rcutorture/configs/rcu/TREE02.boot +1 −0
  38. tools/testing/selftests/rcutorture/configs/rcu/TREE04 +0 −1
  39. tools/testing/selftests/rcutorture/configs/rcu/TREE05 +0 −1
  40. tools/testing/selftests/rcutorture/configs/rcu/TREE06 +0 −1
  41. tools/testing/selftests/rcutorture/configs/rcu/TREE07 +0 −1
  42. tools/testing/selftests/rcutorture/configs/rcu/TREE08 +0 −1
  43. tools/testing/selftests/rcutorture/configs/rcu/TREE10 +0 −1
  44. tools/testing/selftests/rcutorture/configs/rcu/TREE10.boot +1 −0
  45. tools/testing/selftests/rcutorture/configs/rcuscale/TINY +0 −1
  46. tools/testing/selftests/rcutorture/configs/rcuscale/TRACE01 +0 −1
  47. tools/testing/selftests/rcutorture/configs/rcuscale/TREE +0 −1
  48. tools/testing/selftests/rcutorture/configs/rcuscale/TREE54 +0 −1
  49. tools/testing/selftests/rcutorture/configs/refscale/NOPREEMPT +0 −1
  50. tools/testing/selftests/rcutorture/configs/refscale/PREEMPT +0 −1
  51. tools/testing/selftests/rcutorture/doc/TREE_RCU-kconfig.txt +0 −1
Documentation/RCU/stallwarn.rst+0−11
@@ -254,17 +254,6 @@ period (in this case 2603), the grace-period sequence number (7075), and · 253 unmodified lines
254254 an estimate of the total number of RCU callbacks queued across all CPUs
255255 (625 in this case).
256256
257−In kernels with CONFIG_RCU_FAST_NO_HZ, more information is printed
258−for each CPU::
259−
260− 0: (64628 ticks this GP) idle=dd5/3fffffffffffffff/0 softirq=82/543 last_accelerate: a345/d342 dyntick_enabled: 1
261−
262−The "last_accelerate:" prints the low-order 16 bits (in hex) of the
263−jiffies counter when this CPU last invoked rcu_try_advance_all_cbs()
264−from rcu_needs_cpu() or last invoked rcu_accelerate_cbs() from
265−rcu_prepare_for_idle(). "dyntick_enabled: 1" indicates that dyntick-idle
266−processing is enabled.
267−
268257 If the grace period ends just as the stall warning starts printing,
269258 there will be a spurious stall-warning message, which will include
270259 the following::
Documentation/admin-guide/kernel-parameters.txt+52−18
@@ -4343,19 +4343,30 @@ · 4342 unmodified lines
43434343 Disable the Correctable Errors Collector,
43444344 see CONFIG_RAS_CEC help text.
43454345
4346− rcu_nocbs= [KNL]
4347− The argument is a cpu list, as described above.
4348−
4349− In kernels built with CONFIG_RCU_NOCB_CPU=y, set
4350− the specified list of CPUs to be no-callback CPUs.
4351− Invocation of these CPUs' RCU callbacks will be
4352− offloaded to "rcuox/N" kthreads created for that
4353− purpose, where "x" is "p" for RCU-preempt, and
4354− "s" for RCU-sched, and "N" is the CPU number.
4355− This reduces OS jitter on the offloaded CPUs,
4356− which can be useful for HPC and real-time
4357− workloads. It can also improve energy efficiency
4358− for asymmetric multiprocessors.
4346+ rcu_nocbs[=cpu-list]
4347+ [KNL] The optional argument is a cpu list,
4348+ as described above.
4349+
4350+ In kernels built with CONFIG_RCU_NOCB_CPU=y,
4351+ enable the no-callback CPU mode, which prevents
4352+ such CPUs' callbacks from being invoked in
4353+ softirq context. Invocation of such CPUs' RCU
4354+ callbacks will instead be offloaded to "rcuox/N"
4355+ kthreads created for that purpose, where "x" is
4356+ "p" for RCU-preempt, "s" for RCU-sched, and "g"
4357+ for the kthreads that mediate grace periods; and
4358+ "N" is the CPU number. This reduces OS jitter on
4359+ the offloaded CPUs, which can be useful for HPC
4360+ and real-time workloads. It can also improve
4361+ energy efficiency for asymmetric multiprocessors.
4362+
4363+ If a cpulist is passed as an argument, the specified
4364+ list of CPUs is set to no-callback mode from boot.
4365+
4366+ Otherwise, if the '=' sign and the cpulist
4367+ arguments are omitted, no CPU will be set to
4368+ no-callback mode from boot but the mode may be
4369+ toggled at runtime via cpusets.
43594370
43604371 rcu_nocb_poll [KNL]
43614372 Rather than requiring that offloaded CPUs
@@ -4489,10 +4500,6 @@ · 127 unmodified lines
44894500 on rcutree.qhimark at boot time and to zero to
44904501 disable more aggressive help enlistment.
44914502
4492− rcutree.rcu_idle_gp_delay= [KNL]
4493− Set wakeup interval for idle CPUs that have
4494− RCU callbacks (RCU_FAST_NO_HZ=y).
4495−
44964503 rcutree.rcu_kick_kthreads= [KNL]
44974504 Cause the grace-period kthread to get an extra
44984505 wake_up() if it sleeps three times longer than
@@ -4603,8 +4610,12 @@ · 104 unmodified lines
46034610 in seconds.
46044611
46054612 rcutorture.fwd_progress= [KNL]
4606− Enable RCU grace-period forward-progress testing
4613+ Specifies the number of kthreads to be used
4614+ for RCU grace-period forward-progress testing
46074615 for the types of RCU supporting this notion.
4616+ Defaults to 1 kthread, values less than zero or
4617+ greater than the number of CPUs cause the number
4618+ of CPUs to be used.
46084619
46094620 rcutorture.fwd_progress_div= [KNL]
46104621 Specify the fraction of a CPU-stall-warning
@@ -4805,6 +4816,29 @@ · 194 unmodified lines
48054816 period to instead use normal non-expedited
48064817 grace-period processing.
48074818
4819+ rcupdate.rcu_task_collapse_lim= [KNL]
4820+ Set the maximum number of callbacks present
4821+ at the beginning of a grace period that allows
4822+ the RCU Tasks flavors to collapse back to using
4823+ a single callback queue. This switching only
4824+ occurs when rcupdate.rcu_task_enqueue_lim is
4825+ set to the default value of -1.
4826+
4827+ rcupdate.rcu_task_contend_lim= [KNL]
4828+ Set the minimum number of callback-queuing-time
4829+ lock-contention events per jiffy required to
4830+ cause the RCU Tasks flavors to switch to per-CPU
4831+ callback queuing. This switching only occurs
4832+ when rcupdate.rcu_task_enqueue_lim is set to
4833+ the default value of -1.
4834+
4835+ rcupdate.rcu_task_enqueue_lim= [KNL]
4836+ Set the number of callback queues to use for the
4837+ RCU Tasks family of RCU flavors. The default
4838+ of -1 allows this to be automatically (and
4839+ dynamically) adjusted. This parameter is intended
4840+ for use in testing.
4841+
48084842 rcupdate.rcu_task_ipi_delay= [KNL]
48094843 Set time in jiffies during which RCU tasks will
48104844 avoid sending IPIs, starting with the beginning
Documentation/timers/no_hz.rst+3−7
@@ -184,16 +184,12 @@ There are situations in which idle CPUs cannot be permitted to · 183 unmodified lines
184184 enter either dyntick-idle mode or adaptive-tick mode, the most
185185 common being when that CPU has RCU callbacks pending.
186186
187−The CONFIG_RCU_FAST_NO_HZ=y Kconfig option may be used to cause such CPUs
188−to enter dyntick-idle mode or adaptive-tick mode anyway. In this case,
189−a timer will awaken these CPUs every four jiffies in order to ensure
190−that the RCU callbacks are processed in a timely fashion.
191−
192−Another approach is to offload RCU callback processing to "rcuo" kthreads
187+Avoid this by offloading RCU callback processing to "rcuo" kthreads
193188 using the CONFIG_RCU_NOCB_CPU=y Kconfig option. The specific CPUs to
194189 offload may be selected using The "rcu_nocbs=" kernel boot parameter,
195190 which takes a comma-separated list of CPUs and CPU ranges, for example,
196−"1,3-5" selects CPUs 1, 3, 4, and 5.
191+"1,3-5" selects CPUs 1, 3, 4, and 5. Note that CPUs specified by
192+the "nohz_full" kernel boot parameter are also offloaded.
197193
198194 The offloaded CPUs will never queue RCU callbacks, and therefore RCU
199195 never prevents offloaded CPUs from entering either dyntick-idle mode
include/linux/rcu_segcblist.h+37−14
@@ -69,7 +69,7 @@ struct rcu_cblist { · 68 unmodified lines
6969 *
7070 *
7171 * ----------------------------------------------------------------------------
72− * | SEGCBLIST_SOFTIRQ_ONLY |
72+ * | SEGCBLIST_RCU_CORE |
7373 * | |
7474 * | Callbacks processed by rcu_core() from softirqs or local |
7575 * | rcuc kthread, without holding nocb_lock. |
@@ -77,7 +77,7 @@ struct rcu_cblist { · 1 unmodified line
7777 * |
7878 * v
7979 * ----------------------------------------------------------------------------
80− * | SEGCBLIST_OFFLOADED |
80+ * | SEGCBLIST_RCU_CORE | SEGCBLIST_LOCKING | SEGCBLIST_OFFLOADED |
8181 * | |
8282 * | Callbacks processed by rcu_core() from softirqs or local |
8383 * | rcuc kthread, while holding nocb_lock. Waking up CB and GP kthreads, |
@@ -89,7 +89,9 @@ struct rcu_cblist { · 5 unmodified lines
8989 * | |
9090 * v v
9191 * --------------------------------------- ----------------------------------|
92− * | SEGCBLIST_OFFLOADED | | | SEGCBLIST_OFFLOADED | |
92+ * | SEGCBLIST_RCU_CORE | | | SEGCBLIST_RCU_CORE | |
93+ * | SEGCBLIST_LOCKING | | | SEGCBLIST_LOCKING | |
94+ * | SEGCBLIST_OFFLOADED | | | SEGCBLIST_OFFLOADED | |
9395 * | SEGCBLIST_KTHREAD_CB | | SEGCBLIST_KTHREAD_GP |
9496 * | | | |
9597 * | | | |
@@ -104,9 +106,10 @@ struct rcu_cblist { · 8 unmodified lines
104106 * |
105107 * v
106108 * |--------------------------------------------------------------------------|
107− * | SEGCBLIST_OFFLOADED | |
108− * | SEGCBLIST_KTHREAD_CB | |
109− * | SEGCBLIST_KTHREAD_GP |
109+ * | SEGCBLIST_LOCKING | |
110+ * | SEGCBLIST_OFFLOADED | |
111+ * | SEGCBLIST_KTHREAD_GP | |
112+ * | SEGCBLIST_KTHREAD_CB |
110113 * | |
111114 * | Kthreads handle callbacks holding nocb_lock, local rcu_core() stops |
112115 * | handling callbacks. Enable bypass queueing. |
@@ -120,7 +123,8 @@ struct rcu_cblist { · 7 unmodified lines
120123 *
121124 *
122125 * |--------------------------------------------------------------------------|
123− * | SEGCBLIST_OFFLOADED | |
126+ * | SEGCBLIST_LOCKING | |
127+ * | SEGCBLIST_OFFLOADED | |
124128 * | SEGCBLIST_KTHREAD_CB | |
125129 * | SEGCBLIST_KTHREAD_GP |
126130 * | |
@@ -130,6 +134,22 @@ struct rcu_cblist { · 3 unmodified lines
130134 * |
131135 * v
132136 * |--------------------------------------------------------------------------|
137+ * | SEGCBLIST_RCU_CORE | |
138+ * | SEGCBLIST_LOCKING | |
139+ * | SEGCBLIST_OFFLOADED | |
140+ * | SEGCBLIST_KTHREAD_CB | |
141+ * | SEGCBLIST_KTHREAD_GP |
142+ * | |
143+ * | CB/GP kthreads handle callbacks holding nocb_lock, local rcu_core() |
144+ * | handles callbacks concurrently. Bypass enqueue is enabled. |
145+ * | Invoke RCU core so we make sure not to preempt it in the middle with |
146+ * | leaving some urgent work unattended within a jiffy. |
147+ * ----------------------------------------------------------------------------
148+ * |
149+ * v
150+ * |--------------------------------------------------------------------------|
151+ * | SEGCBLIST_RCU_CORE | |
152+ * | SEGCBLIST_LOCKING | |
133153 * | SEGCBLIST_KTHREAD_CB | |
134154 * | SEGCBLIST_KTHREAD_GP |
135155 * | |
@@ -143,7 +163,9 @@ struct rcu_cblist { · 7 unmodified lines
143163 * | |
144164 * v v
145165 * ---------------------------------------------------------------------------|
146− * | |
166+ * | | |
167+ * | SEGCBLIST_RCU_CORE | | SEGCBLIST_RCU_CORE | |
168+ * | SEGCBLIST_LOCKING | | SEGCBLIST_LOCKING | |
147169 * | SEGCBLIST_KTHREAD_CB | SEGCBLIST_KTHREAD_GP |
148170 * | | |
149171 * | GP kthread woke up and | CB kthread woke up and |
@@ -159,7 +181,7 @@ struct rcu_cblist { · 9 unmodified lines
159181 * |
160182 * v
161183 * ----------------------------------------------------------------------------
162− * | 0 |
184+ * | SEGCBLIST_RCU_CORE | SEGCBLIST_LOCKING |
163185 * | |
164186 * | Callbacks processed by rcu_core() from softirqs or local |
165187 * | rcuc kthread, while holding nocb_lock. Forbid nocb_timer to be armed. |
@@ -168,17 +190,18 @@ struct rcu_cblist { · 2 unmodified lines
168190 * |
169191 * v
170192 * ----------------------------------------------------------------------------
171− * | SEGCBLIST_SOFTIRQ_ONLY |
193+ * | SEGCBLIST_RCU_CORE |
172194 * | |
173195 * | Callbacks processed by rcu_core() from softirqs or local |
174196 * | rcuc kthread, without holding nocb_lock. |
175197 * ----------------------------------------------------------------------------
176198 */
177199 #define SEGCBLIST_ENABLED BIT(0)
178−#define SEGCBLIST_SOFTIRQ_ONLY BIT(1)
179−#define SEGCBLIST_KTHREAD_CB BIT(2)
180−#define SEGCBLIST_KTHREAD_GP BIT(3)
181−#define SEGCBLIST_OFFLOADED BIT(4)
200+#define SEGCBLIST_RCU_CORE BIT(1)
201+#define SEGCBLIST_LOCKING BIT(2)
202+#define SEGCBLIST_KTHREAD_CB BIT(3)
203+#define SEGCBLIST_KTHREAD_GP BIT(4)
204+#define SEGCBLIST_OFFLOADED BIT(5)
182205
183206 struct rcu_segcblist {
184207 struct rcu_head *head;
include/linux/rcupdate.h+28−22
@@ -364,6 +364,12 @@ static inline void rcu_preempt_sleep_check(void) { } · 363 unmodified lines
364364 #define rcu_check_sparse(p, space)
365365 #endif /* #else #ifdef __CHECKER__ */
366366
367+#define __unrcu_pointer(p, local) \
368+({ \
369+ typeof(*p) *local = (typeof(*p) *__force)(p); \
370+ rcu_check_sparse(p, __rcu); \
371+ ((typeof(*p) __force __kernel *)(local)); \
372+})
367373 /**
368374 * unrcu_pointer - mark a pointer as not being RCU protected
369375 * @p: pointer needing to lose its __rcu property
@@ -371,39 +377,35 @@ static inline void rcu_preempt_sleep_check(void) { } · 1 unmodified line
371377 * Converts @p from an __rcu pointer to a __kernel pointer.
372378 * This allows an __rcu pointer to be used with xchg() and friends.
373379 */
374−#define unrcu_pointer(p) \
375−({ \
376− typeof(*p) *_________p1 = (typeof(*p) *__force)(p); \
377− rcu_check_sparse(p, __rcu); \
378− ((typeof(*p) __force __kernel *)(_________p1)); \
379−})
380+#define unrcu_pointer(p) __unrcu_pointer(p, __UNIQUE_ID(rcu))
380381
381−#define __rcu_access_pointer(p, space) \
382+#define __rcu_access_pointer(p, local, space) \
382383 ({ \
383− typeof(*p) *_________p1 = (typeof(*p) *__force)READ_ONCE(p); \
384+ typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
384385 rcu_check_sparse(p, space); \
385− ((typeof(*p) __force __kernel *)(_________p1)); \
386+ ((typeof(*p) __force __kernel *)(local)); \
386387 })
387−#define __rcu_dereference_check(p, c, space) \
388+#define __rcu_dereference_check(p, local, c, space) \
388389 ({ \
389390 /* Dependency order vs. p above. */ \
390− typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
391+ typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
391392 RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \
392393 rcu_check_sparse(p, space); \
393− ((typeof(*p) __force __kernel *)(________p1)); \
394+ ((typeof(*p) __force __kernel *)(local)); \
394395 })
395−#define __rcu_dereference_protected(p, c, space) \
396+#define __rcu_dereference_protected(p, local, c, space) \
396397 ({ \
397398 RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_protected() usage"); \
398399 rcu_check_sparse(p, space); \
399400 ((typeof(*p) __force __kernel *)(p)); \
400401 })
401−#define rcu_dereference_raw(p) \
402+#define __rcu_dereference_raw(p, local) \
402403 ({ \
403404 /* Dependency order vs. p above. */ \
404− typeof(p) ________p1 = READ_ONCE(p); \
405− ((typeof(*p) __force __kernel *)(________p1)); \
405+ typeof(p) local = READ_ONCE(p); \
406+ ((typeof(*p) __force __kernel *)(local)); \
406407 })
408+#define rcu_dereference_raw(p) __rcu_dereference_raw(p, __UNIQUE_ID(rcu))
407409
408410 /**
409411 * RCU_INITIALIZER() - statically initialize an RCU-protected global variable
@@ -490,7 +492,7 @@ do { \ · 80 unmodified lines
490492 * when tearing down multi-linked structures after a grace period
491493 * has elapsed.
492494 */
493−#define rcu_access_pointer(p) __rcu_access_pointer((p), __rcu)
495+#define rcu_access_pointer(p) __rcu_access_pointer((p), __UNIQUE_ID(rcu), __rcu)
494496
495497 /**
496498 * rcu_dereference_check() - rcu_dereference with debug checking
@@ -526,7 +528,8 @@ do { \ · 29 unmodified lines
526528 * annotated as __rcu.
527529 */
528530 #define rcu_dereference_check(p, c) \
529− __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
531+ __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
532+ (c) || rcu_read_lock_held(), __rcu)
530533
531534 /**
532535 * rcu_dereference_bh_check() - rcu_dereference_bh with debug checking
@@ -541,7 +544,8 @@ do { \ · 8 unmodified lines
541544 * rcu_read_lock() but also rcu_read_lock_bh() into account.
542545 */
543546 #define rcu_dereference_bh_check(p, c) \
544− __rcu_dereference_check((p), (c) || rcu_read_lock_bh_held(), __rcu)
547+ __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
548+ (c) || rcu_read_lock_bh_held(), __rcu)
545549
546550 /**
547551 * rcu_dereference_sched_check() - rcu_dereference_sched with debug checking
@@ -556,7 +560,8 @@ do { \ · 8 unmodified lines
556560 * only rcu_read_lock() but also rcu_read_lock_sched() into account.
557561 */
558562 #define rcu_dereference_sched_check(p, c) \
559− __rcu_dereference_check((p), (c) || rcu_read_lock_sched_held(), \
563+ __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
564+ (c) || rcu_read_lock_sched_held(), \
560565 __rcu)
561566
562567 /*
@@ -566,7 +571,8 @@ do { \ · 3 unmodified lines
566571 * The no-tracing version of rcu_dereference_raw() must not call
567572 * rcu_read_lock_held().
568573 */
569−#define rcu_dereference_raw_check(p) __rcu_dereference_check((p), 1, __rcu)
574+#define rcu_dereference_raw_check(p) \
575+ __rcu_dereference_check((p), __UNIQUE_ID(rcu), 1, __rcu)
570576
571577 /**
572578 * rcu_dereference_protected() - fetch RCU pointer when updates prevented
@@ -585,7 +591,7 @@ do { \ · 12 unmodified lines
585591 * but very ugly failures.
586592 */
587593 #define rcu_dereference_protected(p, c) \
588− __rcu_dereference_protected((p), (c), __rcu)
594+ __rcu_dereference_protected((p), __UNIQUE_ID(rcu), (c), __rcu)
589595
590596
591597 /**
include/linux/rcutiny.h+1−1
@@ -85,7 +85,7 @@ static inline void rcu_irq_enter_irqson(void) { } · 84 unmodified lines
8585 static inline void rcu_irq_exit(void) { }
8686 static inline void rcu_irq_exit_check_preempt(void) { }
8787 #define rcu_is_idle_cpu(cpu) \
88− (is_idle_task(current) && !in_nmi() && !in_irq() && !in_serving_softirq())
88+ (is_idle_task(current) && !in_nmi() && !in_hardirq() && !in_serving_softirq())
8989 static inline void exit_rcu(void) { }
9090 static inline bool rcu_preempt_need_deferred_qs(struct task_struct *t)
9191 {
include/linux/srcu.h+2−1
@@ -117,7 +117,8 @@ static inline int srcu_read_lock_held(const struct srcu_struct *ssp) · 116 unmodified lines
117117 * lockdep_is_held() calls.
118118 */
119119 #define srcu_dereference_check(p, ssp, c) \
120− __rcu_dereference_check((p), (c) || srcu_read_lock_held(ssp), __rcu)
120+ __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
121+ (c) || srcu_read_lock_held(ssp), __rcu)
121122
122123 /**
123124 * srcu_dereference - fetch SRCU-protected pointer for later dereferencing
include/linux/torture.h+2−7
@@ -38,13 +38,8 @@ do { \ · 37 unmodified lines
3838 pr_alert("%s" TORTURE_FLAG " %s\n", torture_type, s); \
3939 } \
4040 } while (0)
41−#define VERBOSE_TOROUT_ERRSTRING(s) \
42−do { \
43− if (verbose) { \
44− verbose_torout_sleep(); \
45− pr_alert("%s" TORTURE_FLAG "!!! %s\n", torture_type, s); \
46− } \
47−} while (0)
41+#define TOROUT_ERRSTRING(s) \
42+ pr_alert("%s" TORTURE_FLAG "!!! %s\n", torture_type, s)
4843 void verbose_torout_sleep(void);
4944
5045 #define torture_init_error(firsterr) \
kernel/locking/locktorture.c+2−2
@@ -1047,7 +1047,7 @@ static int __init lock_torture_init(void) · 1046 unmodified lines
10471047 sizeof(writer_tasks[0]),
10481048 GFP_KERNEL);
10491049 if (writer_tasks == NULL) {
1050− VERBOSE_TOROUT_ERRSTRING("writer_tasks: Out of memory");
1050+ TOROUT_ERRSTRING("writer_tasks: Out of memory");
10511051 firsterr = -ENOMEM;
10521052 goto unwind;
10531053 }
@@ -1058,7 +1058,7 @@ static int __init lock_torture_init(void) · 4 unmodified lines
10581058 sizeof(reader_tasks[0]),
10591059 GFP_KERNEL);
10601060 if (reader_tasks == NULL) {
1061− VERBOSE_TOROUT_ERRSTRING("reader_tasks: Out of memory");
1061+ TOROUT_ERRSTRING("reader_tasks: Out of memory");
10621062 kfree(writer_tasks);
10631063 writer_tasks = NULL;
10641064 firsterr = -ENOMEM;
kernel/rcu/Kconfig+1−19
@@ -112,7 +112,7 @@ config RCU_STALL_COMMON · 111 unmodified lines
112112 making these warnings mandatory for the tree variants.
113113
114114 config RCU_NEED_SEGCBLIST
115− def_bool ( TREE_RCU || TREE_SRCU )
115+ def_bool ( TREE_RCU || TREE_SRCU || TASKS_RCU_GENERIC )
116116
117117 config RCU_FANOUT
118118 int "Tree-based hierarchical RCU fanout value"
@@ -169,24 +169,6 @@ config RCU_FANOUT_LEAF · 50 unmodified lines
169169
170170 Take the default if unsure.
171171
172−config RCU_FAST_NO_HZ
173− bool "Accelerate last non-dyntick-idle CPU's grace periods"
174− depends on NO_HZ_COMMON && SMP && RCU_EXPERT
175− default n
176− help
177− This option permits CPUs to enter dynticks-idle state even if
178− they have RCU callbacks queued, and prevents RCU from waking
179− these CPUs up more than roughly once every four jiffies (by
180− default, you can adjust this using the rcutree.rcu_idle_gp_delay
181− parameter), thus improving energy efficiency. On the other
182− hand, this option increases the duration of RCU grace periods,
183− for example, slowing down synchronize_rcu().
184−
185− Say Y if energy efficiency is critically important, and you
186− don't care about increased grace-period durations.
187−
188− Say N if you are unsure.
189−
190172 config RCU_BOOST
191173 bool "Enable RCU priority boosting"
192174 depends on (RT_MUTEXES && PREEMPT_RCU && RCU_EXPERT) || PREEMPT_RT
kernel/rcu/rcu_segcblist.c+4−6
@@ -261,16 +261,14 @@ void rcu_segcblist_disable(struct rcu_segcblist *rsclp) · 260 unmodified lines
261261 }
262262
263263 /*
264− * Mark the specified rcu_segcblist structure as offloaded.
264+ * Mark the specified rcu_segcblist structure as offloaded (or not)
265265 */
266266 void rcu_segcblist_offload(struct rcu_segcblist *rsclp, bool offload)
267267 {
268− if (offload) {
269− rcu_segcblist_clear_flags(rsclp, SEGCBLIST_SOFTIRQ_ONLY);
270− rcu_segcblist_set_flags(rsclp, SEGCBLIST_OFFLOADED);
271− } else {
268+ if (offload)
269+ rcu_segcblist_set_flags(rsclp, SEGCBLIST_LOCKING | SEGCBLIST_OFFLOADED);
270+ else
272271 rcu_segcblist_clear_flags(rsclp, SEGCBLIST_OFFLOADED);
273− }
274272 }
275273
276274 /*
kernel/rcu/rcu_segcblist.h+7−5
@@ -80,11 +80,14 @@ static inline bool rcu_segcblist_is_enabled(struct rcu_segcblist *rsclp) · 79 unmodified lines
8080 return rcu_segcblist_test_flags(rsclp, SEGCBLIST_ENABLED);
8181 }
8282
83−/* Is the specified rcu_segcblist offloaded, or is SEGCBLIST_SOFTIRQ_ONLY set? */
83+/*
84+ * Is the specified rcu_segcblist NOCB offloaded (or in the middle of the
85+ * [de]offloading process)?
86+ */
8487 static inline bool rcu_segcblist_is_offloaded(struct rcu_segcblist *rsclp)
8588 {
8689 if (IS_ENABLED(CONFIG_RCU_NOCB_CPU) &&
87− !rcu_segcblist_test_flags(rsclp, SEGCBLIST_SOFTIRQ_ONLY))
90+ rcu_segcblist_test_flags(rsclp, SEGCBLIST_LOCKING))
8891 return true;
8992
9093 return false;
@@ -92,9 +95,8 @@ static inline bool rcu_segcblist_is_offloaded(struct rcu_segcblist *rsclp) · 1 unmodified line
9295
9396 static inline bool rcu_segcblist_completely_offloaded(struct rcu_segcblist *rsclp)
9497 {
95− int flags = SEGCBLIST_KTHREAD_CB | SEGCBLIST_KTHREAD_GP | SEGCBLIST_OFFLOADED;
96−
97− if (IS_ENABLED(CONFIG_RCU_NOCB_CPU) && (rsclp->flags & flags) == flags)
98+ if (IS_ENABLED(CONFIG_RCU_NOCB_CPU) &&
99+ !rcu_segcblist_test_flags(rsclp, SEGCBLIST_RCU_CORE))
98100 return true;
99101
100102 return false;
kernel/rcu/rcuscale.c+7−7
@@ -50,8 +50,8 @@ MODULE_AUTHOR("Paul E. McKenney <paulmck@linux.ibm.com>"); · 49 unmodified lines
5050 pr_alert("%s" SCALE_FLAG " %s\n", scale_type, s)
5151 #define VERBOSE_SCALEOUT_STRING(s) \
5252 do { if (verbose) pr_alert("%s" SCALE_FLAG " %s\n", scale_type, s); } while (0)
53−#define VERBOSE_SCALEOUT_ERRSTRING(s) \
54− do { if (verbose) pr_alert("%s" SCALE_FLAG "!!! %s\n", scale_type, s); } while (0)
53+#define SCALEOUT_ERRSTRING(s) \
54+ pr_alert("%s" SCALE_FLAG "!!! %s\n", scale_type, s)
5555
5656 /*
5757 * The intended use cases for the nreaders and nwriters module parameters
@@ -514,11 +514,11 @@ rcu_scale_cleanup(void) · 456 unmodified lines
514514 * during the mid-boot phase, so have to wait till the end.
515515 */
516516 if (rcu_gp_is_expedited() && !rcu_gp_is_normal() && !gp_exp)
517− VERBOSE_SCALEOUT_ERRSTRING("All grace periods expedited, no normal ones to measure!");
517+ SCALEOUT_ERRSTRING("All grace periods expedited, no normal ones to measure!");
518518 if (rcu_gp_is_normal() && gp_exp)
519− VERBOSE_SCALEOUT_ERRSTRING("All grace periods normal, no expedited ones to measure!");
519+ SCALEOUT_ERRSTRING("All grace periods normal, no expedited ones to measure!");
520520 if (gp_exp && gp_async)
521− VERBOSE_SCALEOUT_ERRSTRING("No expedited async GPs, so went with async!");
521+ SCALEOUT_ERRSTRING("No expedited async GPs, so went with async!");
522522
523523 if (torture_cleanup_begin())
524524 return;
@@ -845,7 +845,7 @@ rcu_scale_init(void) · 320 unmodified lines
845845 reader_tasks = kcalloc(nrealreaders, sizeof(reader_tasks[0]),
846846 GFP_KERNEL);
847847 if (reader_tasks == NULL) {
848− VERBOSE_SCALEOUT_ERRSTRING("out of memory");
848+ SCALEOUT_ERRSTRING("out of memory");
849849 firsterr = -ENOMEM;
850850 goto unwind;
851851 }
@@ -865,7 +865,7 @@ rcu_scale_init(void) · 13 unmodified lines
865865 kcalloc(nrealwriters, sizeof(*writer_n_durations),
866866 GFP_KERNEL);
867867 if (!writer_tasks || !writer_durations || !writer_n_durations) {
868− VERBOSE_SCALEOUT_ERRSTRING("out of memory");
868+ SCALEOUT_ERRSTRING("out of memory");
869869 firsterr = -ENOMEM;
870870 goto unwind;
871871 }
kernel/rcu/rcutorture.c+174−60
@@ -46,6 +46,7 @@ · 45 unmodified lines
4646 #include <linux/oom.h>
4747 #include <linux/tick.h>
4848 #include <linux/rcupdate_trace.h>
49+#include <linux/nmi.h>
4950
5051 #include "rcu.h"
5152
@@ -53,15 +54,18 @@ MODULE_LICENSE("GPL"); · 1 unmodified line
5354 MODULE_AUTHOR("Paul E. McKenney <paulmck@linux.ibm.com> and Josh Triplett <josh@joshtriplett.org>");
5455
5556 /* Bits for ->extendables field, extendables param, and related definitions. */
56−#define RCUTORTURE_RDR_SHIFT 8 /* Put SRCU index in upper bits. */
57−#define RCUTORTURE_RDR_MASK ((1 << RCUTORTURE_RDR_SHIFT) - 1)
57+#define RCUTORTURE_RDR_SHIFT_1 8 /* Put SRCU index in upper bits. */
58+#define RCUTORTURE_RDR_MASK_1 (1 << RCUTORTURE_RDR_SHIFT_1)
59+#define RCUTORTURE_RDR_SHIFT_2 9 /* Put SRCU index in upper bits. */
60+#define RCUTORTURE_RDR_MASK_2 (1 << RCUTORTURE_RDR_SHIFT_2)
5861 #define RCUTORTURE_RDR_BH 0x01 /* Extend readers by disabling bh. */
5962 #define RCUTORTURE_RDR_IRQ 0x02 /* ... disabling interrupts. */
6063 #define RCUTORTURE_RDR_PREEMPT 0x04 /* ... disabling preemption. */
6164 #define RCUTORTURE_RDR_RBH 0x08 /* ... rcu_read_lock_bh(). */
6265 #define RCUTORTURE_RDR_SCHED 0x10 /* ... rcu_read_lock_sched(). */
63−#define RCUTORTURE_RDR_RCU 0x20 /* ... entering another RCU reader. */
64−#define RCUTORTURE_RDR_NBITS 6 /* Number of bits defined above. */
66+#define RCUTORTURE_RDR_RCU_1 0x20 /* ... entering another RCU reader. */
67+#define RCUTORTURE_RDR_RCU_2 0x40 /* ... entering another RCU reader. */
68+#define RCUTORTURE_RDR_NBITS 7 /* Number of bits defined above. */
6569 #define RCUTORTURE_MAX_EXTEND \
6670 (RCUTORTURE_RDR_BH | RCUTORTURE_RDR_IRQ | RCUTORTURE_RDR_PREEMPT | \
6771 RCUTORTURE_RDR_RBH | RCUTORTURE_RDR_SCHED)
@@ -75,7 +79,7 @@ torture_param(int, fqs_duration, 0, · 7 unmodified lines
7579 "Duration of fqs bursts (us), 0 to disable");
7680 torture_param(int, fqs_holdoff, 0, "Holdoff time within fqs bursts (us)");
7781 torture_param(int, fqs_stutter, 3, "Wait time between fqs bursts (s)");
78−torture_param(bool, fwd_progress, 1, "Test grace-period forward progress");
82+torture_param(int, fwd_progress, 1, "Test grace-period forward progress");
7983 torture_param(int, fwd_progress_div, 4, "Fraction of CPU stall to wait");
8084 torture_param(int, fwd_progress_holdoff, 60,
8185 "Time between forward-progress tests (s)");
@@ -109,6 +113,8 @@ torture_param(int, shutdown_secs, 0, "Shutdown time (s), <= zero to disable."); · 27 unmodified lines
109113 torture_param(int, stall_cpu, 0, "Stall duration (s), zero to disable.");
110114 torture_param(int, stall_cpu_holdoff, 10,
111115 "Time to wait before starting stall (s).");
116+torture_param(bool, stall_no_softlockup, false,
117+ "Avoid softlockup warning during cpu stall.");
112118 torture_param(int, stall_cpu_irqsoff, 0, "Disable interrupts while stalling.");
113119 torture_param(int, stall_cpu_block, 0, "Sleep while stalling.");
114120 torture_param(int, stall_gp_kthread, 0,
@@ -140,7 +146,7 @@ static struct task_struct *stats_task; · 25 unmodified lines
140146 static struct task_struct *fqs_task;
141147 static struct task_struct *boost_tasks[NR_CPUS];
142148 static struct task_struct *stall_task;
143−static struct task_struct *fwd_prog_task;
149+static struct task_struct **fwd_prog_tasks;
144150 static struct task_struct **barrier_cbs_tasks;
145151 static struct task_struct *barrier_task;
146152 static struct task_struct *read_exit_task;
@@ -342,10 +348,12 @@ struct rcu_torture_ops { · 195 unmodified lines
342348 void (*gp_kthread_dbg)(void);
343349 bool (*check_boost_failed)(unsigned long gp_state, int *cpup);
344350 int (*stall_dur)(void);
351+ long cbflood_max;
345352 int irq_capable;
346353 int can_boost;
347354 int extendables;
348355 int slow_gps;
356+ int no_pi_lock;
349357 const char *name;
350358 };
351359
@@ -667,6 +675,7 @@ static struct rcu_torture_ops srcu_ops = { · 315 unmodified lines
667675 .cb_barrier = srcu_torture_barrier,
668676 .stats = srcu_torture_stats,
669677 .irq_capable = 1,
678+ .no_pi_lock = IS_ENABLED(CONFIG_TINY_SRCU),
670679 .name = "srcu"
671680 };
672681
@@ -700,6 +709,7 @@ static struct rcu_torture_ops srcud_ops = { · 27 unmodified lines
700709 .cb_barrier = srcu_torture_barrier,
701710 .stats = srcu_torture_stats,
702711 .irq_capable = 1,
712+ .no_pi_lock = IS_ENABLED(CONFIG_TINY_SRCU),
703713 .name = "srcud"
704714 };
705715
@@ -720,6 +730,7 @@ static struct rcu_torture_ops busted_srcud_ops = { · 14 unmodified lines
720730 .cb_barrier = srcu_torture_barrier,
721731 .stats = srcu_torture_stats,
722732 .irq_capable = 1,
733+ .no_pi_lock = IS_ENABLED(CONFIG_TINY_SRCU),
723734 .extendables = RCUTORTURE_MAX_EXTEND,
724735 .name = "busted_srcud"
725736 };
@@ -831,6 +842,7 @@ static struct rcu_torture_ops tasks_rude_ops = { · 105 unmodified lines
831842 .call = call_rcu_tasks_rude,
832843 .cb_barrier = rcu_barrier_tasks_rude,
833844 .gp_kthread_dbg = show_rcu_tasks_rude_gp_kthread,
845+ .cbflood_max = 50000,
834846 .fqs = NULL,
835847 .stats = NULL,
836848 .irq_capable = 1,
@@ -871,6 +883,7 @@ static struct rcu_torture_ops tasks_tracing_ops = { · 34 unmodified lines
871883 .call = call_rcu_tasks_trace,
872884 .cb_barrier = rcu_barrier_tasks_trace,
873885 .gp_kthread_dbg = show_rcu_tasks_trace_gp_kthread,
886+ .cbflood_max = 50000,
874887 .fqs = NULL,
875888 .stats = NULL,
876889 .irq_capable = 1,
@@ -1420,13 +1433,15 @@ static void rcutorture_one_extend(int *readstate, int newstate, · 543 unmodified lines
14201433 struct rt_read_seg *rtrsp)
14211434 {
14221435 unsigned long flags;
1423− int idxnew = -1;
1424− int idxold = *readstate;
1436+ int idxnew1 = -1;
1437+ int idxnew2 = -1;
1438+ int idxold1 = *readstate;
1439+ int idxold2 = idxold1;
14251440 int statesnew = ~*readstate & newstate;
14261441 int statesold = *readstate & ~newstate;
14271442
1428− WARN_ON_ONCE(idxold < 0);
1429− WARN_ON_ONCE((idxold >> RCUTORTURE_RDR_SHIFT) > 1);
1443+ WARN_ON_ONCE(idxold2 < 0);
1444+ WARN_ON_ONCE((idxold2 >> RCUTORTURE_RDR_SHIFT_2) > 1);
14301445 rtrsp->rt_readstate = newstate;
14311446
14321447 /* First, put new protection in place to avoid critical-section gap. */
@@ -1440,8 +1455,10 @@ static void rcutorture_one_extend(int *readstate, int newstate, · 7 unmodified lines
14401455 preempt_disable();
14411456 if (statesnew & RCUTORTURE_RDR_SCHED)
14421457 rcu_read_lock_sched();
1443− if (statesnew & RCUTORTURE_RDR_RCU)
1444− idxnew = cur_ops->readlock() << RCUTORTURE_RDR_SHIFT;
1458+ if (statesnew & RCUTORTURE_RDR_RCU_1)
1459+ idxnew1 = (cur_ops->readlock() & 0x1) << RCUTORTURE_RDR_SHIFT_1;
1460+ if (statesnew & RCUTORTURE_RDR_RCU_2)
1461+ idxnew2 = (cur_ops->readlock() & 0x1) << RCUTORTURE_RDR_SHIFT_2;
14451462
14461463 /*
14471464 * Next, remove old protection, in decreasing order of strength
@@ -1460,12 +1477,20 @@ static void rcutorture_one_extend(int *readstate, int newstate, · 12 unmodified lines
14601477 local_bh_enable();
14611478 if (statesold & RCUTORTURE_RDR_RBH)
14621479 rcu_read_unlock_bh();
1463− if (statesold & RCUTORTURE_RDR_RCU) {
1464− bool lockit = !statesnew && !(torture_random(trsp) & 0xffff);
1480+ if (statesold & RCUTORTURE_RDR_RCU_2) {
1481+ cur_ops->readunlock((idxold2 >> RCUTORTURE_RDR_SHIFT_2) & 0x1);
1482+ WARN_ON_ONCE(idxnew2 != -1);
1483+ idxold2 = 0;
1484+ }
1485+ if (statesold & RCUTORTURE_RDR_RCU_1) {
1486+ bool lockit;
14651487
1488+ lockit = !cur_ops->no_pi_lock && !statesnew && !(torture_random(trsp) & 0xffff);
14661489 if (lockit)
14671490 raw_spin_lock_irqsave(&current->pi_lock, flags);
1468− cur_ops->readunlock(idxold >> RCUTORTURE_RDR_SHIFT);
1491+ cur_ops->readunlock((idxold1 >> RCUTORTURE_RDR_SHIFT_1) & 0x1);
1492+ WARN_ON_ONCE(idxnew1 != -1);
1493+ idxold1 = 0;
14691494 if (lockit)
14701495 raw_spin_unlock_irqrestore(&current->pi_lock, flags);
14711496 }
@@ -1475,13 +1500,19 @@ static void rcutorture_one_extend(int *readstate, int newstate, · 3 unmodified lines
14751500 cur_ops->read_delay(trsp, rtrsp);
14761501
14771502 /* Update the reader state. */
1478− if (idxnew == -1)
1479− idxnew = idxold & ~RCUTORTURE_RDR_MASK;
1480− WARN_ON_ONCE(idxnew < 0);
1481− WARN_ON_ONCE((idxnew >> RCUTORTURE_RDR_SHIFT) > 1);
1482− *readstate = idxnew | newstate;
1483− WARN_ON_ONCE((*readstate >> RCUTORTURE_RDR_SHIFT) < 0);
1484− WARN_ON_ONCE((*readstate >> RCUTORTURE_RDR_SHIFT) > 1);
1503+ if (idxnew1 == -1)
1504+ idxnew1 = idxold1 & RCUTORTURE_RDR_MASK_1;
1505+ WARN_ON_ONCE(idxnew1 < 0);
1506+ if (WARN_ON_ONCE((idxnew1 >> RCUTORTURE_RDR_SHIFT_1) > 1))
1507+ pr_info("Unexpected idxnew1 value of %#x\n", idxnew1);
1508+ if (idxnew2 == -1)
1509+ idxnew2 = idxold2 & RCUTORTURE_RDR_MASK_2;
1510+ WARN_ON_ONCE(idxnew2 < 0);
1511+ WARN_ON_ONCE((idxnew2 >> RCUTORTURE_RDR_SHIFT_2) > 1);
1512+ *readstate = idxnew1 | idxnew2 | newstate;
1513+ WARN_ON_ONCE(*readstate < 0);
1514+ if (WARN_ON_ONCE((*readstate >> RCUTORTURE_RDR_SHIFT_2) > 1))
1515+ pr_info("Unexpected idxnew2 value of %#x\n", idxnew2);
14851516 }
14861517
14871518 /* Return the biggest extendables mask given current RCU and boot parameters. */
@@ -1491,7 +1522,7 @@ static int rcutorture_extend_mask_max(void) · 3 unmodified lines
14911522
14921523 WARN_ON_ONCE(extendables & ~RCUTORTURE_MAX_EXTEND);
14931524 mask = extendables & RCUTORTURE_MAX_EXTEND & cur_ops->extendables;
1494− mask = mask | RCUTORTURE_RDR_RCU;
1525+ mask = mask | RCUTORTURE_RDR_RCU_1 | RCUTORTURE_RDR_RCU_2;
14951526 return mask;
14961527 }
14971528
@@ -1506,13 +1537,21 @@ rcutorture_extend_mask(int oldmask, struct torture_random_state *trsp) · 8 unmodified lines
15061537 unsigned long preempts_irq = preempts | RCUTORTURE_RDR_IRQ;
15071538 unsigned long bhs = RCUTORTURE_RDR_BH | RCUTORTURE_RDR_RBH;
15081539
1509− WARN_ON_ONCE(mask >> RCUTORTURE_RDR_SHIFT);
1540+ WARN_ON_ONCE(mask >> RCUTORTURE_RDR_SHIFT_1);
15101541 /* Mostly only one bit (need preemption!), sometimes lots of bits. */
15111542 if (!(randmask1 & 0x7))
15121543 mask = mask & randmask2;
15131544 else
15141545 mask = mask & (1 << (randmask2 % RCUTORTURE_RDR_NBITS));
15151546
1547+ // Can't have nested RCU reader without outer RCU reader.
1548+ if (!(mask & RCUTORTURE_RDR_RCU_1) && (mask & RCUTORTURE_RDR_RCU_2)) {
1549+ if (oldmask & RCUTORTURE_RDR_RCU_1)
1550+ mask &= ~RCUTORTURE_RDR_RCU_2;
1551+ else
1552+ mask |= RCUTORTURE_RDR_RCU_1;
1553+ }
1554+
15161555 /*
15171556 * Can't enable bh w/irq disabled.
15181557 */
@@ -1532,7 +1571,7 @@ rcutorture_extend_mask(int oldmask, struct torture_random_state *trsp) · 13 unmodified lines
15321571 mask |= oldmask & bhs;
15331572 }
15341573
1535− return mask ?: RCUTORTURE_RDR_RCU;
1574+ return mask ?: RCUTORTURE_RDR_RCU_1;
15361575 }
15371576
15381577 /*
@@ -1626,7 +1665,7 @@ static bool rcu_torture_one_read(struct torture_random_state *trsp, long myid) · 87 unmodified lines
16261665 rcu_torture_writer_state,
16271666 cookie, cur_ops->get_gp_state());
16281667 rcutorture_one_extend(&readstate, 0, trsp, rtrsp);
1629− WARN_ON_ONCE(readstate & RCUTORTURE_RDR_MASK);
1668+ WARN_ON_ONCE(readstate);
16301669 // This next splat is expected behavior if leakpointer, especially
16311670 // for CONFIG_RCU_STRICT_GRACE_PERIOD=y kernels.
16321671 WARN_ON_ONCE(leakpointer && READ_ONCE(p->rtort_pipe_count) > 1);
@@ -2052,6 +2091,8 @@ static int rcu_torture_stall(void *args) · 419 unmodified lines
20522091 #else
20532092 schedule_timeout_uninterruptible(HZ);
20542093 #endif
2094+ } else if (stall_no_softlockup) {
2095+ touch_softlockup_watchdog();
20552096 }
20562097 if (stall_cpu_irqsoff)
20572098 local_irq_enable();
@@ -2123,10 +2164,13 @@ struct rcu_fwd { · 65 unmodified lines
21232164 unsigned long rcu_fwd_startat;
21242165 struct rcu_launder_hist n_launders_hist[N_LAUNDERS_HIST];
21252166 unsigned long rcu_launder_gp_seq_start;
2167+ int rcu_fwd_id;
21262168 };
21272169
21282170 static DEFINE_MUTEX(rcu_fwd_mutex);
21292171 static struct rcu_fwd *rcu_fwds;
2172+static unsigned long rcu_fwd_seq;
2173+static atomic_long_t rcu_fwd_max_cbs;
21302174 static bool rcu_fwd_emergency_stop;
21312175
21322176 static void rcu_torture_fwd_cb_hist(struct rcu_fwd *rfp)
@@ -2139,8 +2183,9 @@ static void rcu_torture_fwd_cb_hist(struct rcu_fwd *rfp) · 6 unmodified lines
21392183 for (i = ARRAY_SIZE(rfp->n_launders_hist) - 1; i > 0; i--)
21402184 if (rfp->n_launders_hist[i].n_launders > 0)
21412185 break;
2142− pr_alert("%s: Callback-invocation histogram (duration %lu jiffies):",
2143− __func__, jiffies - rfp->rcu_fwd_startat);
2186+ mutex_lock(&rcu_fwd_mutex); // Serialize histograms.
2187+ pr_alert("%s: Callback-invocation histogram %d (duration %lu jiffies):",
2188+ __func__, rfp->rcu_fwd_id, jiffies - rfp->rcu_fwd_startat);
21442189 gps_old = rfp->rcu_launder_gp_seq_start;
21452190 for (j = 0; j <= i; j++) {
21462191 gps = rfp->n_launders_hist[j].launder_gp_seq;
@@ -2151,6 +2196,7 @@ static void rcu_torture_fwd_cb_hist(struct rcu_fwd *rfp) · 4 unmodified lines
21512196 gps_old = gps;
21522197 }
21532198 pr_cont("\n");
2199+ mutex_unlock(&rcu_fwd_mutex);
21542200 }
21552201
21562202 /* Callback function for continuous-flood RCU callbacks. */
@@ -2276,7 +2322,8 @@ static void rcu_torture_fwd_prog_nr(struct rcu_fwd *rfp, · 119 unmodified lines
22762322 cver = READ_ONCE(rcu_torture_current_version) - cver;
22772323 gps = rcutorture_seq_diff(cur_ops->get_gp_seq(), gps);
22782324 WARN_ON(!cver && gps < 2);
2279− pr_alert("%s: Duration %ld cver %ld gps %ld\n", __func__, dur, cver, gps);
2325+ pr_alert("%s: %d Duration %ld cver %ld gps %ld\n", __func__,
2326+ rfp->rcu_fwd_id, dur, cver, gps);
22802327 }
22812328 if (selfpropcb) {
22822329 WRITE_ONCE(fcs.stop, 1);
@@ -2344,7 +2391,7 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp) · 61 unmodified lines
23442391 rfp->rcu_fwd_cb_head = rfcpn;
23452392 n_launders++;
23462393 n_launders_sa++;
2347− } else {
2394+ } else if (!cur_ops->cbflood_max || cur_ops->cbflood_max > n_max_cbs) {
23482395 rfcp = kmalloc(sizeof(*rfcp), GFP_KERNEL);
23492396 if (WARN_ON_ONCE(!rfcp)) {
23502397 schedule_timeout_interruptible(1);
@@ -2354,8 +2401,11 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp) · 3 unmodified lines
23542401 n_launders_sa = 0;
23552402 rfcp->rfc_gps = 0;
23562403 rfcp->rfc_rfp = rfp;
2404+ } else {
2405+ rfcp = NULL;
23572406 }
2358− cur_ops->call(&rfcp->rh, rcu_torture_fwd_cb_cr);
2407+ if (rfcp)
2408+ cur_ops->call(&rfcp->rh, rcu_torture_fwd_cb_cr);
23592409 rcu_torture_fwd_prog_cond_resched(n_launders + n_max_cbs);
23602410 if (tick_nohz_full_enabled()) {
23612411 local_irq_save(flags);
@@ -2379,6 +2429,7 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp) · 17 unmodified lines
23792429 n_launders + n_max_cbs - n_launders_cb_snap,
23802430 n_launders, n_launders_sa,
23812431 n_max_gps, n_max_cbs, cver, gps);
2432+ atomic_long_add(n_max_cbs, &rcu_fwd_max_cbs);
23822433 rcu_torture_fwd_cb_hist(rfp);
23832434 }
23842435 schedule_timeout_uninterruptible(HZ); /* Let CBs drain. */
@@ -2394,6 +2445,8 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp) · 9 unmodified lines
23942445 static int rcutorture_oom_notify(struct notifier_block *self,
23952446 unsigned long notused, void *nfreed)
23962447 {
2448+ int i;
2449+ long ncbs;
23972450 struct rcu_fwd *rfp;
23982451
23992452 mutex_lock(&rcu_fwd_mutex);
@@ -2404,18 +2457,26 @@ static int rcutorture_oom_notify(struct notifier_block *self, · 4 unmodified lines
24042457 }
24052458 WARN(1, "%s invoked upon OOM during forward-progress testing.\n",
24062459 __func__);
2407− rcu_torture_fwd_cb_hist(rfp);
2408− rcu_fwd_progress_check(1 + (jiffies - READ_ONCE(rfp->rcu_fwd_startat)) / 2);
2460+ for (i = 0; i < fwd_progress; i++) {
2461+ rcu_torture_fwd_cb_hist(&rfp[i]);
2462+ rcu_fwd_progress_check(1 + (jiffies - READ_ONCE(rfp[i].rcu_fwd_startat)) / 2);
2463+ }
24092464 WRITE_ONCE(rcu_fwd_emergency_stop, true);
24102465 smp_mb(); /* Emergency stop before free and wait to avoid hangs. */
2411− pr_info("%s: Freed %lu RCU callbacks.\n",
2412− __func__, rcu_torture_fwd_prog_cbfree(rfp));
2466+ ncbs = 0;
2467+ for (i = 0; i < fwd_progress; i++)
2468+ ncbs += rcu_torture_fwd_prog_cbfree(&rfp[i]);
2469+ pr_info("%s: Freed %lu RCU callbacks.\n", __func__, ncbs);
24132470 rcu_barrier();
2414− pr_info("%s: Freed %lu RCU callbacks.\n",
2415− __func__, rcu_torture_fwd_prog_cbfree(rfp));
2471+ ncbs = 0;
2472+ for (i = 0; i < fwd_progress; i++)
2473+ ncbs += rcu_torture_fwd_prog_cbfree(&rfp[i]);
2474+ pr_info("%s: Freed %lu RCU callbacks.\n", __func__, ncbs);
24162475 rcu_barrier();
2417− pr_info("%s: Freed %lu RCU callbacks.\n",
2418− __func__, rcu_torture_fwd_prog_cbfree(rfp));
2476+ ncbs = 0;
2477+ for (i = 0; i < fwd_progress; i++)
2478+ ncbs += rcu_torture_fwd_prog_cbfree(&rfp[i]);
2479+ pr_info("%s: Freed %lu RCU callbacks.\n", __func__, ncbs);
24192480 smp_mb(); /* Frees before return to avoid redoing OOM. */
24202481 (*(unsigned long *)nfreed)++; /* Forward progress CBs freed! */
24212482 pr_info("%s returning after OOM processing.\n", __func__);
@@ -2430,7 +2491,10 @@ static struct notifier_block rcutorture_oom_nb = { · 8 unmodified lines
24302491 /* Carry out grace-period forward-progress testing. */
24312492 static int rcu_torture_fwd_prog(void *args)
24322493 {
2494+ bool firsttime = true;
2495+ long max_cbs;
24332496 int oldnice = task_nice(current);
2497+ unsigned long oldseq = READ_ONCE(rcu_fwd_seq);
24342498 struct rcu_fwd *rfp = args;
24352499 int tested = 0;
24362500 int tested_tries = 0;
@@ -2440,21 +2504,38 @@ static int rcu_torture_fwd_prog(void *args) · 3 unmodified lines
24402504 if (!IS_ENABLED(CONFIG_SMP) || !IS_ENABLED(CONFIG_RCU_BOOST))
24412505 set_user_nice(current, MAX_NICE);
24422506 do {
2443− schedule_timeout_interruptible(fwd_progress_holdoff * HZ);
2444− WRITE_ONCE(rcu_fwd_emergency_stop, false);
2445− if (!IS_ENABLED(CONFIG_TINY_RCU) ||
2446− rcu_inkernel_boot_has_ended())
2447− rcu_torture_fwd_prog_nr(rfp, &tested, &tested_tries);
2448− if (rcu_inkernel_boot_has_ended())
2507+ if (!rfp->rcu_fwd_id) {
2508+ schedule_timeout_interruptible(fwd_progress_holdoff * HZ);
2509+ WRITE_ONCE(rcu_fwd_emergency_stop, false);
2510+ if (!firsttime) {
2511+ max_cbs = atomic_long_xchg(&rcu_fwd_max_cbs, 0);
2512+ pr_alert("%s n_max_cbs: %ld\n", __func__, max_cbs);
2513+ }
2514+ firsttime = false;
2515+ WRITE_ONCE(rcu_fwd_seq, rcu_fwd_seq + 1);
2516+ } else {
2517+ while (READ_ONCE(rcu_fwd_seq) == oldseq)
2518+ schedule_timeout_interruptible(1);
2519+ oldseq = READ_ONCE(rcu_fwd_seq);
2520+ }
2521+ pr_alert("%s: Starting forward-progress test %d\n", __func__, rfp->rcu_fwd_id);
2522+ if (rcu_inkernel_boot_has_ended() && torture_num_online_cpus() > rfp->rcu_fwd_id)
24492523 rcu_torture_fwd_prog_cr(rfp);
2524+ if ((cur_ops->stall_dur && cur_ops->stall_dur() > 0) &&
2525+ (!IS_ENABLED(CONFIG_TINY_RCU) ||
2526+ (rcu_inkernel_boot_has_ended() &&
2527+ torture_num_online_cpus() > rfp->rcu_fwd_id)))
2528+ rcu_torture_fwd_prog_nr(rfp, &tested, &tested_tries);
24502529
24512530 /* Avoid slow periods, better to test when busy. */
24522531 if (stutter_wait("rcu_torture_fwd_prog"))
24532532 sched_set_normal(current, oldnice);
24542533 } while (!torture_must_stop());
24552534 /* Short runs might not contain a valid forward-progress attempt. */
2456− WARN_ON(!tested && tested_tries >= 5);
2457− pr_alert("%s: tested %d tested_tries %d\n", __func__, tested, tested_tries);
2535+ if (!rfp->rcu_fwd_id) {
2536+ WARN_ON(!tested && tested_tries >= 5);
2537+ pr_alert("%s: tested %d tested_tries %d\n", __func__, tested, tested_tries);
2538+ }
24582539 torture_kthread_stopping("rcu_torture_fwd_prog");
24592540 return 0;
24602541 }
@@ -2462,17 +2543,28 @@ static int rcu_torture_fwd_prog(void *args) · 1 unmodified line
24622543 /* If forward-progress checking is requested and feasible, spawn the thread. */
24632544 static int __init rcu_torture_fwd_prog_init(void)
24642545 {
2546+ int i;
2547+ int ret = 0;
24652548 struct rcu_fwd *rfp;
24662549
24672550 if (!fwd_progress)
24682551 return 0; /* Not requested, so don't do it. */
2552+ if (fwd_progress >= nr_cpu_ids) {
2553+ VERBOSE_TOROUT_STRING("rcu_torture_fwd_prog_init: Limiting fwd_progress to # CPUs.\n");
2554+ fwd_progress = nr_cpu_ids;
2555+ } else if (fwd_progress < 0) {
2556+ fwd_progress = nr_cpu_ids;
2557+ }
24692558 if ((!cur_ops->sync && !cur_ops->call) ||
2470− !cur_ops->stall_dur || cur_ops->stall_dur() <= 0 || cur_ops == &rcu_busted_ops) {
2559+ (!cur_ops->cbflood_max && (!cur_ops->stall_dur || cur_ops->stall_dur() <= 0)) ||
2560+ cur_ops == &rcu_busted_ops) {
24712561 VERBOSE_TOROUT_STRING("rcu_torture_fwd_prog_init: Disabled, unsupported by RCU flavor under test");
2562+ fwd_progress = 0;
24722563 return 0;
24732564 }
24742565 if (stall_cpu > 0) {
24752566 VERBOSE_TOROUT_STRING("rcu_torture_fwd_prog_init: Disabled, conflicts with CPU-stall testing");
2567+ fwd_progress = 0;
24762568 if (IS_MODULE(CONFIG_RCU_TORTURE_TEST))
24772569 return -EINVAL; /* In module, can fail back to user. */
24782570 WARN_ON(1); /* Make sure rcutorture notices conflict. */
@@ -2482,29 +2574,51 @@ static int __init rcu_torture_fwd_prog_init(void) · 3 unmodified lines
24822574 fwd_progress_holdoff = 1;
24832575 if (fwd_progress_div <= 0)
24842576 fwd_progress_div = 4;
2485− rfp = kzalloc(sizeof(*rfp), GFP_KERNEL);
2486− if (!rfp)
2577+ rfp = kcalloc(fwd_progress, sizeof(*rfp), GFP_KERNEL);
2578+ fwd_prog_tasks = kcalloc(fwd_progress, sizeof(*fwd_prog_tasks), GFP_KERNEL);
2579+ if (!rfp || !fwd_prog_tasks) {
2580+ kfree(rfp);
2581+ kfree(fwd_prog_tasks);
2582+ fwd_prog_tasks = NULL;
2583+ fwd_progress = 0;
24872584 return -ENOMEM;
2488− spin_lock_init(&rfp->rcu_fwd_lock);
2489− rfp->rcu_fwd_cb_tail = &rfp->rcu_fwd_cb_head;
2585+ }
2586+ for (i = 0; i < fwd_progress; i++) {
2587+ spin_lock_init(&rfp[i].rcu_fwd_lock);
2588+ rfp[i].rcu_fwd_cb_tail = &rfp[i].rcu_fwd_cb_head;
2589+ rfp[i].rcu_fwd_id = i;
2590+ }
24902591 mutex_lock(&rcu_fwd_mutex);
24912592 rcu_fwds = rfp;
24922593 mutex_unlock(&rcu_fwd_mutex);
24932594 register_oom_notifier(&rcutorture_oom_nb);
2494− return torture_create_kthread(rcu_torture_fwd_prog, rfp, fwd_prog_task);
2595+ for (i = 0; i < fwd_progress; i++) {
2596+ ret = torture_create_kthread(rcu_torture_fwd_prog, &rcu_fwds[i], fwd_prog_tasks[i]);
2597+ if (ret) {
2598+ fwd_progress = i;
2599+ return ret;
2600+ }
2601+ }
2602+ return 0;
24952603 }
24962604
24972605 static void rcu_torture_fwd_prog_cleanup(void)
24982606 {
2607+ int i;
24992608 struct rcu_fwd *rfp;
25002609
2501− torture_stop_kthread(rcu_torture_fwd_prog, fwd_prog_task);
2502− rfp = rcu_fwds;
2610+ if (!rcu_fwds || !fwd_prog_tasks)
2611+ return;
2612+ for (i = 0; i < fwd_progress; i++)
2613+ torture_stop_kthread(rcu_torture_fwd_prog, fwd_prog_tasks[i]);
2614+ unregister_oom_notifier(&rcutorture_oom_nb);
25032615 mutex_lock(&rcu_fwd_mutex);
2616+ rfp = rcu_fwds;
25042617 rcu_fwds = NULL;
25052618 mutex_unlock(&rcu_fwd_mutex);
2506− unregister_oom_notifier(&rcutorture_oom_nb);
25072619 kfree(rfp);
2620+ kfree(fwd_prog_tasks);
2621+ fwd_prog_tasks = NULL;
25082622 }
25092623
25102624 /* Callback function for RCU barrier testing. */
@@ -2741,7 +2855,7 @@ static int rcu_torture_read_exit(void *unused) · 230 unmodified lines
27412855 &trs, "%s",
27422856 "rcu_torture_read_exit_child");
27432857 if (IS_ERR(tsp)) {
2744− VERBOSE_TOROUT_ERRSTRING("out of memory");
2858+ TOROUT_ERRSTRING("out of memory");
27452859 errexit = true;
27462860 tsp = NULL;
27472861 break;
@@ -3068,7 +3182,7 @@ rcu_torture_init(void) · 320 unmodified lines
30683182 sizeof(fakewriter_tasks[0]),
30693183 GFP_KERNEL);
30703184 if (fakewriter_tasks == NULL) {
3071− VERBOSE_TOROUT_ERRSTRING("out of memory");
3185+ TOROUT_ERRSTRING("out of memory");
30723186 firsterr = -ENOMEM;
30733187 goto unwind;
30743188 }
@@ -3084,7 +3198,7 @@ rcu_torture_init(void) · 9 unmodified lines
30843198 rcu_torture_reader_mbchk = kcalloc(nrealreaders, sizeof(*rcu_torture_reader_mbchk),
30853199 GFP_KERNEL);
30863200 if (!reader_tasks || !rcu_torture_reader_mbchk) {
3087− VERBOSE_TOROUT_ERRSTRING("out of memory");
3201+ TOROUT_ERRSTRING("out of memory");
30883202 firsterr = -ENOMEM;
30893203 goto unwind;
30903204 }
@@ -3103,7 +3217,7 @@ rcu_torture_init(void) · 12 unmodified lines
31033217 if (nrealnocbers > 0) {
31043218 nocb_tasks = kcalloc(nrealnocbers, sizeof(nocb_tasks[0]), GFP_KERNEL);
31053219 if (nocb_tasks == NULL) {
3106− VERBOSE_TOROUT_ERRSTRING("out of memory");
3220+ TOROUT_ERRSTRING("out of memory");
31073221 firsterr = -ENOMEM;
31083222 goto unwind;
31093223 }
kernel/rcu/refscale.c+24−26
@@ -44,7 +44,10 @@ · 43 unmodified lines
4444 pr_alert("%s" SCALE_FLAG s, scale_type, ## x)
4545
4646 #define VERBOSE_SCALEOUT(s, x...) \
47− do { if (verbose) pr_alert("%s" SCALE_FLAG s, scale_type, ## x); } while (0)
47+ do { \
48+ if (verbose) \
49+ pr_alert("%s" SCALE_FLAG s "\n", scale_type, ## x); \
50+ } while (0)
4851
4952 static atomic_t verbose_batch_ctr;
5053
@@ -54,12 +57,11 @@ do { \ · 3 unmodified lines
5457 (verbose_batched <= 0 || \
5558 !(atomic_inc_return(&verbose_batch_ctr) % verbose_batched))) { \
5659 schedule_timeout_uninterruptible(1); \
57− pr_alert("%s" SCALE_FLAG s, scale_type, ## x); \
60+ pr_alert("%s" SCALE_FLAG s "\n", scale_type, ## x); \
5861 } \
5962 } while (0)
6063
61−#define VERBOSE_SCALEOUT_ERRSTRING(s, x...) \
62− do { if (verbose) pr_alert("%s" SCALE_FLAG "!!! " s, scale_type, ## x); } while (0)
64+#define SCALEOUT_ERRSTRING(s, x...) pr_alert("%s" SCALE_FLAG "!!! " s "\n", scale_type, ## x)
6365
6466 MODULE_LICENSE("GPL");
6567 MODULE_AUTHOR("Joel Fernandes (Google) <joel@joelfernandes.org>");
@@ -604,7 +606,7 @@ static u64 process_durations(int n) · 538 unmodified lines
604606 char *buf;
605607 u64 sum = 0;
606608
607− buf = kmalloc(128 + nreaders * 32, GFP_KERNEL);
609+ buf = kmalloc(800 + 64, GFP_KERNEL);
608610 if (!buf)
609611 return 0;
610612 buf[0] = 0;
@@ -617,13 +619,15 @@ static u64 process_durations(int n) · 6 unmodified lines
617619
618620 if (i % 5 == 0)
619621 strcat(buf, "\n");
622+ if (strlen(buf) >= 800) {
623+ pr_alert("%s", buf);
624+ buf[0] = 0;
625+ }
620626 strcat(buf, buf1);
621627
622628 sum += rt->last_duration_ns;
623629 }
624− strcat(buf, "\n");
625−
626− SCALEOUT("%s\n", buf);
630+ pr_alert("%s\n", buf);
627631
628632 kfree(buf);
629633 return sum;
@@ -637,7 +641,6 @@ static u64 process_durations(int n) · 7 unmodified lines
637641 // point all the timestamps are printed.
638642 static int main_func(void *arg)
639643 {
640− bool errexit = false;
641644 int exp, r;
642645 char buf1[64];
643646 char *buf;
@@ -648,10 +651,10 @@ static int main_func(void *arg) · 4 unmodified lines
648651
649652 VERBOSE_SCALEOUT("main_func task started");
650653 result_avg = kzalloc(nruns * sizeof(*result_avg), GFP_KERNEL);
651− buf = kzalloc(64 + nruns * 32, GFP_KERNEL);
654+ buf = kzalloc(800 + 64, GFP_KERNEL);
652655 if (!result_avg || !buf) {
653− VERBOSE_SCALEOUT_ERRSTRING("out of memory");
654− errexit = true;
656+ SCALEOUT_ERRSTRING("out of memory");
657+ goto oom_exit;
655658 }
656659 if (holdoff)
657660 schedule_timeout_interruptible(holdoff * HZ);
@@ -663,8 +666,6 @@ static int main_func(void *arg) · 5 unmodified lines
663666
664667 // Start exp readers up per experiment
665668 for (exp = 0; exp < nruns && !torture_must_stop(); exp++) {
666− if (errexit)
667− break;
668669 if (torture_must_stop())
669670 goto end;
670671
@@ -698,26 +699,23 @@ static int main_func(void *arg) · 27 unmodified lines
698699 // Print the average of all experiments
699700 SCALEOUT("END OF TEST. Calculating average duration per loop (nanoseconds)...\n");
700701
701− if (!errexit) {
702− buf[0] = 0;
703− strcat(buf, "\n");
704− strcat(buf, "Runs\tTime(ns)\n");
705− }
706−
702+ pr_alert("Runs\tTime(ns)\n");
707703 for (exp = 0; exp < nruns; exp++) {
708704 u64 avg;
709705 u32 rem;
710706
711− if (errexit)
712− break;
713707 avg = div_u64_rem(result_avg[exp], 1000, &rem);
714708 sprintf(buf1, "%d\t%llu.%03u\n", exp + 1, avg, rem);
715709 strcat(buf, buf1);
710+ if (strlen(buf) >= 800) {
711+ pr_alert("%s", buf);
712+ buf[0] = 0;
713+ }
716714 }
717715
718− if (!errexit)
719− SCALEOUT("%s", buf);
716+ pr_alert("%s", buf);
720717
718+oom_exit:
721719 // This will shutdown everything including us.
722720 if (shutdown) {
723721 shutdown_start = 1;
@@ -841,12 +839,12 @@ ref_scale_init(void) · 117 unmodified lines
841839 reader_tasks = kcalloc(nreaders, sizeof(reader_tasks[0]),
842840 GFP_KERNEL);
843841 if (!reader_tasks) {
844− VERBOSE_SCALEOUT_ERRSTRING("out of memory");
842+ SCALEOUT_ERRSTRING("out of memory");
845843 firsterr = -ENOMEM;
846844 goto unwind;
847845 }
848846
849− VERBOSE_SCALEOUT("Starting %d reader threads\n", nreaders);
847+ VERBOSE_SCALEOUT("Starting %d reader threads", nreaders);
850848
851849 for (i = 0; i < nreaders; i++) {
852850 firsterr = torture_create_kthread(ref_scale_reader, (void *)i,
kernel/rcu/srcutiny.c+1−1
@@ -99,7 +99,7 @@ void __srcu_read_unlock(struct srcu_struct *ssp, int idx) · 98 unmodified lines
9999 int newval = READ_ONCE(ssp->srcu_lock_nesting[idx]) - 1;
100100
101101 WRITE_ONCE(ssp->srcu_lock_nesting[idx], newval);
102− if (!newval && READ_ONCE(ssp->srcu_gp_waiting))
102+ if (!newval && READ_ONCE(ssp->srcu_gp_waiting) && in_task())
103103 swake_up_one(&ssp->srcu_wq);
104104 }
105105 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
kernel/rcu/tasks.h+394−82
@@ -6,6 +6,7 @@ · 5 unmodified lines
66 */
77
88 #ifdef CONFIG_TASKS_RCU_GENERIC
9+#include "rcu_segcblist.h"
910
1011 ////////////////////////////////////////////////////////////////////////
1112 //
@@ -19,12 +20,34 @@ typedef void (*postscan_func_t)(struct list_head *hop); · 7 unmodified lines
1920 typedef void (*holdouts_func_t)(struct list_head *hop, bool ndrpt, bool *frptp);
2021 typedef void (*postgp_func_t)(struct rcu_tasks *rtp);
2122
23+/**
24+ * struct rcu_tasks_percpu - Per-CPU component of definition for a Tasks-RCU-like mechanism.
25+ * @cblist: Callback list.
26+ * @lock: Lock protecting per-CPU callback list.
27+ * @rtp_jiffies: Jiffies counter value for statistics.
28+ * @rtp_n_lock_retries: Rough lock-contention statistic.
29+ * @rtp_work: Work queue for invoking callbacks.
30+ * @rtp_irq_work: IRQ work queue for deferred wakeups.
31+ * @barrier_q_head: RCU callback for barrier operation.
32+ * @cpu: CPU number corresponding to this entry.
33+ * @rtpp: Pointer to the rcu_tasks structure.
34+ */
35+struct rcu_tasks_percpu {
36+ struct rcu_segcblist cblist;
37+ raw_spinlock_t __private lock;
38+ unsigned long rtp_jiffies;
39+ unsigned long rtp_n_lock_retries;
40+ struct work_struct rtp_work;
41+ struct irq_work rtp_irq_work;
42+ struct rcu_head barrier_q_head;
43+ int cpu;
44+ struct rcu_tasks *rtpp;
45+};
46+
2247 /**
2348 * struct rcu_tasks - Definition for a Tasks-RCU-like mechanism.
24− * @cbs_head: Head of callback list.
25− * @cbs_tail: Tail pointer for callback list.
2649 * @cbs_wq: Wait queue allowing new callback to get kthread's attention.
27− * @cbs_lock: Lock protecting callback list.
50+ * @cbs_gbl_lock: Lock protecting callback list.
2851 * @kthread_ptr: This flavor's grace-period/callback-invocation kthread.
2952 * @gp_func: This flavor's grace-period-wait function.
3053 * @gp_state: Grace period's most recent state transition (debugging).
@@ -32,7 +55,7 @@ typedef void (*postgp_func_t)(struct rcu_tasks *rtp); · 1 unmodified line
3255 * @init_fract: Initial backoff sleep interval.
3356 * @gp_jiffies: Time of last @gp_state transition.
3457 * @gp_start: Most recent grace-period start in jiffies.
35− * @n_gps: Number of grace periods completed since boot.
58+ * @tasks_gp_seq: Number of grace periods completed since boot.
3659 * @n_ipis: Number of IPIs sent to encourage grace periods to end.
3760 * @n_ipis_fails: Number of IPI-send failures.
3861 * @pregp_func: This flavor's pre-grace-period function (optional).
@@ -41,20 +64,27 @@ typedef void (*postgp_func_t)(struct rcu_tasks *rtp); · 2 unmodified lines
4164 * @holdouts_func: This flavor's holdout-list scan function (optional).
4265 * @postgp_func: This flavor's post-grace-period function (optional).
4366 * @call_func: This flavor's call_rcu()-equivalent function.
67+ * @rtpcpu: This flavor's rcu_tasks_percpu structure.
68+ * @percpu_enqueue_shift: Shift down CPU ID this much when enqueuing callbacks.
69+ * @percpu_enqueue_lim: Number of per-CPU callback queues in use for enqueuing.
70+ * @percpu_dequeue_lim: Number of per-CPU callback queues in use for dequeuing.
71+ * @percpu_dequeue_gpseq: RCU grace-period number to propagate enqueue limit to dequeuers.
72+ * @barrier_q_mutex: Serialize barrier operations.
73+ * @barrier_q_count: Number of queues being waited on.
74+ * @barrier_q_completion: Barrier wait/wakeup mechanism.
75+ * @barrier_q_seq: Sequence number for barrier operations.
4476 * @name: This flavor's textual name.
4577 * @kname: This flavor's kthread name.
4678 */
4779 struct rcu_tasks {
48− struct rcu_head *cbs_head;
49− struct rcu_head **cbs_tail;
5080 struct wait_queue_head cbs_wq;
51− raw_spinlock_t cbs_lock;
81+ raw_spinlock_t cbs_gbl_lock;
5282 int gp_state;
5383 int gp_sleep;
5484 int init_fract;
5585 unsigned long gp_jiffies;
5686 unsigned long gp_start;
57− unsigned long n_gps;
87+ unsigned long tasks_gp_seq;
5888 unsigned long n_ipis;
5989 unsigned long n_ipis_fails;
6090 struct task_struct *kthread_ptr;
@@ -65,20 +95,40 @@ struct rcu_tasks { · 4 unmodified lines
6595 holdouts_func_t holdouts_func;
6696 postgp_func_t postgp_func;
6797 call_rcu_func_t call_func;
98+ struct rcu_tasks_percpu __percpu *rtpcpu;
99+ int percpu_enqueue_shift;
100+ int percpu_enqueue_lim;
101+ int percpu_dequeue_lim;
102+ unsigned long percpu_dequeue_gpseq;
103+ struct mutex barrier_q_mutex;
104+ atomic_t barrier_q_count;
105+ struct completion barrier_q_completion;
106+ unsigned long barrier_q_seq;
68107 char *name;
69108 char *kname;
70109 };
71110
72−#define DEFINE_RCU_TASKS(rt_name, gp, call, n) \
73−static struct rcu_tasks rt_name = \
74−{ \
75− .cbs_tail = &rt_name.cbs_head, \
76− .cbs_wq = __WAIT_QUEUE_HEAD_INITIALIZER(rt_name.cbs_wq), \
77− .cbs_lock = __RAW_SPIN_LOCK_UNLOCKED(rt_name.cbs_lock), \
78− .gp_func = gp, \
79− .call_func = call, \
80− .name = n, \
81− .kname = #rt_name, \
111+static void call_rcu_tasks_iw_wakeup(struct irq_work *iwp);
112+
113+#define DEFINE_RCU_TASKS(rt_name, gp, call, n) \
114+static DEFINE_PER_CPU(struct rcu_tasks_percpu, rt_name ## __percpu) = { \
115+ .lock = __RAW_SPIN_LOCK_UNLOCKED(rt_name ## __percpu.cbs_pcpu_lock), \
116+ .rtp_irq_work = IRQ_WORK_INIT(call_rcu_tasks_iw_wakeup), \
117+}; \
118+static struct rcu_tasks rt_name = \
119+{ \
120+ .cbs_wq = __WAIT_QUEUE_HEAD_INITIALIZER(rt_name.cbs_wq), \
121+ .cbs_gbl_lock = __RAW_SPIN_LOCK_UNLOCKED(rt_name.cbs_gbl_lock), \
122+ .gp_func = gp, \
123+ .call_func = call, \
124+ .rtpcpu = &rt_name ## __percpu, \
125+ .name = n, \
126+ .percpu_enqueue_shift = ilog2(CONFIG_NR_CPUS), \
127+ .percpu_enqueue_lim = 1, \
128+ .percpu_dequeue_lim = 1, \
129+ .barrier_q_mutex = __MUTEX_INITIALIZER(rt_name.barrier_q_mutex), \
130+ .barrier_q_seq = (0UL - 50UL) << RCU_SEQ_CTR_SHIFT, \
131+ .kname = #rt_name, \
82132 }
83133
84134 /* Track exiting tasks in order to allow them to be waited for. */
@@ -94,6 +144,15 @@ module_param(rcu_task_ipi_delay, int, 0644); · 9 unmodified lines
94144 static int rcu_task_stall_timeout __read_mostly = RCU_TASK_STALL_TIMEOUT;
95145 module_param(rcu_task_stall_timeout, int, 0644);
96146
147+static int rcu_task_enqueue_lim __read_mostly = -1;
148+module_param(rcu_task_enqueue_lim, int, 0444);
149+
150+static bool rcu_task_cb_adjust;
151+static int rcu_task_contend_lim __read_mostly = 100;
152+module_param(rcu_task_contend_lim, int, 0444);
153+static int rcu_task_collapse_lim __read_mostly = 10;
154+module_param(rcu_task_collapse_lim, int, 0444);
155+
97156 /* RCU tasks grace-period state for debugging. */
98157 #define RTGS_INIT 0
99158 #define RTGS_WAIT_WAIT_CBS 1
@@ -128,6 +187,8 @@ static const char * const rcu_tasks_gp_state_names[] = { · 28 unmodified lines
128187 //
129188 // Generic code.
130189
190+static void rcu_tasks_invoke_cbs_wq(struct work_struct *wp);
191+
131192 /* Record grace-period phase and time. */
132193 static void set_tasks_gp_state(struct rcu_tasks *rtp, int newstate)
133194 {
@@ -148,23 +209,106 @@ static const char *tasks_gp_state_getname(struct rcu_tasks *rtp) · 14 unmodified lines
148209 }
149210 #endif /* #ifndef CONFIG_TINY_RCU */
150211
212+// Initialize per-CPU callback lists for the specified flavor of
213+// Tasks RCU.
214+static void cblist_init_generic(struct rcu_tasks *rtp)
215+{
216+ int cpu;
217+ unsigned long flags;
218+ int lim;
219+
220+ raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags);
221+ if (rcu_task_enqueue_lim < 0) {
222+ rcu_task_enqueue_lim = 1;
223+ rcu_task_cb_adjust = true;
224+ pr_info("%s: Setting adjustable number of callback queues.\n", __func__);
225+ } else if (rcu_task_enqueue_lim == 0) {
226+ rcu_task_enqueue_lim = 1;
227+ }
228+ lim = rcu_task_enqueue_lim;
229+
230+ if (lim > nr_cpu_ids)
231+ lim = nr_cpu_ids;
232+ WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids / lim));
233+ WRITE_ONCE(rtp->percpu_dequeue_lim, lim);
234+ smp_store_release(&rtp->percpu_enqueue_lim, lim);
235+ for_each_possible_cpu(cpu) {
236+ struct rcu_tasks_percpu *rtpcp = per_cpu_ptr(rtp->rtpcpu, cpu);
237+
238+ WARN_ON_ONCE(!rtpcp);
239+ if (cpu)
240+ raw_spin_lock_init(&ACCESS_PRIVATE(rtpcp, lock));
241+ raw_spin_lock_rcu_node(rtpcp); // irqs already disabled.
242+ if (rcu_segcblist_empty(&rtpcp->cblist))
243+ rcu_segcblist_init(&rtpcp->cblist);
244+ INIT_WORK(&rtpcp->rtp_work, rcu_tasks_invoke_cbs_wq);
245+ rtpcp->cpu = cpu;
246+ rtpcp->rtpp = rtp;
247+ raw_spin_unlock_rcu_node(rtpcp); // irqs remain disabled.
248+ }
249+ raw_spin_unlock_irqrestore(&rtp->cbs_gbl_lock, flags);
250+ pr_info("%s: Setting shift to %d and lim to %d.\n", __func__, data_race(rtp->percpu_enqueue_shift), data_race(rtp->percpu_enqueue_lim));
251+}
252+
253+// IRQ-work handler that does deferred wakeup for call_rcu_tasks_generic().
254+static void call_rcu_tasks_iw_wakeup(struct irq_work *iwp)
255+{
256+ struct rcu_tasks *rtp;
257+ struct rcu_tasks_percpu *rtpcp = container_of(iwp, struct rcu_tasks_percpu, rtp_irq_work);
258+
259+ rtp = rtpcp->rtpp;
260+ wake_up(&rtp->cbs_wq);
261+}
262+
151263 // Enqueue a callback for the specified flavor of Tasks RCU.
152264 static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,
153265 struct rcu_tasks *rtp)
154266 {
155267 unsigned long flags;
268+ unsigned long j;
269+ bool needadjust = false;
156270 bool needwake;
271+ struct rcu_tasks_percpu *rtpcp;
157272
158273 rhp->next = NULL;
159274 rhp->func = func;
160− raw_spin_lock_irqsave(&rtp->cbs_lock, flags);
161− needwake = !rtp->cbs_head;
162− WRITE_ONCE(*rtp->cbs_tail, rhp);
163− rtp->cbs_tail = &rhp->next;
164− raw_spin_unlock_irqrestore(&rtp->cbs_lock, flags);
275+ local_irq_save(flags);
276+ rcu_read_lock();
277+ rtpcp = per_cpu_ptr(rtp->rtpcpu,
278+ smp_processor_id() >> READ_ONCE(rtp->percpu_enqueue_shift));
279+ if (!raw_spin_trylock_rcu_node(rtpcp)) { // irqs already disabled.
280+ raw_spin_lock_rcu_node(rtpcp); // irqs already disabled.
281+ j = jiffies;
282+ if (rtpcp->rtp_jiffies != j) {
283+ rtpcp->rtp_jiffies = j;
284+ rtpcp->rtp_n_lock_retries = 0;
285+ }
286+ if (rcu_task_cb_adjust && ++rtpcp->rtp_n_lock_retries > rcu_task_contend_lim &&
287+ READ_ONCE(rtp->percpu_enqueue_lim) != nr_cpu_ids)
288+ needadjust = true; // Defer adjustment to avoid deadlock.
289+ }
290+ if (!rcu_segcblist_is_enabled(&rtpcp->cblist)) {
291+ raw_spin_unlock_rcu_node(rtpcp); // irqs remain disabled.
292+ cblist_init_generic(rtp);
293+ raw_spin_lock_rcu_node(rtpcp); // irqs already disabled.
294+ }
295+ needwake = rcu_segcblist_empty(&rtpcp->cblist);
296+ rcu_segcblist_enqueue(&rtpcp->cblist, rhp);
297+ raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
298+ if (unlikely(needadjust)) {
299+ raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags);
300+ if (rtp->percpu_enqueue_lim != nr_cpu_ids) {
301+ WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids));
302+ WRITE_ONCE(rtp->percpu_dequeue_lim, nr_cpu_ids);
303+ smp_store_release(&rtp->percpu_enqueue_lim, nr_cpu_ids);
304+ pr_info("Switching %s to per-CPU callback queuing.\n", rtp->name);
305+ }
306+ raw_spin_unlock_irqrestore(&rtp->cbs_gbl_lock, flags);
307+ }
308+ rcu_read_unlock();
165309 /* We can't create the thread unless interrupts are enabled. */
166310 if (needwake && READ_ONCE(rtp->kthread_ptr))
167− wake_up(&rtp->cbs_wq);
311+ irq_work_queue(&rtpcp->rtp_irq_work);
168312 }
169313
170314 // Wait for a grace period for the specified flavor of Tasks RCU.
@@ -178,12 +322,173 @@ static void synchronize_rcu_tasks_generic(struct rcu_tasks *rtp) · 7 unmodified lines
178322 wait_rcu_gp(rtp->call_func);
179323 }
180324
325+// RCU callback function for rcu_barrier_tasks_generic().
326+static void rcu_barrier_tasks_generic_cb(struct rcu_head *rhp)
327+{
328+ struct rcu_tasks *rtp;
329+ struct rcu_tasks_percpu *rtpcp;
330+
331+ rtpcp = container_of(rhp, struct rcu_tasks_percpu, barrier_q_head);
332+ rtp = rtpcp->rtpp;
333+ if (atomic_dec_and_test(&rtp->barrier_q_count))
334+ complete(&rtp->barrier_q_completion);
335+}
336+
337+// Wait for all in-flight callbacks for the specified RCU Tasks flavor.
338+// Operates in a manner similar to rcu_barrier().
339+static void rcu_barrier_tasks_generic(struct rcu_tasks *rtp)
340+{
341+ int cpu;
342+ unsigned long flags;
343+ struct rcu_tasks_percpu *rtpcp;
344+ unsigned long s = rcu_seq_snap(&rtp->barrier_q_seq);
345+
346+ mutex_lock(&rtp->barrier_q_mutex);
347+ if (rcu_seq_done(&rtp->barrier_q_seq, s)) {
348+ smp_mb();
349+ mutex_unlock(&rtp->barrier_q_mutex);
350+ return;
351+ }
352+ rcu_seq_start(&rtp->barrier_q_seq);
353+ init_completion(&rtp->barrier_q_completion);
354+ atomic_set(&rtp->barrier_q_count, 2);
355+ for_each_possible_cpu(cpu) {
356+ if (cpu >= smp_load_acquire(&rtp->percpu_dequeue_lim))
357+ break;
358+ rtpcp = per_cpu_ptr(rtp->rtpcpu, cpu);
359+ rtpcp->barrier_q_head.func = rcu_barrier_tasks_generic_cb;
360+ raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
361+ if (rcu_segcblist_entrain(&rtpcp->cblist, &rtpcp->barrier_q_head))
362+ atomic_inc(&rtp->barrier_q_count);
363+ raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
364+ }
365+ if (atomic_sub_and_test(2, &rtp->barrier_q_count))
366+ complete(&rtp->barrier_q_completion);
367+ wait_for_completion(&rtp->barrier_q_completion);
368+ rcu_seq_end(&rtp->barrier_q_seq);
369+ mutex_unlock(&rtp->barrier_q_mutex);
370+}
371+
372+// Advance callbacks and indicate whether either a grace period or
373+// callback invocation is needed.
374+static int rcu_tasks_need_gpcb(struct rcu_tasks *rtp)
375+{
376+ int cpu;
377+ unsigned long flags;
378+ long n;
379+ long ncbs = 0;
380+ long ncbsnz = 0;
381+ int needgpcb = 0;
382+
383+ for (cpu = 0; cpu < smp_load_acquire(&rtp->percpu_dequeue_lim); cpu++) {
384+ struct rcu_tasks_percpu *rtpcp = per_cpu_ptr(rtp->rtpcpu, cpu);
385+
386+ /* Advance and accelerate any new callbacks. */
387+ if (!rcu_segcblist_n_cbs(&rtpcp->cblist))
388+ continue;
389+ raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
390+ // Should we shrink down to a single callback queue?
391+ n = rcu_segcblist_n_cbs(&rtpcp->cblist);
392+ if (n) {
393+ ncbs += n;
394+ if (cpu > 0)
395+ ncbsnz += n;
396+ }
397+ rcu_segcblist_advance(&rtpcp->cblist, rcu_seq_current(&rtp->tasks_gp_seq));
398+ (void)rcu_segcblist_accelerate(&rtpcp->cblist, rcu_seq_snap(&rtp->tasks_gp_seq));
399+ if (rcu_segcblist_pend_cbs(&rtpcp->cblist))
400+ needgpcb |= 0x3;
401+ if (!rcu_segcblist_empty(&rtpcp->cblist))
402+ needgpcb |= 0x1;
403+ raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
404+ }
405+
406+ // Shrink down to a single callback queue if appropriate.
407+ // This is done in two stages: (1) If there are no more than
408+ // rcu_task_collapse_lim callbacks on CPU 0 and none on any other
409+ // CPU, limit enqueueing to CPU 0. (2) After an RCU grace period,
410+ // if there has not been an increase in callbacks, limit dequeuing
411+ // to CPU 0. Note the matching RCU read-side critical section in
412+ // call_rcu_tasks_generic().
413+ if (rcu_task_cb_adjust && ncbs <= rcu_task_collapse_lim) {
414+ raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags);
415+ if (rtp->percpu_enqueue_lim > 1) {
416+ WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids));
417+ smp_store_release(&rtp->percpu_enqueue_lim, 1);
418+ rtp->percpu_dequeue_gpseq = get_state_synchronize_rcu();
419+ pr_info("Starting switch %s to CPU-0 callback queuing.\n", rtp->name);
420+ }
421+ raw_spin_unlock_irqrestore(&rtp->cbs_gbl_lock, flags);
422+ }
423+ if (rcu_task_cb_adjust && !ncbsnz &&
424+ poll_state_synchronize_rcu(rtp->percpu_dequeue_gpseq)) {
425+ raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags);
426+ if (rtp->percpu_enqueue_lim < rtp->percpu_dequeue_lim) {
427+ WRITE_ONCE(rtp->percpu_dequeue_lim, 1);
428+ pr_info("Completing switch %s to CPU-0 callback queuing.\n", rtp->name);
429+ }
430+ raw_spin_unlock_irqrestore(&rtp->cbs_gbl_lock, flags);
431+ }
432+
433+ return needgpcb;
434+}
435+
436+// Advance callbacks and invoke any that are ready.
437+static void rcu_tasks_invoke_cbs(struct rcu_tasks *rtp, struct rcu_tasks_percpu *rtpcp)
438+{
439+ int cpu;
440+ int cpunext;
441+ unsigned long flags;
442+ int len;
443+ struct rcu_head *rhp;
444+ struct rcu_cblist rcl = RCU_CBLIST_INITIALIZER(rcl);
445+ struct rcu_tasks_percpu *rtpcp_next;
446+
447+ cpu = rtpcp->cpu;
448+ cpunext = cpu * 2 + 1;
449+ if (cpunext < smp_load_acquire(&rtp->percpu_dequeue_lim)) {
450+ rtpcp_next = per_cpu_ptr(rtp->rtpcpu, cpunext);
451+ queue_work_on(cpunext, system_wq, &rtpcp_next->rtp_work);
452+ cpunext++;
453+ if (cpunext < smp_load_acquire(&rtp->percpu_dequeue_lim)) {
454+ rtpcp_next = per_cpu_ptr(rtp->rtpcpu, cpunext);
455+ queue_work_on(cpunext, system_wq, &rtpcp_next->rtp_work);
456+ }
457+ }
458+
459+ if (rcu_segcblist_empty(&rtpcp->cblist))
460+ return;
461+ raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
462+ rcu_segcblist_advance(&rtpcp->cblist, rcu_seq_current(&rtp->tasks_gp_seq));
463+ rcu_segcblist_extract_done_cbs(&rtpcp->cblist, &rcl);
464+ raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
465+ len = rcl.len;
466+ for (rhp = rcu_cblist_dequeue(&rcl); rhp; rhp = rcu_cblist_dequeue(&rcl)) {
467+ local_bh_disable();
468+ rhp->func(rhp);
469+ local_bh_enable();
470+ cond_resched();
471+ }
472+ raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
473+ rcu_segcblist_add_len(&rtpcp->cblist, -len);
474+ (void)rcu_segcblist_accelerate(&rtpcp->cblist, rcu_seq_snap(&rtp->tasks_gp_seq));
475+ raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
476+}
477+
478+// Workqueue flood to advance callbacks and invoke any that are ready.
479+static void rcu_tasks_invoke_cbs_wq(struct work_struct *wp)
480+{
481+ struct rcu_tasks *rtp;
482+ struct rcu_tasks_percpu *rtpcp = container_of(wp, struct rcu_tasks_percpu, rtp_work);
483+
484+ rtp = rtpcp->rtpp;
485+ rcu_tasks_invoke_cbs(rtp, rtpcp);
486+}
487+
181488 /* RCU-tasks kthread that detects grace periods and invokes callbacks. */
182489 static int __noreturn rcu_tasks_kthread(void *arg)
183490 {
184− unsigned long flags;
185− struct rcu_head *list;
186− struct rcu_head *next;
491+ int needgpcb;
187492 struct rcu_tasks *rtp = arg;
188493
189494 /* Run on housekeeping CPUs by default. Sysadm can move if desired. */
@@ -199,42 +504,22 @@ static int __noreturn rcu_tasks_kthread(void *arg) · 9 unmodified lines
199504 for (;;) {
200505 set_tasks_gp_state(rtp, RTGS_WAIT_CBS);
201506
202− /* Pick up any new callbacks. */
203− raw_spin_lock_irqsave(&rtp->cbs_lock, flags);
204− smp_mb__after_spinlock(); // Order updates vs. GP.
205− list = rtp->cbs_head;
206− rtp->cbs_head = NULL;
207− rtp->cbs_tail = &rtp->cbs_head;
208− raw_spin_unlock_irqrestore(&rtp->cbs_lock, flags);
209−
210507 /* If there were none, wait a bit and start over. */
211− if (!list) {
212− wait_event_interruptible(rtp->cbs_wq,
213− READ_ONCE(rtp->cbs_head));
214− if (!rtp->cbs_head) {
215− WARN_ON(signal_pending(current));
216− set_tasks_gp_state(rtp, RTGS_WAIT_WAIT_CBS);
217− schedule_timeout_idle(HZ/10);
218− }
219− continue;
508+ wait_event_idle(rtp->cbs_wq, (needgpcb = rcu_tasks_need_gpcb(rtp)));
509+
510+ if (needgpcb & 0x2) {
511+ // Wait for one grace period.
512+ set_tasks_gp_state(rtp, RTGS_WAIT_GP);
513+ rtp->gp_start = jiffies;
514+ rcu_seq_start(&rtp->tasks_gp_seq);
515+ rtp->gp_func(rtp);
516+ rcu_seq_end(&rtp->tasks_gp_seq);
220517 }
221518
222− // Wait for one grace period.
223− set_tasks_gp_state(rtp, RTGS_WAIT_GP);
224− rtp->gp_start = jiffies;
225− rtp->gp_func(rtp);
226− rtp->n_gps++;
227−
228− /* Invoke the callbacks. */
519+ /* Invoke callbacks. */
229520 set_tasks_gp_state(rtp, RTGS_INVOKE_CBS);
230− while (list) {
231− next = list->next;
232− local_bh_disable();
233− list->func(list);
234− local_bh_enable();
235− list = next;
236− cond_resched();
237− }
521+ rcu_tasks_invoke_cbs(rtp, per_cpu_ptr(rtp->rtpcpu, 0));
522+
238523 /* Paranoid sleep to keep this from entering a tight loop */
239524 schedule_timeout_idle(rtp->gp_sleep);
240525 }
@@ -279,14 +564,15 @@ static void __init rcu_tasks_bootup_oddness(void) · 38 unmodified lines
279564 /* Dump out rcutorture-relevant state common to all RCU-tasks flavors. */
280565 static void show_rcu_tasks_generic_gp_kthread(struct rcu_tasks *rtp, char *s)
281566 {
567+ struct rcu_tasks_percpu *rtpcp = per_cpu_ptr(rtp->rtpcpu, 0); // for_each...
282568 pr_info("%s: %s(%d) since %lu g:%lu i:%lu/%lu %c%c %s\n",
283569 rtp->kname,
284570 tasks_gp_state_getname(rtp), data_race(rtp->gp_state),
285571 jiffies - data_race(rtp->gp_jiffies),
286− data_race(rtp->n_gps),
572+ data_race(rcu_seq_current(&rtp->tasks_gp_seq)),
287573 data_race(rtp->n_ipis_fails), data_race(rtp->n_ipis),
288574 ".k"[!!data_race(rtp->kthread_ptr)],
289− ".C"[!!data_race(rtp->cbs_head)],
575+ ".C"[!data_race(rcu_segcblist_empty(&rtpcp->cblist))],
290576 s);
291577 }
292578 #endif // #ifndef CONFIG_TINY_RCU
@@ -411,10 +697,10 @@ static void rcu_tasks_wait_gp(struct rcu_tasks *rtp) · 118 unmodified lines
411697 // exit_tasks_rcu_finish() functions begin and end, respectively, the SRCU
412698 // read-side critical sections waited for by rcu_tasks_postscan().
413699 //
414−// Pre-grace-period update-side code is ordered before the grace via the
415−// ->cbs_lock and the smp_mb__after_spinlock(). Pre-grace-period read-side
416−// code is ordered before the grace period via synchronize_rcu() call
417−// in rcu_tasks_pregp_step() and by the scheduler's locks and interrupt
700+// Pre-grace-period update-side code is ordered before the grace
701+// via the raw_spin_lock.*rcu_node(). Pre-grace-period read-side code
702+// is ordered before the grace period via synchronize_rcu() call in
703+// rcu_tasks_pregp_step() and by the scheduler's locks and interrupt
418704 // disabling.
419705
420706 /* Pre-grace-period preparation. */
@@ -586,13 +872,13 @@ EXPORT_SYMBOL_GPL(synchronize_rcu_tasks); · 165 unmodified lines
586872 */
587873 void rcu_barrier_tasks(void)
588874 {
589− /* There is only one callback queue, so this is easy. ;-) */
590− synchronize_rcu_tasks();
875+ rcu_barrier_tasks_generic(&rcu_tasks);
591876 }
592877 EXPORT_SYMBOL_GPL(rcu_barrier_tasks);
593878
594879 static int __init rcu_spawn_tasks_kthread(void)
595880 {
881+ cblist_init_generic(&rcu_tasks);
596882 rcu_tasks.gp_sleep = HZ / 10;
597883 rcu_tasks.init_fract = HZ / 10;
598884 rcu_tasks.pregp_func = rcu_tasks_pregp_step;
@@ -724,13 +1010,13 @@ EXPORT_SYMBOL_GPL(synchronize_rcu_tasks_rude); · 125 unmodified lines
7241010 */
7251011 void rcu_barrier_tasks_rude(void)
7261012 {
727− /* There is only one callback queue, so this is easy. ;-) */
728− synchronize_rcu_tasks_rude();
1013+ rcu_barrier_tasks_generic(&rcu_tasks_rude);
7291014 }
7301015 EXPORT_SYMBOL_GPL(rcu_barrier_tasks_rude);
7311016
7321017 static int __init rcu_spawn_tasks_rude_kthread(void)
7331018 {
1019+ cblist_init_generic(&rcu_tasks_rude);
7341020 rcu_tasks_rude.gp_sleep = HZ / 10;
7351021 rcu_spawn_tasks_kthread_generic(&rcu_tasks_rude);
7361022 return 0;
@@ -1073,25 +1359,50 @@ static void rcu_tasks_trace_postscan(struct list_head *hop) · 336 unmodified lines
10731359 // Any tasks that exit after this point will set ->trc_reader_checked.
10741360 }
10751361
1362+/* Communicate task state back to the RCU tasks trace stall warning request. */
1363+struct trc_stall_chk_rdr {
1364+ int nesting;
1365+ int ipi_to_cpu;
1366+ u8 needqs;
1367+};
1368+
1369+static int trc_check_slow_task(struct task_struct *t, void *arg)
1370+{
1371+ struct trc_stall_chk_rdr *trc_rdrp = arg;
1372+
1373+ if (task_curr(t))
1374+ return false; // It is running, so decline to inspect it.
1375+ trc_rdrp->nesting = READ_ONCE(t->trc_reader_nesting);
1376+ trc_rdrp->ipi_to_cpu = READ_ONCE(t->trc_ipi_to_cpu);
1377+ trc_rdrp->needqs = READ_ONCE(t->trc_reader_special.b.need_qs);
1378+ return true;
1379+}
1380+
10761381 /* Show the state of a task stalling the current RCU tasks trace GP. */
10771382 static void show_stalled_task_trace(struct task_struct *t, bool *firstreport)
10781383 {
10791384 int cpu;
1385+ struct trc_stall_chk_rdr trc_rdr;
1386+ bool is_idle_tsk = is_idle_task(t);
10801387
10811388 if (*firstreport) {
10821389 pr_err("INFO: rcu_tasks_trace detected stalls on tasks:\n");
10831390 *firstreport = false;
10841391 }
1085− // FIXME: This should attempt to use try_invoke_on_nonrunning_task().
10861392 cpu = task_cpu(t);
1087− pr_alert("P%d: %c%c%c nesting: %d%c cpu: %d\n",
1088− t->pid,
1089− ".I"[READ_ONCE(t->trc_ipi_to_cpu) >= 0],
1090− ".i"[is_idle_task(t)],
1091− ".N"[cpu >= 0 && tick_nohz_full_cpu(cpu)],
1092− READ_ONCE(t->trc_reader_nesting),
1093− " N"[!!READ_ONCE(t->trc_reader_special.b.need_qs)],
1094− cpu);
1393+ if (!task_call_func(t, trc_check_slow_task, &trc_rdr))
1394+ pr_alert("P%d: %c\n",
1395+ t->pid,
1396+ ".i"[is_idle_tsk]);
1397+ else
1398+ pr_alert("P%d: %c%c%c nesting: %d%c cpu: %d\n",
1399+ t->pid,
1400+ ".I"[trc_rdr.ipi_to_cpu >= 0],
1401+ ".i"[is_idle_tsk],
1402+ ".N"[cpu >= 0 && tick_nohz_full_cpu(cpu)],
1403+ trc_rdr.nesting,
1404+ " N"[!!trc_rdr.needqs],
1405+ cpu);
10951406 sched_show_task(t);
10961407 }
10971408
@@ -1121,7 +1432,8 @@ static void check_all_holdout_tasks_trace(struct list_head *hop, · 23 unmodified lines
11211432 trc_wait_for_one_reader(t, hop);
11221433
11231434 // If check succeeded, remove this task from the list.
1124− if (READ_ONCE(t->trc_reader_checked))
1435+ if (smp_load_acquire(&t->trc_ipi_to_cpu) == -1 &&
1436+ READ_ONCE(t->trc_reader_checked))
11251437 trc_del_holdout(t);
11261438 else if (needreport)
11271439 show_stalled_task_trace(t, firstreport);
@@ -1156,7 +1468,7 @@ static void rcu_tasks_trace_postgp(struct rcu_tasks *rtp) · 28 unmodified lines
11561468 // Yes, this assumes that CPUs process IPIs in order. If that ever
11571469 // changes, there will need to be a recheck and/or timed wait.
11581470 for_each_online_cpu(cpu)
1159− if (smp_load_acquire(per_cpu_ptr(&trc_ipi_to_cpu, cpu)))
1471+ if (WARN_ON_ONCE(smp_load_acquire(per_cpu_ptr(&trc_ipi_to_cpu, cpu))))
11601472 smp_call_function_single(cpu, rcu_tasks_trace_empty_fn, NULL, 1);
11611473
11621474 // Remove the safety count.
@@ -1256,13 +1568,13 @@ EXPORT_SYMBOL_GPL(synchronize_rcu_tasks_trace); · 93 unmodified lines
12561568 */
12571569 void rcu_barrier_tasks_trace(void)
12581570 {
1259− /* There is only one callback queue, so this is easy. ;-) */
1260− synchronize_rcu_tasks_trace();
1571+ rcu_barrier_tasks_generic(&rcu_tasks_trace);
12611572 }
12621573 EXPORT_SYMBOL_GPL(rcu_barrier_tasks_trace);
12631574
12641575 static int __init rcu_spawn_tasks_trace_kthread(void)
12651576 {
1577+ cblist_init_generic(&rcu_tasks_trace);
12661578 if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB)) {
12671579 rcu_tasks_trace.gp_sleep = HZ / 10;
12681580 rcu_tasks_trace.init_fract = HZ / 10;
kernel/rcu/tree.c+86−45
@@ -79,7 +79,7 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, rcu_data) = { · 78 unmodified lines
7979 .dynticks_nmi_nesting = DYNTICK_IRQ_NONIDLE,
8080 .dynticks = ATOMIC_INIT(1),
8181 #ifdef CONFIG_RCU_NOCB_CPU
82− .cblist.flags = SEGCBLIST_SOFTIRQ_ONLY,
82+ .cblist.flags = SEGCBLIST_RCU_CORE,
8383 #endif
8484 };
8585 static struct rcu_state rcu_state = {
@@ -624,7 +624,6 @@ static noinstr void rcu_eqs_enter(bool user) · 538 unmodified lines
624624 instrumentation_begin();
625625 trace_rcu_dyntick(TPS("Start"), rdp->dynticks_nesting, 0, atomic_read(&rdp->dynticks));
626626 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !user && !is_idle_task(current));
627− rcu_prepare_for_idle();
628627 rcu_preempt_deferred_qs(current);
629628
630629 // instrumentation for the noinstr rcu_dynticks_eqs_enter()
@@ -768,9 +767,6 @@ noinstr void rcu_nmi_exit(void) · 137 unmodified lines
768767 trace_rcu_dyntick(TPS("Startirq"), rdp->dynticks_nmi_nesting, 0, atomic_read(&rdp->dynticks));
769768 WRITE_ONCE(rdp->dynticks_nmi_nesting, 0); /* Avoid store tearing. */
770769
771− if (!in_nmi())
772− rcu_prepare_for_idle();
773−
774770 // instrumentation for the noinstr rcu_dynticks_eqs_enter()
775771 instrument_atomic_write(&rdp->dynticks, sizeof(rdp->dynticks));
776772 instrumentation_end();
@@ -872,7 +868,6 @@ static void noinstr rcu_eqs_exit(bool user) · 95 unmodified lines
872868 // instrumentation for the noinstr rcu_dynticks_eqs_exit()
873869 instrument_atomic_write(&rdp->dynticks, sizeof(rdp->dynticks));
874870
875− rcu_cleanup_after_idle();
876871 trace_rcu_dyntick(TPS("End"), rdp->dynticks_nesting, 1, atomic_read(&rdp->dynticks));
877872 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !user && !is_idle_task(current));
878873 WRITE_ONCE(rdp->dynticks_nesting, 1);
@@ -1014,12 +1009,6 @@ noinstr void rcu_nmi_enter(void) · 135 unmodified lines
10141009 rcu_dynticks_eqs_exit();
10151010 // ... but is watching here.
10161011
1017− if (!in_nmi()) {
1018− instrumentation_begin();
1019− rcu_cleanup_after_idle();
1020− instrumentation_end();
1021− }
1022−
10231012 instrumentation_begin();
10241013 // instrumentation for the noinstr rcu_dynticks_curr_cpu_in_eqs()
10251014 instrument_atomic_read(&rdp->dynticks, sizeof(rdp->dynticks));
@@ -1086,6 +1075,24 @@ void rcu_irq_enter_irqson(void) · 60 unmodified lines
10861075 local_irq_restore(flags);
10871076 }
10881077
1078+/*
1079+ * Check to see if any future non-offloaded RCU-related work will need
1080+ * to be done by the current CPU, even if none need be done immediately,
1081+ * returning 1 if so. This function is part of the RCU implementation;
1082+ * it is -not- an exported member of the RCU API. This is used by
1083+ * the idle-entry code to figure out whether it is safe to disable the
1084+ * scheduler-clock interrupt.
1085+ *
1086+ * Just check whether or not this CPU has non-offloaded RCU callbacks
1087+ * queued.
1088+ */
1089+int rcu_needs_cpu(u64 basemono, u64 *nextevt)
1090+{
1091+ *nextevt = KTIME_MAX;
1092+ return !rcu_segcblist_empty(&this_cpu_ptr(&rcu_data)->cblist) &&
1093+ !rcu_rdp_is_offloaded(this_cpu_ptr(&rcu_data));
1094+}
1095+
10891096 /*
10901097 * If any sort of urgency was applied to the current CPU (for example,
10911098 * the scheduler-clock interrupt was enabled on a nohz_full CPU) in order
@@ -1467,7 +1474,7 @@ static void rcu_gp_kthread_wake(void) · 375 unmodified lines
14671474 {
14681475 struct task_struct *t = READ_ONCE(rcu_state.gp_kthread);
14691476
1470− if ((current == t && !in_irq() && !in_serving_softirq()) ||
1477+ if ((current == t && !in_hardirq() && !in_serving_softirq()) ||
14711478 !READ_ONCE(rcu_state.gp_flags) || !t)
14721479 return;
14731480 WRITE_ONCE(rcu_state.gp_wake_time, jiffies);
@@ -1590,10 +1597,11 @@ static void __maybe_unused rcu_advance_cbs_nowake(struct rcu_node *rnp, · 116 unmodified lines
15901597 struct rcu_data *rdp)
15911598 {
15921599 rcu_lockdep_assert_cblist_protected(rdp);
1593− if (!rcu_seq_state(rcu_seq_current(&rnp->gp_seq)) ||
1594− !raw_spin_trylock_rcu_node(rnp))
1600+ if (!rcu_seq_state(rcu_seq_current(&rnp->gp_seq)) || !raw_spin_trylock_rcu_node(rnp))
15951601 return;
1596− WARN_ON_ONCE(rcu_advance_cbs(rnp, rdp));
1602+ // The grace period cannot end while we hold the rcu_node lock.
1603+ if (rcu_seq_state(rcu_seq_current(&rnp->gp_seq)))
1604+ WARN_ON_ONCE(rcu_advance_cbs(rnp, rdp));
15971605 raw_spin_unlock_rcu_node(rnp);
15981606 }
15991607
@@ -2277,7 +2285,7 @@ rcu_report_qs_rdp(struct rcu_data *rdp) · 677 unmodified lines
22772285 unsigned long flags;
22782286 unsigned long mask;
22792287 bool needwake = false;
2280− const bool offloaded = rcu_rdp_is_offloaded(rdp);
2288+ bool needacc = false;
22812289 struct rcu_node *rnp;
22822290
22832291 WARN_ON_ONCE(rdp->cpu != smp_processor_id());
@@ -2304,15 +2312,30 @@ rcu_report_qs_rdp(struct rcu_data *rdp) · 20 unmodified lines
23042312 /*
23052313 * This GP can't end until cpu checks in, so all of our
23062314 * callbacks can be processed during the next GP.
2315+ *
2316+ * NOCB kthreads have their own way to deal with that...
23072317 */
2308− if (!offloaded)
2318+ if (!rcu_rdp_is_offloaded(rdp)) {
23092319 needwake = rcu_accelerate_cbs(rnp, rdp);
2320+ } else if (!rcu_segcblist_completely_offloaded(&rdp->cblist)) {
2321+ /*
2322+ * ...but NOCB kthreads may miss or delay callbacks acceleration
2323+ * if in the middle of a (de-)offloading process.
2324+ */
2325+ needacc = true;
2326+ }
23102327
23112328 rcu_disable_urgency_upon_qs(rdp);
23122329 rcu_report_qs_rnp(mask, rnp, rnp->gp_seq, flags);
23132330 /* ^^^ Released rnp->lock */
23142331 if (needwake)
23152332 rcu_gp_kthread_wake();
2333+
2334+ if (needacc) {
2335+ rcu_nocb_lock_irqsave(rdp, flags);
2336+ rcu_accelerate_cbs_unlocked(rnp, rdp);
2337+ rcu_nocb_unlock_irqrestore(rdp, flags);
2338+ }
23162339 }
23172340 }
23182341
@@ -2444,7 +2467,6 @@ static void rcu_do_batch(struct rcu_data *rdp) · 125 unmodified lines
24442467 int div;
24452468 bool __maybe_unused empty;
24462469 unsigned long flags;
2447− const bool offloaded = rcu_rdp_is_offloaded(rdp);
24482470 struct rcu_head *rhp;
24492471 struct rcu_cblist rcl = RCU_CBLIST_INITIALIZER(rcl);
24502472 long bl, count = 0;
@@ -2462,18 +2484,17 @@ static void rcu_do_batch(struct rcu_data *rdp) · 11 unmodified lines
24622484 }
24632485
24642486 /*
2465− * Extract the list of ready callbacks, disabling to prevent
2487+ * Extract the list of ready callbacks, disabling IRQs to prevent
24662488 * races with call_rcu() from interrupt handlers. Leave the
24672489 * callback counts, as rcu_barrier() needs to be conservative.
24682490 */
2469− local_irq_save(flags);
2470− rcu_nocb_lock(rdp);
2491+ rcu_nocb_lock_irqsave(rdp, flags);
24712492 WARN_ON_ONCE(cpu_is_offline(smp_processor_id()));
24722493 pending = rcu_segcblist_n_cbs(&rdp->cblist);
24732494 div = READ_ONCE(rcu_divisor);
24742495 div = div < 0 ? 7 : div > sizeof(long) * 8 - 2 ? sizeof(long) * 8 - 2 : div;
24752496 bl = max(rdp->blimit, pending >> div);
2476− if (unlikely(bl > 100)) {
2497+ if (in_serving_softirq() && unlikely(bl > 100)) {
24772498 long rrn = READ_ONCE(rcu_resched_ns);
24782499
24792500 rrn = rrn < NSEC_PER_MSEC ? NSEC_PER_MSEC : rrn > NSEC_PER_SEC ? NSEC_PER_SEC : rrn;
@@ -2482,7 +2503,7 @@ static void rcu_do_batch(struct rcu_data *rdp) · 2 unmodified lines
24822503 trace_rcu_batch_start(rcu_state.name,
24832504 rcu_segcblist_n_cbs(&rdp->cblist), bl);
24842505 rcu_segcblist_extract_done_cbs(&rdp->cblist, &rcl);
2485− if (offloaded)
2506+ if (rcu_rdp_is_offloaded(rdp))
24862507 rdp->qlen_last_fqs_check = rcu_segcblist_n_cbs(&rdp->cblist);
24872508
24882509 trace_rcu_segcb_stats(&rdp->cblist, TPS("SegCbDequeued"));
@@ -2510,18 +2531,21 @@ static void rcu_do_batch(struct rcu_data *rdp) · 21 unmodified lines
25102531 /*
25112532 * Stop only if limit reached and CPU has something to do.
25122533 */
2513− if (count >= bl && !offloaded &&
2514− (need_resched() ||
2515− (!is_idle_task(current) && !rcu_is_callbacks_kthread())))
2516− break;
2517− if (unlikely(tlimit)) {
2518− /* only call local_clock() every 32 callbacks */
2519− if (likely((count & 31) || local_clock() < tlimit))
2520− continue;
2521− /* Exceeded the time limit, so leave. */
2522− break;
2523− }
2524− if (!in_serving_softirq()) {
2534+ if (in_serving_softirq()) {
2535+ if (count >= bl && (need_resched() || !is_idle_task(current)))
2536+ break;
2537+ /*
2538+ * Make sure we don't spend too much time here and deprive other
2539+ * softirq vectors of CPU cycles.
2540+ */
2541+ if (unlikely(tlimit)) {
2542+ /* only call local_clock() every 32 callbacks */
2543+ if (likely((count & 31) || local_clock() < tlimit))
2544+ continue;
2545+ /* Exceeded the time limit, so leave. */
2546+ break;
2547+ }
2548+ } else {
25252549 local_bh_enable();
25262550 lockdep_assert_irqs_enabled();
25272551 cond_resched_tasks_rcu_qs();
@@ -2530,8 +2554,7 @@ static void rcu_do_batch(struct rcu_data *rdp) · 2 unmodified lines
25302554 }
25312555 }
25322556
2533− local_irq_save(flags);
2534− rcu_nocb_lock(rdp);
2557+ rcu_nocb_lock_irqsave(rdp, flags);
25352558 rdp->n_cbs_invoked += count;
25362559 trace_rcu_batch_end(rcu_state.name, count, !!rcl.head, need_resched(),
25372560 is_idle_task(current), rcu_is_callbacks_kthread());
@@ -2565,9 +2588,6 @@ static void rcu_do_batch(struct rcu_data *rdp) · 27 unmodified lines
25652588
25662589 rcu_nocb_unlock_irqrestore(rdp, flags);
25672590
2568− /* Re-invoke RCU core processing if there are callbacks remaining. */
2569− if (!offloaded && rcu_segcblist_ready_cbs(&rdp->cblist))
2570− invoke_rcu_core();
25712591 tick_dep_clear_task(current, TICK_DEP_BIT_RCU);
25722592 }
25732593
@@ -2706,6 +2726,23 @@ static __latent_entropy void rcu_core(void) · 132 unmodified lines
27062726 unsigned long flags;
27072727 struct rcu_data *rdp = raw_cpu_ptr(&rcu_data);
27082728 struct rcu_node *rnp = rdp->mynode;
2729+ /*
2730+ * On RT rcu_core() can be preempted when IRQs aren't disabled.
2731+ * Therefore this function can race with concurrent NOCB (de-)offloading
2732+ * on this CPU and the below condition must be considered volatile.
2733+ * However if we race with:
2734+ *
2735+ * _ Offloading: In the worst case we accelerate or process callbacks
2736+ * concurrently with NOCB kthreads. We are guaranteed to
2737+ * call rcu_nocb_lock() if that happens.
2738+ *
2739+ * _ Deoffloading: In the worst case we miss callbacks acceleration or
2740+ * processing. This is fine because the early stage
2741+ * of deoffloading invokes rcu_core() after setting
2742+ * SEGCBLIST_RCU_CORE. So we guarantee that we'll process
2743+ * what could have been dismissed without the need to wait
2744+ * for the next rcu_pending() check in the next jiffy.
2745+ */
27092746 const bool do_batch = !rcu_segcblist_completely_offloaded(&rdp->cblist);
27102747
27112748 if (cpu_is_offline(smp_processor_id()))
@@ -2714,7 +2751,7 @@ static __latent_entropy void rcu_core(void) · 2 unmodified lines
27142751 WARN_ON_ONCE(!rdp->beenonline);
27152752
27162753 /* Report any deferred quiescent states if preemption enabled. */
2717− if (!(preempt_count() & PREEMPT_MASK)) {
2754+ if (IS_ENABLED(CONFIG_PREEMPT_COUNT) && (!(preempt_count() & PREEMPT_MASK))) {
27182755 rcu_preempt_deferred_qs(current);
27192756 } else if (rcu_preempt_need_deferred_qs(current)) {
27202757 set_tsk_need_resched(current);
@@ -2737,8 +2774,12 @@ static __latent_entropy void rcu_core(void) · 16 unmodified lines
27372774
27382775 /* If there are callbacks ready, invoke them. */
27392776 if (do_batch && rcu_segcblist_ready_cbs(&rdp->cblist) &&
2740− likely(READ_ONCE(rcu_scheduler_fully_active)))
2777+ likely(READ_ONCE(rcu_scheduler_fully_active))) {
27412778 rcu_do_batch(rdp);
2779+ /* Re-invoke RCU core processing if there are callbacks remaining. */
2780+ if (rcu_segcblist_ready_cbs(&rdp->cblist))
2781+ invoke_rcu_core();
2782+ }
27422783
27432784 /* Do any needed deferred wakeups of rcuo kthreads. */
27442785 do_nocb_deferred_wakeup(rdp);
@@ -2982,7 +3023,7 @@ __call_rcu(struct rcu_head *head, rcu_callback_t func) · 237 unmodified lines
29823023 head->func = func;
29833024 head->next = NULL;
29843025 local_irq_save(flags);
2985− kasan_record_aux_stack(head);
3026+ kasan_record_aux_stack_noalloc(head);
29863027 rdp = this_cpu_ptr(&rcu_data);
29873028
29883029 /* Add the callback to our list. */
@@ -3547,7 +3588,7 @@ void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func) · 558 unmodified lines
35473588 return;
35483589 }
35493590
3550− kasan_record_aux_stack(ptr);
3591+ kasan_record_aux_stack_noalloc(ptr);
35513592 success = add_ptr_to_bulk_krc_lock(&krcp, &flags, ptr, !head);
35523593 if (!success) {
35533594 run_page_cache_worker(krcp);
kernel/rcu/tree.h+15−16
@@ -157,7 +157,6 @@ struct rcu_data { · 156 unmodified lines
157157 bool core_needs_qs; /* Core waits for quiescent state. */
158158 bool beenonline; /* CPU online at least once. */
159159 bool gpwrap; /* Possible ->gp_seq wrap. */
160− bool exp_deferred_qs; /* This CPU awaiting a deferred QS? */
161160 bool cpu_started; /* RCU watching this onlining CPU. */
162161 struct rcu_node *mynode; /* This CPU's leaf of hierarchy */
163162 unsigned long grpmask; /* Mask to apply to leaf qsmask. */
@@ -189,11 +188,6 @@ struct rcu_data { · 25 unmodified lines
189188 bool rcu_urgent_qs; /* GP old need light quiescent state. */
190189 bool rcu_forced_tick; /* Forced tick to provide QS. */
191190 bool rcu_forced_tick_exp; /* ... provide QS to expedited GP. */
192−#ifdef CONFIG_RCU_FAST_NO_HZ
193− unsigned long last_accelerate; /* Last jiffy CBs were accelerated. */
194− unsigned long last_advance_all; /* Last jiffy CBs were all advanced. */
195− int tick_nohz_enabled_snap; /* Previously seen value from sysfs. */
196−#endif /* #ifdef CONFIG_RCU_FAST_NO_HZ */
197191
198192 /* 4) rcu_barrier(), OOM callbacks, and expediting. */
199193 struct rcu_head barrier_head;
@@ -227,8 +221,11 @@ struct rcu_data { · 27 unmodified lines
227221 struct swait_queue_head nocb_gp_wq; /* For nocb kthreads to sleep on. */
228222 bool nocb_cb_sleep; /* Is the nocb CB thread asleep? */
229223 struct task_struct *nocb_cb_kthread;
230− struct rcu_data *nocb_next_cb_rdp;
231− /* Next rcu_data in wakeup chain. */
224+ struct list_head nocb_head_rdp; /*
225+ * Head of rcu_data list in wakeup chain,
226+ * if rdp_gp.
227+ */
228+ struct list_head nocb_entry_rdp; /* rcu_data node in wakeup chain. */
232229
233230 /* The following fields are used by CB kthread, hence new cacheline. */
234231 struct rcu_data *nocb_gp_rdp ____cacheline_internodealigned_in_smp;
@@ -419,8 +416,6 @@ static bool rcu_is_callbacks_kthread(void); · 184 unmodified lines
419416 static void rcu_cpu_kthread_setup(unsigned int cpu);
420417 static void rcu_spawn_one_boost_kthread(struct rcu_node *rnp);
421418 static void __init rcu_spawn_boost_kthreads(void);
422−static void rcu_cleanup_after_idle(void);
423−static void rcu_prepare_for_idle(void);
424419 static bool rcu_preempt_has_tasks(struct rcu_node *rnp);
425420 static bool rcu_preempt_need_deferred_qs(struct task_struct *t);
426421 static void rcu_preempt_deferred_qs(struct task_struct *t);
@@ -447,12 +442,16 @@ static void rcu_nocb_unlock_irqrestore(struct rcu_data *rdp, · 20 unmodified lines
447442 static void rcu_lockdep_assert_cblist_protected(struct rcu_data *rdp);
448443 #ifdef CONFIG_RCU_NOCB_CPU
449444 static void __init rcu_organize_nocb_kthreads(void);
450−#define rcu_nocb_lock_irqsave(rdp, flags) \
451−do { \
452− if (!rcu_segcblist_is_offloaded(&(rdp)->cblist)) \
453− local_irq_save(flags); \
454− else \
455− raw_spin_lock_irqsave(&(rdp)->nocb_lock, (flags)); \
445+
446+/*
447+ * Disable IRQs before checking offloaded state so that local
448+ * locking is safe against concurrent de-offloading.
449+ */
450+#define rcu_nocb_lock_irqsave(rdp, flags) \
451+do { \
452+ local_irq_save(flags); \
453+ if (rcu_segcblist_is_offloaded(&(rdp)->cblist)) \
454+ raw_spin_lock(&(rdp)->nocb_lock); \
456455 } while (0)
457456 #else /* #ifdef CONFIG_RCU_NOCB_CPU */
458457 #define rcu_nocb_lock_irqsave(rdp, flags) local_irq_save(flags)
kernel/rcu/tree_exp.h+9−5
@@ -255,7 +255,7 @@ static void rcu_report_exp_cpu_mult(struct rcu_node *rnp, · 254 unmodified lines
255255 */
256256 static void rcu_report_exp_rdp(struct rcu_data *rdp)
257257 {
258− WRITE_ONCE(rdp->exp_deferred_qs, false);
258+ WRITE_ONCE(rdp->cpu_no_qs.b.exp, false);
259259 rcu_report_exp_cpu_mult(rdp->mynode, rdp->grpmask, true);
260260 }
261261
@@ -387,6 +387,7 @@ retry_ipi: · 125 unmodified lines
387387 continue;
388388 }
389389 if (get_cpu() == cpu) {
390+ mask_ofl_test |= mask;
390391 put_cpu();
391392 continue;
392393 }
@@ -506,7 +507,10 @@ static void synchronize_rcu_expedited_wait(void) · 113 unmodified lines
506507 if (rdp->rcu_forced_tick_exp)
507508 continue;
508509 rdp->rcu_forced_tick_exp = true;
509− tick_dep_set_cpu(cpu, TICK_DEP_BIT_RCU_EXP);
510+ preempt_disable();
511+ if (cpu_online(cpu))
512+ tick_dep_set_cpu(cpu, TICK_DEP_BIT_RCU_EXP);
513+ preempt_enable();
510514 }
511515 }
512516 j = READ_ONCE(jiffies_till_first_fqs);
@@ -655,7 +659,7 @@ static void rcu_exp_handler(void *unused) · 142 unmodified lines
655659 rcu_dynticks_curr_cpu_in_eqs()) {
656660 rcu_report_exp_rdp(rdp);
657661 } else {
658− rdp->exp_deferred_qs = true;
662+ WRITE_ONCE(rdp->cpu_no_qs.b.exp, true);
659663 set_tsk_need_resched(t);
660664 set_preempt_need_resched();
661665 }
@@ -677,7 +681,7 @@ static void rcu_exp_handler(void *unused) · 15 unmodified lines
677681 if (depth > 0) {
678682 raw_spin_lock_irqsave_rcu_node(rnp, flags);
679683 if (rnp->expmask & rdp->grpmask) {
680− rdp->exp_deferred_qs = true;
684+ WRITE_ONCE(rdp->cpu_no_qs.b.exp, true);
681685 t->rcu_read_unlock_special.b.exp_hint = true;
682686 }
683687 raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
@@ -759,7 +763,7 @@ static void sync_sched_exp_online_cleanup(int cpu) · 75 unmodified lines
759763 my_cpu = get_cpu();
760764 /* Quiescent state either not needed or already requested, leave. */
761765 if (!(READ_ONCE(rnp->expmask) & rdp->grpmask) ||
762− rdp->cpu_no_qs.b.exp) {
766+ READ_ONCE(rdp->cpu_no_qs.b.exp)) {
763767 put_cpu();
764768 return;
765769 }
kernel/rcu/tree_nocb.h+106−54
@@ -60,16 +60,22 @@ static inline bool rcu_current_is_nocb_kthread(struct rcu_data *rdp) · 59 unmodified lines
6060 * Parse the boot-time rcu_nocb_mask CPU list from the kernel parameters.
6161 * If the list is invalid, a warning is emitted and all CPUs are offloaded.
6262 */
63+
64+static bool rcu_nocb_is_setup;
65+
6366 static int __init rcu_nocb_setup(char *str)
6467 {
6568 alloc_bootmem_cpumask_var(&rcu_nocb_mask);
66− if (cpulist_parse(str, rcu_nocb_mask)) {
67− pr_warn("rcu_nocbs= bad CPU range, all CPUs set\n");
68− cpumask_setall(rcu_nocb_mask);
69+ if (*str == '=') {
70+ if (cpulist_parse(++str, rcu_nocb_mask)) {
71+ pr_warn("rcu_nocbs= bad CPU range, all CPUs set\n");
72+ cpumask_setall(rcu_nocb_mask);
73+ }
6974 }
75+ rcu_nocb_is_setup = true;
7076 return 1;
7177 }
72−__setup("rcu_nocbs=", rcu_nocb_setup);
78+__setup("rcu_nocbs", rcu_nocb_setup);
7379
7480 static int __init parse_rcu_nocb_poll(char *arg)
7581 {
@@ -625,7 +631,21 @@ static void nocb_gp_wait(struct rcu_data *my_rdp) · 549 unmodified lines
625631 * and the global grace-period kthread are awakened if needed.
626632 */
627633 WARN_ON_ONCE(my_rdp->nocb_gp_rdp != my_rdp);
628− for (rdp = my_rdp; rdp; rdp = rdp->nocb_next_cb_rdp) {
634+ /*
635+ * An rcu_data structure is removed from the list after its
636+ * CPU is de-offloaded and added to the list before that CPU is
637+ * (re-)offloaded. If the following loop happens to be referencing
638+ * that rcu_data structure during the time that the corresponding
639+ * CPU is de-offloaded and then immediately re-offloaded, this
640+ * loop's rdp pointer will be carried to the end of the list by
641+ * the resulting pair of list operations. This can cause the loop
642+ * to skip over some of the rcu_data structures that were supposed
643+ * to have been scanned. Fortunately a new iteration through the
644+ * entire loop is forced after a given CPU's rcu_data structure
645+ * is added to the list, so the skipped-over rcu_data structures
646+ * won't be ignored for long.
647+ */
648+ list_for_each_entry_rcu(rdp, &my_rdp->nocb_head_rdp, nocb_entry_rdp, 1) {
629649 bool needwake_state = false;
630650
631651 if (!nocb_gp_enabled_cb(rdp))
@@ -789,6 +809,18 @@ static void nocb_cb_wait(struct rcu_data *rdp) · 157 unmodified lines
789809 bool can_sleep = true;
790810 struct rcu_node *rnp = rdp->mynode;
791811
812+ do {
813+ swait_event_interruptible_exclusive(rdp->nocb_cb_wq,
814+ nocb_cb_wait_cond(rdp));
815+
816+ // VVV Ensure CB invocation follows _sleep test.
817+ if (smp_load_acquire(&rdp->nocb_cb_sleep)) { // ^^^
818+ WARN_ON(signal_pending(current));
819+ trace_rcu_nocb_wake(rcu_state.name, rdp->cpu, TPS("WokeEmpty"));
820+ }
821+ } while (!nocb_cb_can_run(rdp));
822+
823+
792824 local_irq_save(flags);
793825 rcu_momentary_dyntick_idle();
794826 local_irq_restore(flags);
@@ -841,17 +873,6 @@ static void nocb_cb_wait(struct rcu_data *rdp) · 46 unmodified lines
841873
842874 if (needwake_state)
843875 swake_up_one(&rdp->nocb_state_wq);
844−
845− do {
846− swait_event_interruptible_exclusive(rdp->nocb_cb_wq,
847− nocb_cb_wait_cond(rdp));
848−
849− // VVV Ensure CB invocation follows _sleep test.
850− if (smp_load_acquire(&rdp->nocb_cb_sleep)) { // ^^^
851− WARN_ON(signal_pending(current));
852− trace_rcu_nocb_wake(rcu_state.name, rdp->cpu, TPS("WokeEmpty"));
853− }
854− } while (!nocb_cb_can_run(rdp));
855876 }
856877
857878 /*
@@ -990,22 +1011,33 @@ static long rcu_nocb_rdp_deoffload(void *arg) · 132 unmodified lines
9901011 * will refuse to put anything into the bypass.
9911012 */
9921013 WARN_ON_ONCE(!rcu_nocb_flush_bypass(rdp, NULL, jiffies));
1014+ /*
1015+ * Start with invoking rcu_core() early. This way if the current thread
1016+ * happens to preempt an ongoing call to rcu_core() in the middle,
1017+ * leaving some work dismissed because rcu_core() still thinks the rdp is
1018+ * completely offloaded, we are guaranteed a nearby future instance of
1019+ * rcu_core() to catch up.
1020+ */
1021+ rcu_segcblist_set_flags(cblist, SEGCBLIST_RCU_CORE);
1022+ invoke_rcu_core();
9931023 ret = rdp_offload_toggle(rdp, false, flags);
9941024 swait_event_exclusive(rdp->nocb_state_wq,
9951025 !rcu_segcblist_test_flags(cblist, SEGCBLIST_KTHREAD_CB |
9961026 SEGCBLIST_KTHREAD_GP));
1027+ /* Stop nocb_gp_wait() from iterating over this structure. */
1028+ list_del_rcu(&rdp->nocb_entry_rdp);
9971029 /*
9981030 * Lock one last time to acquire latest callback updates from kthreads
9991031 * so we can later handle callbacks locally without locking.
10001032 */
10011033 rcu_nocb_lock_irqsave(rdp, flags);
10021034 /*
1003− * Theoretically we could set SEGCBLIST_SOFTIRQ_ONLY after the nocb
1035+ * Theoretically we could clear SEGCBLIST_LOCKING after the nocb
10041036 * lock is released but how about being paranoid for once?
10051037 */
1006− rcu_segcblist_set_flags(cblist, SEGCBLIST_SOFTIRQ_ONLY);
1038+ rcu_segcblist_clear_flags(cblist, SEGCBLIST_LOCKING);
10071039 /*
1008− * With SEGCBLIST_SOFTIRQ_ONLY, we can't use
1040+ * Without SEGCBLIST_LOCKING, we can't use
10091041 * rcu_nocb_unlock_irqrestore() anymore.
10101042 */
10111043 raw_spin_unlock_irqrestore(&rdp->nocb_lock, flags);
@@ -1057,15 +1089,26 @@ static long rcu_nocb_rdp_offload(void *arg) · 45 unmodified lines
10571089 return -EINVAL;
10581090
10591091 pr_info("Offloading %d\n", rdp->cpu);
1092+
1093+ /*
1094+ * Cause future nocb_gp_wait() invocations to iterate over
1095+ * structure, resetting ->nocb_gp_sleep and waking up the related
1096+ * "rcuog". Since nocb_gp_wait() in turn locks ->nocb_gp_lock
1097+ * before setting ->nocb_gp_sleep again, we are guaranteed to
1098+ * iterate this newly added structure before "rcuog" goes to
1099+ * sleep again.
1100+ */
1101+ list_add_tail_rcu(&rdp->nocb_entry_rdp, &rdp->nocb_gp_rdp->nocb_head_rdp);
1102+
10601103 /*
1061− * Can't use rcu_nocb_lock_irqsave() while we are in
1062− * SEGCBLIST_SOFTIRQ_ONLY mode.
1104+ * Can't use rcu_nocb_lock_irqsave() before SEGCBLIST_LOCKING
1105+ * is set.
10631106 */
10641107 raw_spin_lock_irqsave(&rdp->nocb_lock, flags);
10651108
10661109 /*
10671110 * We didn't take the nocb lock while working on the
1068− * rdp->cblist in SEGCBLIST_SOFTIRQ_ONLY mode.
1111+ * rdp->cblist with SEGCBLIST_LOCKING cleared (pure softirq/rcuc mode).
10691112 * Every modifications that have been done previously on
10701113 * rdp->cblist must be visible remotely by the nocb kthreads
10711114 * upon wake up after reading the cblist flags.
@@ -1084,6 +1127,14 @@ static long rcu_nocb_rdp_offload(void *arg) · 12 unmodified lines
10841127 rcu_segcblist_test_flags(cblist, SEGCBLIST_KTHREAD_CB) &&
10851128 rcu_segcblist_test_flags(cblist, SEGCBLIST_KTHREAD_GP));
10861129
1130+ /*
1131+ * All kthreads are ready to work, we can finally relieve rcu_core() and
1132+ * enable nocb bypass.
1133+ */
1134+ rcu_nocb_lock_irqsave(rdp, flags);
1135+ rcu_segcblist_clear_flags(cblist, SEGCBLIST_RCU_CORE);
1136+ rcu_nocb_unlock_irqrestore(rdp, flags);
1137+
10871138 return ret;
10881139 }
10891140
@@ -1122,13 +1173,17 @@ void __init rcu_init_nohz(void) · 32 unmodified lines
11221173 need_rcu_nocb_mask = true;
11231174 #endif /* #if defined(CONFIG_NO_HZ_FULL) */
11241175
1125− if (!cpumask_available(rcu_nocb_mask) && need_rcu_nocb_mask) {
1126− if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) {
1127− pr_info("rcu_nocb_mask allocation failed, callback offloading disabled.\n");
1128− return;
1176+ if (need_rcu_nocb_mask) {
1177+ if (!cpumask_available(rcu_nocb_mask)) {
1178+ if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) {
1179+ pr_info("rcu_nocb_mask allocation failed, callback offloading disabled.\n");
1180+ return;
1181+ }
11291182 }
1183+ rcu_nocb_is_setup = true;
11301184 }
1131− if (!cpumask_available(rcu_nocb_mask))
1185+
1186+ if (!rcu_nocb_is_setup)
11321187 return;
11331188
11341189 #if defined(CONFIG_NO_HZ_FULL)
@@ -1154,8 +1209,8 @@ void __init rcu_init_nohz(void) · 19 unmodified lines
11541209 if (rcu_segcblist_empty(&rdp->cblist))
11551210 rcu_segcblist_init(&rdp->cblist);
11561211 rcu_segcblist_offload(&rdp->cblist, true);
1157− rcu_segcblist_set_flags(&rdp->cblist, SEGCBLIST_KTHREAD_CB);
1158− rcu_segcblist_set_flags(&rdp->cblist, SEGCBLIST_KTHREAD_GP);
1212+ rcu_segcblist_set_flags(&rdp->cblist, SEGCBLIST_KTHREAD_CB | SEGCBLIST_KTHREAD_GP);
1213+ rcu_segcblist_clear_flags(&rdp->cblist, SEGCBLIST_RCU_CORE);
11591214 }
11601215 rcu_organize_nocb_kthreads();
11611216 }
@@ -1178,17 +1233,17 @@ static void __init rcu_boot_init_nocb_percpu_data(struct rcu_data *rdp) · 16 unmodified lines
11781233 * rcuo CB kthread, spawn it. Additionally, if the rcuo GP kthread
11791234 * for this CPU's group has not yet been created, spawn it as well.
11801235 */
1181−static void rcu_spawn_one_nocb_kthread(int cpu)
1236+static void rcu_spawn_cpu_nocb_kthread(int cpu)
11821237 {
11831238 struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
11841239 struct rcu_data *rdp_gp;
11851240 struct task_struct *t;
11861241
1187− /*
1188− * If this isn't a no-CBs CPU or if it already has an rcuo kthread,
1189− * then nothing to do.
1190− */
1191− if (!rcu_is_nocb_cpu(cpu) || rdp->nocb_cb_kthread)
1242+ if (!rcu_scheduler_fully_active || !rcu_nocb_is_setup)
1243+ return;
1244+
1245+ /* If there already is an rcuo kthread, then nothing to do. */
1246+ if (rdp->nocb_cb_kthread)
11921247 return;
11931248
11941249 /* If we didn't spawn the GP kthread first, reorganize! */
@@ -1210,16 +1265,6 @@ static void rcu_spawn_one_nocb_kthread(int cpu) · 15 unmodified lines
12101265 WRITE_ONCE(rdp->nocb_gp_kthread, rdp_gp->nocb_gp_kthread);
12111266 }
12121267
1213−/*
1214− * If the specified CPU is a no-CBs CPU that does not already have its
1215− * rcuo kthread, spawn it.
1216− */
1217−static void rcu_spawn_cpu_nocb_kthread(int cpu)
1218−{
1219− if (rcu_scheduler_fully_active)
1220− rcu_spawn_one_nocb_kthread(cpu);
1221−}
1222−
12231268 /*
12241269 * Once the scheduler is running, spawn rcuo kthreads for all online
12251270 * no-CBs CPUs. This assumes that the early_initcall()s happen before
@@ -1230,8 +1275,10 @@ static void __init rcu_spawn_nocb_kthreads(void) · 4 unmodified lines
12301275 {
12311276 int cpu;
12321277
1233− for_each_online_cpu(cpu)
1234− rcu_spawn_cpu_nocb_kthread(cpu);
1278+ if (rcu_nocb_is_setup) {
1279+ for_each_online_cpu(cpu)
1280+ rcu_spawn_cpu_nocb_kthread(cpu);
1281+ }
12351282 }
12361283
12371284 /* How many CB CPU IDs per GP kthread? Default of -1 for sqrt(nr_cpu_ids). */
@@ -1251,7 +1298,6 @@ static void __init rcu_organize_nocb_kthreads(void) · 13 unmodified lines
12511298 int nl = 0; /* Next GP kthread. */
12521299 struct rcu_data *rdp;
12531300 struct rcu_data *rdp_gp = NULL; /* Suppress misguided gcc warn. */
1254− struct rcu_data *rdp_prev = NULL;
12551301
12561302 if (!cpumask_available(rcu_nocb_mask))
12571303 return;
@@ -1265,14 +1311,14 @@ static void __init rcu_organize_nocb_kthreads(void) · 7 unmodified lines
12651311 * Should the corresponding CPU come online in the future, then
12661312 * we will spawn the needed set of rcu_nocb_kthread() kthreads.
12671313 */
1268− for_each_cpu(cpu, rcu_nocb_mask) {
1314+ for_each_possible_cpu(cpu) {
12691315 rdp = per_cpu_ptr(&rcu_data, cpu);
12701316 if (rdp->cpu >= nl) {
12711317 /* New GP kthread, set up for CBs & next GP. */
12721318 gotnocbs = true;
12731319 nl = DIV_ROUND_UP(rdp->cpu + 1, ls) * ls;
1274− rdp->nocb_gp_rdp = rdp;
12751320 rdp_gp = rdp;
1321+ INIT_LIST_HEAD(&rdp->nocb_head_rdp);
12761322 if (dump_tree) {
12771323 if (!firsttime)
12781324 pr_cont("%s\n", gotnocbscbs
@@ -1285,12 +1331,12 @@ static void __init rcu_organize_nocb_kthreads(void) · 6 unmodified lines
12851331 } else {
12861332 /* Another CB kthread, link to previous GP kthread. */
12871333 gotnocbscbs = true;
1288− rdp->nocb_gp_rdp = rdp_gp;
1289− rdp_prev->nocb_next_cb_rdp = rdp;
12901334 if (dump_tree)
12911335 pr_cont(" %d", cpu);
12921336 }
1293− rdp_prev = rdp;
1337+ rdp->nocb_gp_rdp = rdp_gp;
1338+ if (cpumask_test_cpu(cpu, rcu_nocb_mask))
1339+ list_add_tail(&rdp->nocb_entry_rdp, &rdp_gp->nocb_head_rdp);
12941340 }
12951341 if (gotnocbs && dump_tree)
12961342 pr_cont("%s\n", gotnocbscbs ? "" : " (self only)");
@@ -1352,6 +1398,7 @@ static void show_rcu_nocb_state(struct rcu_data *rdp) · 55 unmodified lines
13521398 {
13531399 char bufw[20];
13541400 char bufr[20];
1401+ struct rcu_data *nocb_next_rdp;
13551402 struct rcu_segcblist *rsclp = &rdp->cblist;
13561403 bool waslocked;
13571404 bool wassleep;
@@ -1359,11 +1406,16 @@ static void show_rcu_nocb_state(struct rcu_data *rdp) · 1 unmodified line
13591406 if (rdp->nocb_gp_rdp == rdp)
13601407 show_rcu_nocb_gp_state(rdp);
13611408
1409+ nocb_next_rdp = list_next_or_null_rcu(&rdp->nocb_gp_rdp->nocb_head_rdp,
1410+ &rdp->nocb_entry_rdp,
1411+ typeof(*rdp),
1412+ nocb_entry_rdp);
1413+
13621414 sprintf(bufw, "%ld", rsclp->gp_seq[RCU_WAIT_TAIL]);
13631415 sprintf(bufr, "%ld", rsclp->gp_seq[RCU_NEXT_READY_TAIL]);
13641416 pr_info(" CB %d^%d->%d %c%c%c%c%c%c F%ld L%ld C%d %c%c%s%c%s%c%c q%ld %c CPU %d%s\n",
13651417 rdp->cpu, rdp->nocb_gp_rdp->cpu,
1366− rdp->nocb_next_cb_rdp ? rdp->nocb_next_cb_rdp->cpu : -1,
1418+ nocb_next_rdp ? nocb_next_rdp->cpu : -1,
13671419 "kK"[!!rdp->nocb_cb_kthread],
13681420 "bB"[raw_spin_is_locked(&rdp->nocb_bypass_lock)],
13691421 "cC"[!!atomic_read(&rdp->nocb_lock_contended)],
kernel/rcu/tree_plugin.h+33−217
@@ -16,7 +16,7 @@ · 15 unmodified lines
1616 static bool rcu_rdp_is_offloaded(struct rcu_data *rdp)
1717 {
1818 /*
19− * In order to read the offloaded state of an rdp is a safe
19+ * In order to read the offloaded state of an rdp in a safe
2020 * and stable way and prevent from its value to be changed
2121 * under us, we must either hold the barrier mutex, the cpu
2222 * hotplug lock (read or write) or the nocb lock. Local
@@ -51,12 +51,10 @@ static void __init rcu_bootup_announce_oddness(void) · 28 unmodified lines
5151 RCU_FANOUT);
5252 if (rcu_fanout_exact)
5353 pr_info("\tHierarchical RCU autobalancing is disabled.\n");
54− if (IS_ENABLED(CONFIG_RCU_FAST_NO_HZ))
55− pr_info("\tRCU dyntick-idle grace-period acceleration is enabled.\n");
5654 if (IS_ENABLED(CONFIG_PROVE_RCU))
5755 pr_info("\tRCU lockdep checking is enabled.\n");
5856 if (IS_ENABLED(CONFIG_RCU_STRICT_GRACE_PERIOD))
59− pr_info("\tRCU strict (and thus non-scalable) grace periods enabled.\n");
57+ pr_info("\tRCU strict (and thus non-scalable) grace periods are enabled.\n");
6058 if (RCU_NUM_LVLS >= 4)
6159 pr_info("\tFour(or more)-level hierarchy is enabled.\n");
6260 if (RCU_FANOUT_LEAF != 16)
@@ -88,13 +86,13 @@ static void __init rcu_bootup_announce_oddness(void) · 25 unmodified lines
8886 if (rcu_kick_kthreads)
8987 pr_info("\tKick kthreads if too-long grace period.\n");
9088 if (IS_ENABLED(CONFIG_DEBUG_OBJECTS_RCU_HEAD))
91− pr_info("\tRCU callback double-/use-after-free debug enabled.\n");
89+ pr_info("\tRCU callback double-/use-after-free debug is enabled.\n");
9290 if (gp_preinit_delay)
9391 pr_info("\tRCU debug GP pre-init slowdown %d jiffies.\n", gp_preinit_delay);
9492 if (gp_init_delay)
9593 pr_info("\tRCU debug GP init slowdown %d jiffies.\n", gp_init_delay);
9694 if (gp_cleanup_delay)
97− pr_info("\tRCU debug GP init slowdown %d jiffies.\n", gp_cleanup_delay);
95+ pr_info("\tRCU debug GP cleanup slowdown %d jiffies.\n", gp_cleanup_delay);
9896 if (!use_softirq)
9997 pr_info("\tRCU_SOFTIRQ processing moved to rcuc kthreads.\n");
10098 if (IS_ENABLED(CONFIG_RCU_EQS_DEBUG))
@@ -260,10 +258,10 @@ static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp) · 159 unmodified lines
260258 * no need to check for a subsequent expedited GP. (Though we are
261259 * still in a quiescent state in any case.)
262260 */
263− if (blkd_state & RCU_EXP_BLKD && rdp->exp_deferred_qs)
261+ if (blkd_state & RCU_EXP_BLKD && rdp->cpu_no_qs.b.exp)
264262 rcu_report_exp_rdp(rdp);
265263 else
266− WARN_ON_ONCE(rdp->exp_deferred_qs);
264+ WARN_ON_ONCE(rdp->cpu_no_qs.b.exp);
267265 }
268266
269267 /*
@@ -277,12 +275,16 @@ static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp) · 7 unmodified lines
277275 * current task, there might be any number of other tasks blocked while
278276 * in an RCU read-side critical section.
279277 *
278+ * Unlike non-preemptible-RCU, quiescent state reports for expedited
279+ * grace periods are handled separately via deferred quiescent states
280+ * and context switch events.
281+ *
280282 * Callers to this function must disable preemption.
281283 */
282284 static void rcu_qs(void)
283285 {
284286 RCU_LOCKDEP_WARN(preemptible(), "rcu_qs() invoked with preemption enabled!!!\n");
285− if (__this_cpu_read(rcu_data.cpu_no_qs.s)) {
287+ if (__this_cpu_read(rcu_data.cpu_no_qs.b.norm)) {
286288 trace_rcu_grace_period(TPS("rcu_preempt"),
287289 __this_cpu_read(rcu_data.gp_seq),
288290 TPS("cpuqs"));
@@ -350,7 +352,7 @@ void rcu_note_context_switch(bool preempt) · 61 unmodified lines
350352 * means that we continue to block the current grace period.
351353 */
352354 rcu_qs();
353− if (rdp->exp_deferred_qs)
355+ if (rdp->cpu_no_qs.b.exp)
354356 rcu_report_exp_rdp(rdp);
355357 rcu_tasks_qs(current, preempt);
356358 trace_rcu_utilization(TPS("End context switch"));
@@ -477,7 +479,7 @@ rcu_preempt_deferred_qs_irqrestore(struct task_struct *t, unsigned long flags) · 120 unmodified lines
477479 */
478480 special = t->rcu_read_unlock_special;
479481 rdp = this_cpu_ptr(&rcu_data);
480− if (!special.s && !rdp->exp_deferred_qs) {
482+ if (!special.s && !rdp->cpu_no_qs.b.exp) {
481483 local_irq_restore(flags);
482484 return;
483485 }
@@ -497,7 +499,7 @@ rcu_preempt_deferred_qs_irqrestore(struct task_struct *t, unsigned long flags) · 13 unmodified lines
497499 * tasks are handled when removing the task from the
498500 * blocked-tasks list below.
499501 */
500− if (rdp->exp_deferred_qs)
502+ if (rdp->cpu_no_qs.b.exp)
501503 rcu_report_exp_rdp(rdp);
502504
503505 /* Clean up if blocked during RCU read-side critical section. */
@@ -580,7 +582,7 @@ rcu_preempt_deferred_qs_irqrestore(struct task_struct *t, unsigned long flags) · 76 unmodified lines
580582 */
581583 static bool rcu_preempt_need_deferred_qs(struct task_struct *t)
582584 {
583− return (__this_cpu_read(rcu_data.exp_deferred_qs) ||
585+ return (__this_cpu_read(rcu_data.cpu_no_qs.b.exp) ||
584586 READ_ONCE(t->rcu_read_unlock_special.s)) &&
585587 rcu_preempt_depth() == 0;
586588 }
@@ -642,7 +644,7 @@ static void rcu_read_unlock_special(struct task_struct *t) · 55 unmodified lines
642644 (IS_ENABLED(CONFIG_RCU_BOOST) && irqs_were_disabled &&
643645 t->rcu_blocked_node);
644646 // Need to defer quiescent state until everything is enabled.
645− if (use_softirq && (in_irq() || (expboost && !irqs_were_disabled))) {
647+ if (use_softirq && (in_hardirq() || (expboost && !irqs_were_disabled))) {
646648 // Using softirq, safe to awaken, and either the
647649 // wakeup is free or there is either an expedited
648650 // GP in flight or a potential need to deboost.
@@ -845,10 +847,8 @@ static void rcu_qs(void) · 196 unmodified lines
845847 trace_rcu_grace_period(TPS("rcu_sched"),
846848 __this_cpu_read(rcu_data.gp_seq), TPS("cpuqs"));
847849 __this_cpu_write(rcu_data.cpu_no_qs.b.norm, false);
848− if (!__this_cpu_read(rcu_data.cpu_no_qs.b.exp))
849− return;
850− __this_cpu_write(rcu_data.cpu_no_qs.b.exp, false);
851− rcu_report_exp_rdp(this_cpu_ptr(&rcu_data));
850+ if (__this_cpu_read(rcu_data.cpu_no_qs.b.exp))
851+ rcu_report_exp_rdp(this_cpu_ptr(&rcu_data));
852852 }
853853
854854 /*
@@ -925,7 +925,18 @@ static bool rcu_preempt_need_deferred_qs(struct task_struct *t) · 70 unmodified lines
925925 {
926926 return false;
927927 }
928−static void rcu_preempt_deferred_qs(struct task_struct *t) { }
928+
929+// Except that we do need to respond to a request by an expedited grace
930+// period for a quiescent state from this CPU. Note that requests from
931+// tasks are handled when removing the task from the blocked-tasks list
932+// below.
933+static void rcu_preempt_deferred_qs(struct task_struct *t)
934+{
935+ struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
936+
937+ if (rdp->cpu_no_qs.b.exp)
938+ rcu_report_exp_rdp(rdp);
939+}
929940
930941 /*
931942 * Because there is no preemptible RCU, there can be no readers blocked,
@@ -1153,7 +1164,6 @@ static void rcu_preempt_boost_start_gp(struct rcu_node *rnp) · 221 unmodified lines
11531164 /*
11541165 * Create an RCU-boost kthread for the specified node if one does not
11551166 * already exist. We only create this kthread for preemptible RCU.
1156− * Returns zero if all is well, a negated errno otherwise.
11571167 */
11581168 static void rcu_spawn_one_boost_kthread(struct rcu_node *rnp)
11591169 {
@@ -1204,8 +1214,9 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) · 44 unmodified lines
12041214 if ((mask & leaf_node_cpu_bit(rnp, cpu)) &&
12051215 cpu != outgoingcpu)
12061216 cpumask_set_cpu(cpu, cm);
1217+ cpumask_and(cm, cm, housekeeping_cpumask(HK_FLAG_RCU));
12071218 if (cpumask_weight(cm) == 0)
1208− cpumask_setall(cm);
1219+ cpumask_copy(cm, housekeeping_cpumask(HK_FLAG_RCU));
12091220 set_cpus_allowed_ptr(t, cm);
12101221 free_cpumask_var(cm);
12111222 }
@@ -1253,201 +1264,6 @@ static void __init rcu_spawn_boost_kthreads(void) · 41 unmodified lines
12531264
12541265 #endif /* #else #ifdef CONFIG_RCU_BOOST */
12551266
1256−#if !defined(CONFIG_RCU_FAST_NO_HZ)
1257−
1258−/*
1259− * Check to see if any future non-offloaded RCU-related work will need
1260− * to be done by the current CPU, even if none need be done immediately,
1261− * returning 1 if so. This function is part of the RCU implementation;
1262− * it is -not- an exported member of the RCU API.
1263− *
1264− * Because we not have RCU_FAST_NO_HZ, just check whether or not this
1265− * CPU has RCU callbacks queued.
1266− */
1267−int rcu_needs_cpu(u64 basemono, u64 *nextevt)
1268−{
1269− *nextevt = KTIME_MAX;
1270− return !rcu_segcblist_empty(&this_cpu_ptr(&rcu_data)->cblist) &&
1271− !rcu_rdp_is_offloaded(this_cpu_ptr(&rcu_data));
1272−}
1273−
1274−/*
1275− * Because we do not have RCU_FAST_NO_HZ, don't bother cleaning up
1276− * after it.
1277− */
1278−static void rcu_cleanup_after_idle(void)
1279−{
1280−}
1281−
1282−/*
1283− * Do the idle-entry grace-period work, which, because CONFIG_RCU_FAST_NO_HZ=n,
1284− * is nothing.
1285− */
1286−static void rcu_prepare_for_idle(void)
1287−{
1288−}
1289−
1290−#else /* #if !defined(CONFIG_RCU_FAST_NO_HZ) */
1291−
1292−/*
1293− * This code is invoked when a CPU goes idle, at which point we want
1294− * to have the CPU do everything required for RCU so that it can enter
1295− * the energy-efficient dyntick-idle mode.
1296− *
1297− * The following preprocessor symbol controls this:
1298− *
1299− * RCU_IDLE_GP_DELAY gives the number of jiffies that a CPU is permitted
1300− * to sleep in dyntick-idle mode with RCU callbacks pending. This
1301− * is sized to be roughly one RCU grace period. Those energy-efficiency
1302− * benchmarkers who might otherwise be tempted to set this to a large
1303− * number, be warned: Setting RCU_IDLE_GP_DELAY too high can hang your
1304− * system. And if you are -that- concerned about energy efficiency,
1305− * just power the system down and be done with it!
1306− *
1307− * The value below works well in practice. If future workloads require
1308− * adjustment, they can be converted into kernel config parameters, though
1309− * making the state machine smarter might be a better option.
1310− */
1311−#define RCU_IDLE_GP_DELAY 4 /* Roughly one grace period. */
1312−
1313−static int rcu_idle_gp_delay = RCU_IDLE_GP_DELAY;
1314−module_param(rcu_idle_gp_delay, int, 0644);
1315−
1316−/*
1317− * Try to advance callbacks on the current CPU, but only if it has been
1318− * awhile since the last time we did so. Afterwards, if there are any
1319− * callbacks ready for immediate invocation, return true.
1320− */
1321−static bool __maybe_unused rcu_try_advance_all_cbs(void)
1322−{
1323− bool cbs_ready = false;
1324− struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
1325− struct rcu_node *rnp;
1326−
1327− /* Exit early if we advanced recently. */
1328− if (jiffies == rdp->last_advance_all)
1329− return false;
1330− rdp->last_advance_all = jiffies;
1331−
1332− rnp = rdp->mynode;
1333−
1334− /*
1335− * Don't bother checking unless a grace period has
1336− * completed since we last checked and there are
1337− * callbacks not yet ready to invoke.
1338− */
1339− if ((rcu_seq_completed_gp(rdp->gp_seq,
1340− rcu_seq_current(&rnp->gp_seq)) ||
1341− unlikely(READ_ONCE(rdp->gpwrap))) &&
1342− rcu_segcblist_pend_cbs(&rdp->cblist))
1343− note_gp_changes(rdp);
1344−
1345− if (rcu_segcblist_ready_cbs(&rdp->cblist))
1346− cbs_ready = true;
1347− return cbs_ready;
1348−}
1349−
1350−/*
1351− * Allow the CPU to enter dyntick-idle mode unless it has callbacks ready
1352− * to invoke. If the CPU has callbacks, try to advance them. Tell the
1353− * caller about what to set the timeout.
1354− *
1355− * The caller must have disabled interrupts.
1356− */
1357−int rcu_needs_cpu(u64 basemono, u64 *nextevt)
1358−{
1359− struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
1360− unsigned long dj;
1361−
1362− lockdep_assert_irqs_disabled();
1363−
1364− /* If no non-offloaded callbacks, RCU doesn't need the CPU. */
1365− if (rcu_segcblist_empty(&rdp->cblist) ||
1366− rcu_rdp_is_offloaded(rdp)) {
1367− *nextevt = KTIME_MAX;
1368− return 0;
1369− }
1370−
1371− /* Attempt to advance callbacks. */
1372− if (rcu_try_advance_all_cbs()) {
1373− /* Some ready to invoke, so initiate later invocation. */
1374− invoke_rcu_core();
1375− return 1;
1376− }
1377− rdp->last_accelerate = jiffies;
1378−
1379− /* Request timer and round. */
1380− dj = round_up(rcu_idle_gp_delay + jiffies, rcu_idle_gp_delay) - jiffies;
1381−
1382− *nextevt = basemono + dj * TICK_NSEC;
1383− return 0;
1384−}
1385−
1386−/*
1387− * Prepare a CPU for idle from an RCU perspective. The first major task is to
1388− * sense whether nohz mode has been enabled or disabled via sysfs. The second
1389− * major task is to accelerate (that is, assign grace-period numbers to) any
1390− * recently arrived callbacks.
1391− *
1392− * The caller must have disabled interrupts.
1393− */
1394−static void rcu_prepare_for_idle(void)
1395−{
1396− bool needwake;
1397− struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
1398− struct rcu_node *rnp;
1399− int tne;
1400−
1401− lockdep_assert_irqs_disabled();
1402− if (rcu_rdp_is_offloaded(rdp))
1403− return;
1404−
1405− /* Handle nohz enablement switches conservatively. */
1406− tne = READ_ONCE(tick_nohz_active);
1407− if (tne != rdp->tick_nohz_enabled_snap) {
1408− if (!rcu_segcblist_empty(&rdp->cblist))
1409− invoke_rcu_core(); /* force nohz to see update. */
1410− rdp->tick_nohz_enabled_snap = tne;
1411− return;
1412− }
1413− if (!tne)
1414− return;
1415−
1416− /*
1417− * If we have not yet accelerated this jiffy, accelerate all
1418− * callbacks on this CPU.
1419− */
1420− if (rdp->last_accelerate == jiffies)
1421− return;
1422− rdp->last_accelerate = jiffies;
1423− if (rcu_segcblist_pend_cbs(&rdp->cblist)) {
1424− rnp = rdp->mynode;
1425− raw_spin_lock_rcu_node(rnp); /* irqs already disabled. */
1426− needwake = rcu_accelerate_cbs(rnp, rdp);
1427− raw_spin_unlock_rcu_node(rnp); /* irqs remain disabled. */
1428− if (needwake)
1429− rcu_gp_kthread_wake();
1430− }
1431−}
1432−
1433−/*
1434− * Clean up for exit from idle. Attempt to advance callbacks based on
1435− * any grace periods that elapsed while the CPU was idle, and if any
1436− * callbacks are now ready to invoke, initiate invocation.
1437− */
1438−static void rcu_cleanup_after_idle(void)
1439−{
1440− struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
1441−
1442− lockdep_assert_irqs_disabled();
1443− if (rcu_rdp_is_offloaded(rdp))
1444− return;
1445− if (rcu_try_advance_all_cbs())
1446− invoke_rcu_core();
1447−}
1448−
1449−#endif /* #else #if !defined(CONFIG_RCU_FAST_NO_HZ) */
1450−
14511267 /*
14521268 * Is this CPU a NO_HZ_FULL CPU that should ignore RCU so that the
14531269 * grace-period kthread will do force_quiescent_state() processing?
@@ -1455,7 +1271,7 @@ static void rcu_cleanup_after_idle(void) · 1 unmodified line
14551271 * CPU unless the grace period has extended for too long.
14561272 *
14571273 * This code relies on the fact that all NO_HZ_FULL CPUs are also
1458− * CONFIG_RCU_NOCB_CPU CPUs.
1274+ * RCU_NOCB_CPU CPUs.
14591275 */
14601276 static bool rcu_nohz_full_cpu(void)
14611277 {
kernel/rcu/tree_stall.h+2−25
@@ -347,26 +347,6 @@ static void rcu_dump_cpu_stacks(void) · 346 unmodified lines
347347 }
348348 }
349349
350−#ifdef CONFIG_RCU_FAST_NO_HZ
351−
352−static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
353−{
354− struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
355−
356− sprintf(cp, "last_accelerate: %04lx/%04lx dyntick_enabled: %d",
357− rdp->last_accelerate & 0xffff, jiffies & 0xffff,
358− !!rdp->tick_nohz_enabled_snap);
359−}
360−
361−#else /* #ifdef CONFIG_RCU_FAST_NO_HZ */
362−
363−static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
364−{
365− *cp = '\0';
366−}
367−
368−#endif /* #else #ifdef CONFIG_RCU_FAST_NO_HZ */
369−
370350 static const char * const gp_state_names[] = {
371351 [RCU_GP_IDLE] = "RCU_GP_IDLE",
372352 [RCU_GP_WAIT_GPS] = "RCU_GP_WAIT_GPS",
@@ -408,13 +388,12 @@ static bool rcu_is_gp_kthread_starving(unsigned long *jp) · 35 unmodified lines
408388 * of RCU grace periods that this CPU is ignorant of, for example, "1"
409389 * if the CPU was aware of the previous grace period.
410390 *
411− * Also print out idle and (if CONFIG_RCU_FAST_NO_HZ) idle-entry info.
391+ * Also print out idle info.
412392 */
413393 static void print_cpu_stall_info(int cpu)
414394 {
415395 unsigned long delta;
416396 bool falsepositive;
417− char fast_no_hz[72];
418397 struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
419398 char *ticks_title;
420399 unsigned long ticks_value;
@@ -432,11 +411,10 @@ static void print_cpu_stall_info(int cpu) · 11 unmodified lines
432411 ticks_title = "ticks this GP";
433412 ticks_value = rdp->ticks_this_gp;
434413 }
435− print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
436414 delta = rcu_seq_ctr(rdp->mynode->gp_seq - rdp->rcu_iw_gp_seq);
437415 falsepositive = rcu_is_gp_kthread_starving(NULL) &&
438416 rcu_dynticks_in_eqs(rcu_dynticks_snap(rdp));
439− pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%03x/%ld/%#lx softirq=%u/%u fqs=%ld %s%s\n",
417+ pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%03x/%ld/%#lx softirq=%u/%u fqs=%ld %s\n",
440418 cpu,
441419 "O."[!!cpu_online(cpu)],
442420 "o."[!!(rdp->grpmask & rdp->mynode->qsmaskinit)],
@@ -449,7 +427,6 @@ static void print_cpu_stall_info(int cpu) · 6 unmodified lines
449427 rdp->dynticks_nesting, rdp->dynticks_nmi_nesting,
450428 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
451429 data_race(rcu_state.n_force_qs) - rcu_state.n_force_qs_gpstart,
452− fast_no_hz,
453430 falsepositive ? " (false positive?)" : "");
454431 }
455432
kernel/scftorture.c+6−10
@@ -38,14 +38,10 @@ · 37 unmodified lines
3838 #define SCFTORT_STRING "scftorture"
3939 #define SCFTORT_FLAG SCFTORT_STRING ": "
4040
41−#define SCFTORTOUT(s, x...) \
42− pr_alert(SCFTORT_FLAG s, ## x)
43−
4441 #define VERBOSE_SCFTORTOUT(s, x...) \
45− do { if (verbose) pr_alert(SCFTORT_FLAG s, ## x); } while (0)
42+ do { if (verbose) pr_alert(SCFTORT_FLAG s "\n", ## x); } while (0)
4643
47−#define VERBOSE_SCFTORTOUT_ERRSTRING(s, x...) \
48− do { if (verbose) pr_alert(SCFTORT_FLAG "!!! " s, ## x); } while (0)
44+#define SCFTORTOUT_ERRSTRING(s, x...) pr_alert(SCFTORT_FLAG "!!! " s "\n", ## x)
4945
5046 MODULE_LICENSE("GPL");
5147 MODULE_AUTHOR("Paul E. McKenney <paulmck@kernel.org>");
@@ -587,14 +583,14 @@ static int __init scf_torture_init(void) · 535 unmodified lines
587583 if (weight_resched1 == 0 && weight_single1 == 0 && weight_single_rpc1 == 0 &&
588584 weight_single_wait1 == 0 && weight_many1 == 0 && weight_many_wait1 == 0 &&
589585 weight_all1 == 0 && weight_all_wait1 == 0) {
590− VERBOSE_SCFTORTOUT_ERRSTRING("all zero weights makes no sense");
586+ SCFTORTOUT_ERRSTRING("all zero weights makes no sense");
591587 firsterr = -EINVAL;
592588 goto unwind;
593589 }
594590 if (IS_BUILTIN(CONFIG_SCF_TORTURE_TEST))
595591 scf_sel_add(weight_resched1, SCF_PRIM_RESCHED, false);
596592 else if (weight_resched1)
597− VERBOSE_SCFTORTOUT_ERRSTRING("built as module, weight_resched ignored");
593+ SCFTORTOUT_ERRSTRING("built as module, weight_resched ignored");
598594 scf_sel_add(weight_single1, SCF_PRIM_SINGLE, false);
599595 scf_sel_add(weight_single_rpc1, SCF_PRIM_SINGLE_RPC, true);
600596 scf_sel_add(weight_single_wait1, SCF_PRIM_SINGLE, true);
@@ -625,12 +621,12 @@ static int __init scf_torture_init(void) · 24 unmodified lines
625621 nthreads = num_online_cpus();
626622 scf_stats_p = kcalloc(nthreads, sizeof(scf_stats_p[0]), GFP_KERNEL);
627623 if (!scf_stats_p) {
628− VERBOSE_SCFTORTOUT_ERRSTRING("out of memory");
624+ SCFTORTOUT_ERRSTRING("out of memory");
629625 firsterr = -ENOMEM;
630626 goto unwind;
631627 }
632628
633− VERBOSE_SCFTORTOUT("Starting %d smp_call_function() threads\n", nthreads);
629+ VERBOSE_SCFTORTOUT("Starting %d smp_call_function() threads", nthreads);
634630
635631 atomic_set(&n_started, nthreads);
636632 for (i = 0; i < nthreads; i++) {
kernel/torture.c+2−2
@@ -570,7 +570,7 @@ int torture_shuffle_init(long shuffint) · 569 unmodified lines
570570 shuffle_idle_cpu = -1;
571571
572572 if (!alloc_cpumask_var(&shuffle_tmp_mask, GFP_KERNEL)) {
573− VERBOSE_TOROUT_ERRSTRING("Failed to alloc mask");
573+ TOROUT_ERRSTRING("Failed to alloc mask");
574574 return -ENOMEM;
575575 }
576576
@@ -934,7 +934,7 @@ int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m, · 357 unmodified lines
934934 *tp = kthread_run(fn, arg, "%s", s);
935935 if (IS_ERR(*tp)) {
936936 ret = PTR_ERR(*tp);
937− VERBOSE_TOROUT_ERRSTRING(f);
937+ TOROUT_ERRSTRING(f);
938938 *tp = NULL;
939939 }
940940 torture_shuffle_task_register(*tp);
tools/include/nolibc/nolibc.h+60−26
@@ -265,12 +265,17 @@ struct stat { · 264 unmodified lines
265265 * - arguments are in rdi, rsi, rdx, r10, r8, r9 respectively
266266 * - the system call is performed by calling the syscall instruction
267267 * - syscall return comes in rax
268− * - rcx and r8..r11 may be clobbered, others are preserved.
268+ * - rcx and r11 are clobbered, others are preserved.
269269 * - the arguments are cast to long and assigned into the target registers
270270 * which are then simply passed as registers to the asm code, so that we
271271 * don't have to experience issues with register constraints.
272272 * - the syscall number is always specified last in order to allow to force
273273 * some registers before (gcc refuses a %-register at the last position).
274+ * - see also x86-64 ABI section A.2 AMD64 Linux Kernel Conventions, A.2.1
275+ * Calling Conventions.
276+ *
277+ * Link x86-64 ABI: https://gitlab.com/x86-psABIs/x86-64-ABI/-/wikis/x86-64-psABI
278+ *
274279 */
275280
276281 #define my_syscall0(num) \
@@ -280,9 +285,9 @@ struct stat { · 3 unmodified lines
280285 \
281286 asm volatile ( \
282287 "syscall\n" \
283− : "=a" (_ret) \
288+ : "=a"(_ret) \
284289 : "0"(_num) \
285− : "rcx", "r8", "r9", "r10", "r11", "memory", "cc" \
290+ : "rcx", "r11", "memory", "cc" \
286291 ); \
287292 _ret; \
288293 })
@@ -295,10 +300,10 @@ struct stat { · 6 unmodified lines
295300 \
296301 asm volatile ( \
297302 "syscall\n" \
298− : "=a" (_ret) \
303+ : "=a"(_ret) \
299304 : "r"(_arg1), \
300305 "0"(_num) \
301− : "rcx", "r8", "r9", "r10", "r11", "memory", "cc" \
306+ : "rcx", "r11", "memory", "cc" \
302307 ); \
303308 _ret; \
304309 })
@@ -312,10 +317,10 @@ struct stat { · 7 unmodified lines
312317 \
313318 asm volatile ( \
314319 "syscall\n" \
315− : "=a" (_ret) \
320+ : "=a"(_ret) \
316321 : "r"(_arg1), "r"(_arg2), \
317322 "0"(_num) \
318− : "rcx", "r8", "r9", "r10", "r11", "memory", "cc" \
323+ : "rcx", "r11", "memory", "cc" \
319324 ); \
320325 _ret; \
321326 })
@@ -330,10 +335,10 @@ struct stat { · 8 unmodified lines
330335 \
331336 asm volatile ( \
332337 "syscall\n" \
333− : "=a" (_ret) \
338+ : "=a"(_ret) \
334339 : "r"(_arg1), "r"(_arg2), "r"(_arg3), \
335340 "0"(_num) \
336− : "rcx", "r8", "r9", "r10", "r11", "memory", "cc" \
341+ : "rcx", "r11", "memory", "cc" \
337342 ); \
338343 _ret; \
339344 })
@@ -349,10 +354,10 @@ struct stat { · 9 unmodified lines
349354 \
350355 asm volatile ( \
351356 "syscall\n" \
352− : "=a" (_ret), "=r"(_arg4) \
357+ : "=a"(_ret) \
353358 : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), \
354359 "0"(_num) \
355− : "rcx", "r8", "r9", "r11", "memory", "cc" \
360+ : "rcx", "r11", "memory", "cc" \
356361 ); \
357362 _ret; \
358363 })
@@ -369,10 +374,10 @@ struct stat { · 10 unmodified lines
369374 \
370375 asm volatile ( \
371376 "syscall\n" \
372− : "=a" (_ret), "=r"(_arg4), "=r"(_arg5) \
377+ : "=a"(_ret) \
373378 : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), "r"(_arg5), \
374379 "0"(_num) \
375− : "rcx", "r9", "r11", "memory", "cc" \
380+ : "rcx", "r11", "memory", "cc" \
376381 ); \
377382 _ret; \
378383 })
@@ -390,7 +395,7 @@ struct stat { · 11 unmodified lines
390395 \
391396 asm volatile ( \
392397 "syscall\n" \
393− : "=a" (_ret), "=r"(_arg4), "=r"(_arg5) \
398+ : "=a"(_ret) \
394399 : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), "r"(_arg5), \
395400 "r"(_arg6), "0"(_num) \
396401 : "rcx", "r11", "memory", "cc" \
@@ -399,17 +404,23 @@ struct stat { · 2 unmodified lines
399404 })
400405
401406 /* startup code */
407+/*
408+ * x86-64 System V ABI mandates:
409+ * 1) %rsp must be 16-byte aligned right before the function call.
410+ * 2) The deepest stack frame should be zero (the %rbp).
411+ *
412+ */
402413 asm(".section .text\n"
403414 ".global _start\n"
404415 "_start:\n"
405416 "pop %rdi\n" // argc (first arg, %rdi)
406417 "mov %rsp, %rsi\n" // argv[] (second arg, %rsi)
407418 "lea 8(%rsi,%rdi,8),%rdx\n" // then a NULL then envp (third arg, %rdx)
408− "and $-16, %rsp\n" // x86 ABI : esp must be 16-byte aligned when
409− "sub $8, %rsp\n" // entering the callee
419+ "xor %ebp, %ebp\n" // zero the stack frame
420+ "and $-16, %rsp\n" // x86 ABI : esp must be 16-byte aligned before call
410421 "call main\n" // main() returns the status code, we'll exit with it.
411− "movzb %al, %rdi\n" // retrieve exit code from 8 lower bits
412− "mov $60, %rax\n" // NR_exit == 60
422+ "mov %eax, %edi\n" // retrieve exit code (32 bit)
423+ "mov $60, %eax\n" // NR_exit == 60
413424 "syscall\n" // really exit
414425 "hlt\n" // ensure it does not return
415426 "");
@@ -577,20 +588,28 @@ struct sys_stat_struct { · 161 unmodified lines
577588 })
578589
579590 /* startup code */
591+/*
592+ * i386 System V ABI mandates:
593+ * 1) last pushed argument must be 16-byte aligned.
594+ * 2) The deepest stack frame should be set to zero
595+ *
596+ */
580597 asm(".section .text\n"
581598 ".global _start\n"
582599 "_start:\n"
583600 "pop %eax\n" // argc (first arg, %eax)
584601 "mov %esp, %ebx\n" // argv[] (second arg, %ebx)
585602 "lea 4(%ebx,%eax,4),%ecx\n" // then a NULL then envp (third arg, %ecx)
586− "and $-16, %esp\n" // x86 ABI : esp must be 16-byte aligned when
603+ "xor %ebp, %ebp\n" // zero the stack frame
604+ "and $-16, %esp\n" // x86 ABI : esp must be 16-byte aligned before
605+ "sub $4, %esp\n" // the call instruction (args are aligned)
587606 "push %ecx\n" // push all registers on the stack so that we
588607 "push %ebx\n" // support both regparm and plain stack modes
589608 "push %eax\n"
590609 "call main\n" // main() returns the status code in %eax
591− "movzbl %al, %ebx\n" // retrieve exit code from lower 8 bits
592− "movl $1, %eax\n" // NR_exit == 1
593− "int $0x80\n" // exit now
610+ "mov %eax, %ebx\n" // retrieve exit code (32-bit int)
611+ "movl $1, %eax\n" // NR_exit == 1
612+ "int $0x80\n" // exit now
594613 "hlt\n" // ensure it does not
595614 "");
596615
@@ -774,7 +793,6 @@ asm(".section .text\n" · 177 unmodified lines
774793 "and %r3, %r1, $-8\n" // AAPCS : sp must be 8-byte aligned in the
775794 "mov %sp, %r3\n" // callee, an bl doesn't push (lr=pc)
776795 "bl main\n" // main() returns the status code, we'll exit with it.
777− "and %r0, %r0, $0xff\n" // limit exit code to 8 bits
778796 "movs r7, $1\n" // NR_exit == 1
779797 "svc $0x00\n"
780798 "");
@@ -971,7 +989,6 @@ asm(".section .text\n" · 190 unmodified lines
971989 "add x2, x2, x1\n" // + argv
972990 "and sp, x1, -16\n" // sp must be 16-byte aligned in the callee
973991 "bl main\n" // main() returns the status code, we'll exit with it.
974− "and x0, x0, 0xff\n" // limit exit code to 8 bits
975992 "mov x8, 93\n" // NR_exit == 93
976993 "svc #0\n"
977994 "");
@@ -1176,7 +1193,7 @@ asm(".section .text\n" · 198 unmodified lines
11761193 "addiu $sp,$sp,-16\n" // the callee expects to save a0..a3 there!
11771194 "jal main\n" // main() returns the status code, we'll exit with it.
11781195 "nop\n" // delayed slot
1179− "and $a0, $v0, 0xff\n" // limit exit code to 8 bits
1196+ "move $a0, $v0\n" // retrieve 32-bit exit code from v0
11801197 "li $v0, 4001\n" // NR_exit == 4001
11811198 "syscall\n"
11821199 ".end __start\n"
@@ -1374,7 +1391,6 @@ asm(".section .text\n" · 191 unmodified lines
13741391 "add a2,a2,a1\n" // + argv
13751392 "andi sp,a1,-16\n" // sp must be 16-byte aligned
13761393 "call main\n" // main() returns the status code, we'll exit with it.
1377− "andi a0, a0, 0xff\n" // limit exit code to 8 bits
13781394 "li a7, 93\n" // NR_exit == 93
13791395 "ecall\n"
13801396 "");
@@ -1555,6 +1571,12 @@ pid_t sys_getpid(void) · 174 unmodified lines
15551571 return my_syscall0(__NR_getpid);
15561572 }
15571573
1574+static __attribute__((unused))
1575+pid_t sys_gettid(void)
1576+{
1577+ return my_syscall0(__NR_gettid);
1578+}
1579+
15581580 static __attribute__((unused))
15591581 int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
15601582 {
@@ -2013,6 +2035,18 @@ pid_t getpid(void) · 452 unmodified lines
20132035 return ret;
20142036 }
20152037
2038+static __attribute__((unused))
2039+pid_t gettid(void)
2040+{
2041+ pid_t ret = sys_gettid();
2042+
2043+ if (ret < 0) {
2044+ SET_ERRNO(-ret);
2045+ ret = -1;
2046+ }
2047+ return ret;
2048+}
2049+
20162050 static __attribute__((unused))
20172051 int gettimeofday(struct timeval *tv, struct timezone *tz)
20182052 {
tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh+2−2
@@ -30,9 +30,9 @@ editor=${EDITOR-vi} · 29 unmodified lines
3030 files=
3131 for i in ${rundir}/*/Make.out
3232 do
33− if egrep -q "error:|warning:" < $i
33+ if egrep -q "error:|warning:|^ld: .*undefined reference to" < $i
3434 then
35− egrep "error:|warning:" < $i > $i.diags
35+ egrep "error:|warning:|^ld: .*undefined reference to" < $i > $i.diags
3636 files="$files $i.diags $i"
3737 fi
3838 done
tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh+1−1
@@ -25,7 +25,7 @@ stopstate="`grep 'End-test grace-period state: g' $i/console.log 2> /dev/null | · 24 unmodified lines
2525 tail -1 | sed -e 's/^\[[ 0-9.]*] //' |
2626 awk '{ print \"[\" $1 \" \" $5 \" \" $6 \" \" $7 \"]\"; }' |
2727 tr -d '\012\015'`"
28−fwdprog="`grep 'rcu_torture_fwd_prog_cr Duration' $i/console.log 2> /dev/null | sed -e 's/^\[[^]]*] //' | sort -k15nr | head -1 | awk '{ print $14 " " $15 }'`"
28+fwdprog="`grep 'rcu_torture_fwd_prog n_max_cbs: ' $i/console.log 2> /dev/null | sed -e 's/^\[[^]]*] //' | sort -k3nr | head -1 | awk '{ print $2 " " $3 }'`"
2929 if test -z "$ngps"
3030 then
3131 echo "$configfile ------- " $stopstate
tools/testing/selftests/rcutorture/bin/kvm-remote.sh+15−8
@@ -144,7 +144,7 @@ do · 143 unmodified lines
144144 if test "$ret" -ne 0
145145 then
146146 echo System $i unreachable, giving up. | tee -a "$oldrun/remote-log"
147− exit 4 | tee -a "$oldrun/remote-log"
147+ exit 4
148148 fi
149149 done
150150
@@ -157,8 +157,15 @@ do · 6 unmodified lines
157157 ret=$?
158158 if test "$ret" -ne 0
159159 then
160− echo Unable to download $T/binres.tgz to system $i, giving up. | tee -a "$oldrun/remote-log"
161− exit 10 | tee -a "$oldrun/remote-log"
160+ echo Unable to download $T/binres.tgz to system $i, waiting and then retrying. | tee -a "$oldrun/remote-log"
161+ sleep 60
162+ cat $T/binres.tgz | ssh $i "cd /tmp; tar -xzf -"
163+ ret=$?
164+ if test "$ret" -ne 0
165+ then
166+ echo Unable to download $T/binres.tgz to system $i, giving up. | tee -a "$oldrun/remote-log"
167+ exit 10
168+ fi
162169 fi
163170 done
164171
@@ -177,16 +184,16 @@ checkremotefile () { · 12 unmodified lines
177184 ret=$?
178185 if test "$ret" -eq 255
179186 then
180− echo " ---" ssh failure to $1 checking for file $2, retry after $sleeptime seconds. `date`
187+ echo " ---" ssh failure to $1 checking for file $2, retry after $sleeptime seconds. `date` | tee -a "$oldrun/remote-log"
181188 elif test "$ret" -eq 0
182189 then
183190 return 0
184191 elif test "$ret" -eq 1
185192 then
186− echo " ---" File \"$2\" not found: ssh $1 test -f \"$2\"
193+ echo " ---" File \"$2\" not found: ssh $1 test -f \"$2\" | tee -a "$oldrun/remote-log"
187194 return 1
188195 else
189− echo " ---" Exit code $ret: ssh $1 test -f \"$2\", retry after $sleeptime seconds. `date`
196+ echo " ---" Exit code $ret: ssh $1 test -f \"$2\", retry after $sleeptime seconds. `date` | tee -a "$oldrun/remote-log"
190197 return $ret
191198 fi
192199 sleep $sleeptime
@@ -245,7 +252,7 @@ do · 52 unmodified lines
245252 sleep 30
246253 fi
247254 done
248−echo All batches started. `date`
255+echo All batches started. `date` | tee -a "$oldrun/remote-log"
249256
250257 # Wait for all remaining scenarios to complete and collect results.
251258 for i in $systems
@@ -254,7 +261,7 @@ do · 2 unmodified lines
254261 do
255262 sleep 30
256263 done
257− echo " ---" Collecting results from $i `date`
264+ echo " ---" Collecting results from $i `date` | tee -a "$oldrun/remote-log"
258265 ( cd "$oldrun"; ssh $i "cd $rundir; tar -czf - kvm-remote-*.sh.out */console.log */kvm-test-1-run*.sh.out */qemu[_-]pid */qemu-retval */qemu-affinity; rm -rf $T > /dev/null 2>&1" | tar -xzf - )
259266 done
260267
tools/testing/selftests/rcutorture/bin/kvm.sh+6−3
@@ -74,7 +74,9 @@ usage () { · 73 unmodified lines
7474 echo " --help"
7575 echo " --interactive"
7676 echo " --jitter N [ maxsleep (us) [ maxspin (us) ] ]"
77+ echo " --kasan"
7778 echo " --kconfig Kconfig-options"
79+ echo " --kcsan"
7880 echo " --kmake-arg kernel-make-arguments"
7981 echo " --mac nn:nn:nn:nn:nn:nn"
8082 echo " --memory megabytes|nnnG"
@@ -83,6 +85,7 @@ usage () { · 2 unmodified lines
8385 echo " --qemu-cmd qemu-system-..."
8486 echo " --remote"
8587 echo " --results absolute-pathname"
88+ echo " --shutdown-grace seconds"
8689 echo " --torture lock|rcu|rcuscale|refscale|scf"
8790 echo " --trust-make"
8891 exit 1
@@ -175,14 +178,14 @@ do · 86 unmodified lines
175178 jitter="$2"
176179 shift
177180 ;;
181+ --kasan)
182+ TORTURE_KCONFIG_KASAN_ARG="CONFIG_DEBUG_INFO=y CONFIG_KASAN=y"; export TORTURE_KCONFIG_KASAN_ARG
183+ ;;
178184 --kconfig|--kconfigs)
179185 checkarg --kconfig "(Kconfig options)" $# "$2" '^CONFIG_[A-Z0-9_]\+=\([ynm]\|[0-9]\+\)\( CONFIG_[A-Z0-9_]\+=\([ynm]\|[0-9]\+\)\)*$' '^error$'
180186 TORTURE_KCONFIG_ARG="`echo "$TORTURE_KCONFIG_ARG $2" | sed -e 's/^ *//' -e 's/ *$//'`"
181187 shift
182188 ;;
183− --kasan)
184− TORTURE_KCONFIG_KASAN_ARG="CONFIG_DEBUG_INFO=y CONFIG_KASAN=y"; export TORTURE_KCONFIG_KASAN_ARG
185− ;;
186189 --kcsan)
187190 TORTURE_KCONFIG_KCSAN_ARG="CONFIG_DEBUG_INFO=y CONFIG_KCSAN=y CONFIG_KCSAN_STRICT=y CONFIG_KCSAN_REPORT_ONCE_IN_MS=100000 CONFIG_KCSAN_VERBOSE=y CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y"; export TORTURE_KCONFIG_KCSAN_ARG
188191 ;;
tools/testing/selftests/rcutorture/bin/parse-build.sh+2−1
@@ -39,7 +39,8 @@ fi · 38 unmodified lines
3939 grep warning: < $F > $T/warnings
4040 grep "include/linux/*rcu*\.h:" $T/warnings > $T/hwarnings
4141 grep "kernel/rcu/[^/]*:" $T/warnings > $T/cwarnings
42−cat $T/hwarnings $T/cwarnings > $T/rcuwarnings
42+grep "^ld: .*undefined reference to" $T/warnings | head -1 > $T/ldwarnings
43+cat $T/hwarnings $T/cwarnings $T/ldwarnings > $T/rcuwarnings
4344 if test -s $T/rcuwarnings
4445 then
4546 print_warning $title build errors:
tools/testing/selftests/rcutorture/configs/rcu/TASKS01.boot+1−0
@@ -1,2 +1,3 @@
11 rcutorture.torture_type=tasks
22 rcutree.use_softirq=0
3+rcupdate.rcu_task_enqueue_lim=4
tools/testing/selftests/rcutorture/configs/rcu/TRACE01.boot+1−0
@@ -1 +1,2 @@
11 rcutorture.torture_type=tasks-tracing
2+rcupdate.rcu_task_enqueue_lim=2
tools/testing/selftests/rcutorture/configs/rcu/TRACE02.boot+1−0
@@ -1 +1,2 @@
11 rcutorture.torture_type=tasks-tracing
2+rcutorture.fwd_progress=2
tools/testing/selftests/rcutorture/configs/rcu/TREE01+0−1
@@ -6,7 +6,6 @@ CONFIG_PREEMPT=y · 5 unmodified lines
66 CONFIG_HZ_PERIODIC=n
77 CONFIG_NO_HZ_IDLE=y
88 CONFIG_NO_HZ_FULL=n
9−CONFIG_RCU_FAST_NO_HZ=y
109 CONFIG_RCU_TRACE=y
1110 CONFIG_HOTPLUG_CPU=y
1211 CONFIG_MAXSMP=y
tools/testing/selftests/rcutorture/configs/rcu/TREE02+0−1
@@ -7,7 +7,6 @@ CONFIG_PREEMPT=y · 6 unmodified lines
77 CONFIG_HZ_PERIODIC=n
88 CONFIG_NO_HZ_IDLE=y
99 CONFIG_NO_HZ_FULL=n
10−CONFIG_RCU_FAST_NO_HZ=n
1110 CONFIG_RCU_TRACE=n
1211 CONFIG_RCU_FANOUT=3
1312 CONFIG_RCU_FANOUT_LEAF=3
tools/testing/selftests/rcutorture/configs/rcu/TREE02.boot+1−0
@@ -0,0 +1 @@
1+rcutorture.fwd_progress=2
tools/testing/selftests/rcutorture/configs/rcu/TREE04+0−1
@@ -7,7 +7,6 @@ CONFIG_PREEMPT=n · 6 unmodified lines
77 CONFIG_HZ_PERIODIC=n
88 CONFIG_NO_HZ_IDLE=n
99 CONFIG_NO_HZ_FULL=y
10−CONFIG_RCU_FAST_NO_HZ=y
1110 CONFIG_RCU_TRACE=y
1211 CONFIG_RCU_FANOUT=4
1312 CONFIG_RCU_FANOUT_LEAF=3
tools/testing/selftests/rcutorture/configs/rcu/TREE05+0−1
@@ -7,7 +7,6 @@ CONFIG_PREEMPT=n · 6 unmodified lines
77 CONFIG_HZ_PERIODIC=n
88 CONFIG_NO_HZ_IDLE=y
99 CONFIG_NO_HZ_FULL=n
10−CONFIG_RCU_FAST_NO_HZ=n
1110 CONFIG_RCU_TRACE=n
1211 CONFIG_HOTPLUG_CPU=y
1312 CONFIG_RCU_FANOUT=6
tools/testing/selftests/rcutorture/configs/rcu/TREE06+0−1
@@ -7,7 +7,6 @@ CONFIG_PREEMPT=n · 6 unmodified lines
77 CONFIG_HZ_PERIODIC=n
88 CONFIG_NO_HZ_IDLE=y
99 CONFIG_NO_HZ_FULL=n
10−CONFIG_RCU_FAST_NO_HZ=n
1110 CONFIG_RCU_TRACE=n
1211 CONFIG_RCU_FANOUT=6
1312 CONFIG_RCU_FANOUT_LEAF=6
tools/testing/selftests/rcutorture/configs/rcu/TREE07+0−1
@@ -7,7 +7,6 @@ CONFIG_PREEMPT=n · 6 unmodified lines
77 CONFIG_HZ_PERIODIC=n
88 CONFIG_NO_HZ_IDLE=n
99 CONFIG_NO_HZ_FULL=y
10−CONFIG_RCU_FAST_NO_HZ=n
1110 CONFIG_RCU_TRACE=y
1211 CONFIG_HOTPLUG_CPU=y
1312 CONFIG_RCU_FANOUT=2
tools/testing/selftests/rcutorture/configs/rcu/TREE08+0−1
@@ -7,7 +7,6 @@ CONFIG_PREEMPT=y · 6 unmodified lines
77 CONFIG_HZ_PERIODIC=n
88 CONFIG_NO_HZ_IDLE=y
99 CONFIG_NO_HZ_FULL=n
10−CONFIG_RCU_FAST_NO_HZ=n
1110 CONFIG_RCU_TRACE=n
1211 CONFIG_RCU_FANOUT=3
1312 CONFIG_RCU_FANOUT_LEAF=2
tools/testing/selftests/rcutorture/configs/rcu/TREE10+0−1
@@ -7,7 +7,6 @@ CONFIG_PREEMPT=n · 6 unmodified lines
77 CONFIG_HZ_PERIODIC=n
88 CONFIG_NO_HZ_IDLE=y
99 CONFIG_NO_HZ_FULL=n
10−CONFIG_RCU_FAST_NO_HZ=n
1110 CONFIG_RCU_TRACE=n
1211 CONFIG_RCU_NOCB_CPU=n
1312 CONFIG_DEBUG_LOCK_ALLOC=n
tools/testing/selftests/rcutorture/configs/rcu/TREE10.boot+1−0
@@ -0,0 +1 @@
1+rcutorture.fwd_progress=2
tools/testing/selftests/rcutorture/configs/rcuscale/TINY+0−1
@@ -7,7 +7,6 @@ CONFIG_PREEMPT_DYNAMIC=n · 6 unmodified lines
77 CONFIG_HZ_PERIODIC=n
88 CONFIG_NO_HZ_IDLE=y
99 CONFIG_NO_HZ_FULL=n
10−CONFIG_RCU_FAST_NO_HZ=n
1110 CONFIG_RCU_NOCB_CPU=n
1211 CONFIG_DEBUG_LOCK_ALLOC=n
1312 CONFIG_PROVE_LOCKING=n
tools/testing/selftests/rcutorture/configs/rcuscale/TRACE01+0−1
@@ -5,7 +5,6 @@ CONFIG_PREEMPT=n · 4 unmodified lines
55 CONFIG_HZ_PERIODIC=n
66 CONFIG_NO_HZ_IDLE=y
77 CONFIG_NO_HZ_FULL=n
8−CONFIG_RCU_FAST_NO_HZ=n
98 CONFIG_RCU_NOCB_CPU=n
109 CONFIG_DEBUG_LOCK_ALLOC=n
1110 CONFIG_PROVE_LOCKING=n
tools/testing/selftests/rcutorture/configs/rcuscale/TREE+0−1
@@ -6,7 +6,6 @@ CONFIG_PREEMPT=y · 5 unmodified lines
66 CONFIG_HZ_PERIODIC=n
77 CONFIG_NO_HZ_IDLE=y
88 CONFIG_NO_HZ_FULL=n
9−CONFIG_RCU_FAST_NO_HZ=n
109 CONFIG_HOTPLUG_CPU=y
1110 CONFIG_SUSPEND=n
1211 CONFIG_HIBERNATION=n
tools/testing/selftests/rcutorture/configs/rcuscale/TREE54+0−1
@@ -7,7 +7,6 @@ CONFIG_PREEMPT=y · 6 unmodified lines
77 CONFIG_HZ_PERIODIC=n
88 CONFIG_NO_HZ_IDLE=y
99 CONFIG_NO_HZ_FULL=n
10−CONFIG_RCU_FAST_NO_HZ=n
1110 CONFIG_HOTPLUG_CPU=y
1211 CONFIG_SUSPEND=n
1312 CONFIG_HIBERNATION=n
tools/testing/selftests/rcutorture/configs/refscale/NOPREEMPT+0−1
@@ -6,7 +6,6 @@ CONFIG_PREEMPT=n · 5 unmodified lines
66 CONFIG_HZ_PERIODIC=n
77 CONFIG_NO_HZ_IDLE=y
88 CONFIG_NO_HZ_FULL=n
9−CONFIG_RCU_FAST_NO_HZ=n
109 CONFIG_HOTPLUG_CPU=y
1110 CONFIG_SUSPEND=n
1211 CONFIG_HIBERNATION=n
tools/testing/selftests/rcutorture/configs/refscale/PREEMPT+0−1
@@ -6,7 +6,6 @@ CONFIG_PREEMPT=y · 5 unmodified lines
66 CONFIG_HZ_PERIODIC=n
77 CONFIG_NO_HZ_IDLE=y
88 CONFIG_NO_HZ_FULL=n
9−CONFIG_RCU_FAST_NO_HZ=n
109 CONFIG_HOTPLUG_CPU=y
1110 CONFIG_SUSPEND=n
1211 CONFIG_HIBERNATION=n
tools/testing/selftests/rcutorture/doc/TREE_RCU-kconfig.txt+0−1
@@ -15,7 +15,6 @@ CONFIG_PROVE_RCU -- Hardwired to CONFIG_PROVE_LOCKING. · 14 unmodified lines
1515 CONFIG_RCU_BOOST -- one of PREEMPT_RCU.
1616 CONFIG_RCU_FANOUT -- Cover hierarchy, but overlap with others.
1717 CONFIG_RCU_FANOUT_LEAF -- Do one non-default.
18−CONFIG_RCU_FAST_NO_HZ -- Do one, but not with all nohz_full CPUs.
1918 CONFIG_RCU_NOCB_CPU -- Do three, one with no rcu_nocbs CPUs, one with
2019 rcu_nocbs=0, and one with all rcu_nocbs CPUs.
2120 CONFIG_RCU_TRACE -- Do half.