History

Merge branches 'doc.2015.01.07a', 'fixes.2015.01.15a', 'preempt.2015.01.06a', 'srcu.2015.01.06a', 'stall.2015.01.16a' and 'torture.2015.01.11a' into HEAD

doc.2015.01.07a: Documentation updates. fixes.2015.01.15a: Miscellaneous fixes. preempt.2015.01.06a: Changes to handling of lists of preempted tasks. srcu.2015.01.06a: SRCU updates. stall.2015.01.16a: RCU CPU stall-warning updates and fixes. torture.2015.01.11a: RCU torture-test updates and fixes.

Paul E. McKenney committed 11 years ago

Commit 78e691f6 parents d87510c 6047967 ab954c1 83fe27e 630181c 7602de447 files · +562 −567Browse files

Unified · Split

47 files
  1. Documentation/RCU/stallwarn.txt +14 −0
  2. Documentation/RCU/trace.txt +16 −16
  3. arch/arm/kvm/Kconfig +1 −0
  4. arch/arm64/kvm/Kconfig +1 −0
  5. arch/mips/kvm/Kconfig +1 −0
  6. arch/powerpc/kvm/Kconfig +1 −0
  7. arch/s390/kvm/Kconfig +1 −0
  8. arch/tile/kvm/Kconfig +1 −0
  9. arch/x86/Kconfig +1 −0
  10. arch/x86/kvm/Kconfig +1 −0
  11. drivers/clk/Kconfig +1 −0
  12. drivers/cpufreq/Kconfig +1 −0
  13. drivers/devfreq/Kconfig +1 −0
  14. drivers/md/Kconfig +1 −0
  15. drivers/net/Kconfig +1 −0
  16. fs/btrfs/Kconfig +1 −0
  17. fs/notify/Kconfig +1 −0
  18. fs/quota/Kconfig +1 −0
  19. include/linux/compiler.h +1 −1
  20. include/linux/rculist.h +8 −8
  21. include/linux/rcupdate.h +7 −6
  22. include/linux/rcutiny.h +40 −5
  23. include/linux/rcutree.h +8 −3
  24. include/linux/srcu.h +6 −8
  25. init/Kconfig +13 −5
  26. kernel/cpu.c +23 −33
  27. kernel/notifier.c +3 −0
  28. kernel/power/Kconfig +1 −0
  29. kernel/rcu/Makefile +2 −1
  30. kernel/rcu/rcu.h +6 −0
  31. kernel/rcu/rcutorture.c +38 −28
  32. kernel/rcu/srcu.c +1 −1
  33. kernel/rcu/tiny.c +10 −103
  34. kernel/rcu/tiny_plugin.h +4 −5
  35. kernel/rcu/tree.c +209 −80
  36. kernel/rcu/tree.h +15 −47
  37. kernel/rcu/tree_plugin.h +72 −199
  38. kernel/rcu/tree_trace.c +6 −2
  39. kernel/softirq.c +1 −2
  40. lib/Kconfig.debug +2 −1
  41. mm/Kconfig +1 −0
  42. security/tomoyo/Kconfig +1 −0
  43. tools/testing/selftests/rcutorture/bin/cpus2use.sh +1 −1
  44. tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh +18 −0
  45. tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +5 −4
  46. tools/testing/selftests/rcutorture/bin/parse-build.sh +13 −7
  47. tools/testing/selftests/rcutorture/bin/parse-console.sh +1 −1
Documentation/RCU/stallwarn.txt+14−0
@@ -152,6 +152,15 @@ no non-lazy callbacks ("." is printed otherwise, as shown above) and · 151 unmodified lines
152152 "D" indicates that dyntick-idle processing is enabled ("." is printed
153153 otherwise, for example, if disabled via the "nohz=" kernel boot parameter).
154154
155+If the relevant grace-period kthread has been unable to run prior to
156+the stall warning, the following additional line is printed:
157+
158+ rcu_preempt kthread starved for 2023 jiffies!
159+
160+Starving the grace-period kthreads of CPU time can of course result in
161+RCU CPU stall warnings even when all CPUs and tasks have passed through
162+the required quiescent states.
163+
155164
156165 Multiple Warnings From One Stall
157166
@@ -187,6 +196,11 @@ o For !CONFIG_PREEMPT kernels, a CPU looping anywhere in the · 29 unmodified lines
187196 behavior, you might need to replace some of the cond_resched()
188197 calls with calls to cond_resched_rcu_qs().
189198
199+o Anything that prevents RCU's grace-period kthreads from running.
200+ This can result in the "All QSes seen" console-log message.
201+ This message will include information on when the kthread last
202+ ran and how often it should be expected to run.
203+
190204 o A CPU-bound real-time task in a CONFIG_PREEMPT kernel, which might
191205 happen to preempt a low-priority task in the middle of an RCU
192206 read-side critical section. This is especially damaging if
Documentation/RCU/trace.txt+16−16
@@ -56,14 +56,14 @@ rcuboost: · 55 unmodified lines
5656
5757 The output of "cat rcu/rcu_preempt/rcudata" looks as follows:
5858
59− 0!c=30455 g=30456 pq=1 qp=1 dt=126535/140000000000000/0 df=2002 of=4 ql=0/0 qs=N... b=10 ci=74572 nci=0 co=1131 ca=716
60− 1!c=30719 g=30720 pq=1 qp=0 dt=132007/140000000000000/0 df=1874 of=10 ql=0/0 qs=N... b=10 ci=123209 nci=0 co=685 ca=982
61− 2!c=30150 g=30151 pq=1 qp=1 dt=138537/140000000000000/0 df=1707 of=8 ql=0/0 qs=N... b=10 ci=80132 nci=0 co=1328 ca=1458
62− 3 c=31249 g=31250 pq=1 qp=0 dt=107255/140000000000000/0 df=1749 of=6 ql=0/450 qs=NRW. b=10 ci=151700 nci=0 co=509 ca=622
63− 4!c=29502 g=29503 pq=1 qp=1 dt=83647/140000000000000/0 df=965 of=5 ql=0/0 qs=N... b=10 ci=65643 nci=0 co=1373 ca=1521
64− 5 c=31201 g=31202 pq=1 qp=1 dt=70422/0/0 df=535 of=7 ql=0/0 qs=.... b=10 ci=58500 nci=0 co=764 ca=698
65− 6!c=30253 g=30254 pq=1 qp=1 dt=95363/140000000000000/0 df=780 of=5 ql=0/0 qs=N... b=10 ci=100607 nci=0 co=1414 ca=1353
66− 7 c=31178 g=31178 pq=1 qp=0 dt=91536/0/0 df=547 of=4 ql=0/0 qs=.... b=10 ci=109819 nci=0 co=1115 ca=969
59+ 0!c=30455 g=30456 pq=1/0 qp=1 dt=126535/140000000000000/0 df=2002 of=4 ql=0/0 qs=N... b=10 ci=74572 nci=0 co=1131 ca=716
60+ 1!c=30719 g=30720 pq=1/0 qp=0 dt=132007/140000000000000/0 df=1874 of=10 ql=0/0 qs=N... b=10 ci=123209 nci=0 co=685 ca=982
61+ 2!c=30150 g=30151 pq=1/1 qp=1 dt=138537/140000000000000/0 df=1707 of=8 ql=0/0 qs=N... b=10 ci=80132 nci=0 co=1328 ca=1458
62+ 3 c=31249 g=31250 pq=1/1 qp=0 dt=107255/140000000000000/0 df=1749 of=6 ql=0/450 qs=NRW. b=10 ci=151700 nci=0 co=509 ca=622
63+ 4!c=29502 g=29503 pq=1/0 qp=1 dt=83647/140000000000000/0 df=965 of=5 ql=0/0 qs=N... b=10 ci=65643 nci=0 co=1373 ca=1521
64+ 5 c=31201 g=31202 pq=1/0 qp=1 dt=70422/0/0 df=535 of=7 ql=0/0 qs=.... b=10 ci=58500 nci=0 co=764 ca=698
65+ 6!c=30253 g=30254 pq=1/0 qp=1 dt=95363/140000000000000/0 df=780 of=5 ql=0/0 qs=N... b=10 ci=100607 nci=0 co=1414 ca=1353
66+ 7 c=31178 g=31178 pq=1/0 qp=0 dt=91536/0/0 df=547 of=4 ql=0/0 qs=.... b=10 ci=109819 nci=0 co=1115 ca=969
6767
6868 This file has one line per CPU, or eight for this 8-CPU system.
6969 The fields are as follows:
@@ -188,14 +188,14 @@ o "ca" is the number of RCU callbacks that have been adopted by this · 118 unmodified lines
188188 Kernels compiled with CONFIG_RCU_BOOST=y display the following from
189189 /debug/rcu/rcu_preempt/rcudata:
190190
191− 0!c=12865 g=12866 pq=1 qp=1 dt=83113/140000000000000/0 df=288 of=11 ql=0/0 qs=N... kt=0/O ktl=944 b=10 ci=60709 nci=0 co=748 ca=871
192− 1 c=14407 g=14408 pq=1 qp=0 dt=100679/140000000000000/0 df=378 of=7 ql=0/119 qs=NRW. kt=0/W ktl=9b6 b=10 ci=109740 nci=0 co=589 ca=485
193− 2 c=14407 g=14408 pq=1 qp=0 dt=105486/0/0 df=90 of=9 ql=0/89 qs=NRW. kt=0/W ktl=c0c b=10 ci=83113 nci=0 co=533 ca=490
194− 3 c=14407 g=14408 pq=1 qp=0 dt=107138/0/0 df=142 of=8 ql=0/188 qs=NRW. kt=0/W ktl=b96 b=10 ci=121114 nci=0 co=426 ca=290
195− 4 c=14405 g=14406 pq=1 qp=1 dt=50238/0/0 df=706 of=7 ql=0/0 qs=.... kt=0/W ktl=812 b=10 ci=34929 nci=0 co=643 ca=114
196− 5!c=14168 g=14169 pq=1 qp=0 dt=45465/140000000000000/0 df=161 of=11 ql=0/0 qs=N... kt=0/O ktl=b4d b=10 ci=47712 nci=0 co=677 ca=722
197− 6 c=14404 g=14405 pq=1 qp=0 dt=59454/0/0 df=94 of=6 ql=0/0 qs=.... kt=0/W ktl=e57 b=10 ci=55597 nci=0 co=701 ca=811
198− 7 c=14407 g=14408 pq=1 qp=1 dt=68850/0/0 df=31 of=8 ql=0/0 qs=.... kt=0/W ktl=14bd b=10 ci=77475 nci=0 co=508 ca=1042
191+ 0!c=12865 g=12866 pq=1/0 qp=1 dt=83113/140000000000000/0 df=288 of=11 ql=0/0 qs=N... kt=0/O ktl=944 b=10 ci=60709 nci=0 co=748 ca=871
192+ 1 c=14407 g=14408 pq=1/0 qp=0 dt=100679/140000000000000/0 df=378 of=7 ql=0/119 qs=NRW. kt=0/W ktl=9b6 b=10 ci=109740 nci=0 co=589 ca=485
193+ 2 c=14407 g=14408 pq=1/0 qp=0 dt=105486/0/0 df=90 of=9 ql=0/89 qs=NRW. kt=0/W ktl=c0c b=10 ci=83113 nci=0 co=533 ca=490
194+ 3 c=14407 g=14408 pq=1/0 qp=0 dt=107138/0/0 df=142 of=8 ql=0/188 qs=NRW. kt=0/W ktl=b96 b=10 ci=121114 nci=0 co=426 ca=290
195+ 4 c=14405 g=14406 pq=1/0 qp=1 dt=50238/0/0 df=706 of=7 ql=0/0 qs=.... kt=0/W ktl=812 b=10 ci=34929 nci=0 co=643 ca=114
196+ 5!c=14168 g=14169 pq=1/0 qp=0 dt=45465/140000000000000/0 df=161 of=11 ql=0/0 qs=N... kt=0/O ktl=b4d b=10 ci=47712 nci=0 co=677 ca=722
197+ 6 c=14404 g=14405 pq=1/0 qp=0 dt=59454/0/0 df=94 of=6 ql=0/0 qs=.... kt=0/W ktl=e57 b=10 ci=55597 nci=0 co=701 ca=811
198+ 7 c=14407 g=14408 pq=1/0 qp=1 dt=68850/0/0 df=31 of=8 ql=0/0 qs=.... kt=0/W ktl=14bd b=10 ci=77475 nci=0 co=508 ca=1042
199199
200200 This is similar to the output discussed above, but contains the following
201201 additional fields:
arch/arm/kvm/Kconfig+1−0
@@ -23,6 +23,7 @@ config KVM · 22 unmodified lines
2323 select HAVE_KVM_CPU_RELAX_INTERCEPT
2424 select KVM_MMIO
2525 select KVM_ARM_HOST
26+ select SRCU
2627 depends on ARM_VIRT_EXT && ARM_LPAE
2728 ---help---
2829 Support hosting virtualized guest machines. You will also
arch/arm64/kvm/Kconfig+1−0
@@ -26,6 +26,7 @@ config KVM · 25 unmodified lines
2626 select KVM_ARM_HOST
2727 select KVM_ARM_VGIC
2828 select KVM_ARM_TIMER
29+ select SRCU
2930 ---help---
3031 Support hosting virtualized guest machines.
3132
arch/mips/kvm/Kconfig+1−0
@@ -20,6 +20,7 @@ config KVM · 19 unmodified lines
2020 select PREEMPT_NOTIFIERS
2121 select ANON_INODES
2222 select KVM_MMIO
23+ select SRCU
2324 ---help---
2425 Support for hosting Guest kernels.
2526 Currently supported on MIPS32 processors.
arch/powerpc/kvm/Kconfig+1−0
@@ -21,6 +21,7 @@ config KVM · 20 unmodified lines
2121 select PREEMPT_NOTIFIERS
2222 select ANON_INODES
2323 select HAVE_KVM_EVENTFD
24+ select SRCU
2425
2526 config KVM_BOOK3S_HANDLER
2627 bool
arch/s390/kvm/Kconfig+1−0
@@ -28,6 +28,7 @@ config KVM · 27 unmodified lines
2828 select HAVE_KVM_IRQCHIP
2929 select HAVE_KVM_IRQFD
3030 select HAVE_KVM_IRQ_ROUTING
31+ select SRCU
3132 ---help---
3233 Support hosting paravirtualized guest machines using the SIE
3334 virtualization capability on the mainframe. This should work
arch/tile/kvm/Kconfig+1−0
@@ -21,6 +21,7 @@ config KVM · 20 unmodified lines
2121 depends on HAVE_KVM && MODULES
2222 select PREEMPT_NOTIFIERS
2323 select ANON_INODES
24+ select SRCU
2425 ---help---
2526 Support hosting paravirtualized guest machines.
2627
arch/x86/Kconfig+1−0
@@ -138,6 +138,7 @@ config X86 · 137 unmodified lines
138138 select HAVE_ACPI_APEI_NMI if ACPI
139139 select ACPI_LEGACY_TABLES_LOOKUP if ACPI
140140 select X86_FEATURE_NAMES if PROC_FS
141+ select SRCU
141142
142143 config INSTRUCTION_DECODER
143144 def_bool y
arch/x86/kvm/Kconfig+1−0
@@ -40,6 +40,7 @@ config KVM · 39 unmodified lines
4040 select HAVE_KVM_MSI
4141 select HAVE_KVM_CPU_RELAX_INTERCEPT
4242 select KVM_VFIO
43+ select SRCU
4344 ---help---
4445 Support hosting fully virtualized guest machines using hardware
4546 virtualization extensions. You will need a fairly recent
drivers/clk/Kconfig+1−0
@@ -13,6 +13,7 @@ config COMMON_CLK · 12 unmodified lines
1313 bool
1414 select HAVE_CLK_PREPARE
1515 select CLKDEV_LOOKUP
16+ select SRCU
1617 ---help---
1718 The common clock framework is a single definition of struct
1819 clk, useful across many platforms, as well as an
drivers/cpufreq/Kconfig+1−0
@@ -2,6 +2,7 @@ menu "CPU Frequency scaling" · 1 unmodified line
22
33 config CPU_FREQ
44 bool "CPU Frequency scaling"
5+ select SRCU
56 help
67 CPU Frequency scaling allows you to change the clock speed of
78 CPUs on the fly. This is a nice method to save power, because
drivers/devfreq/Kconfig+1−0
@@ -1,5 +1,6 @@
11 menuconfig PM_DEVFREQ
22 bool "Generic Dynamic Voltage and Frequency Scaling (DVFS) support"
3+ select SRCU
34 help
45 A device may have a list of frequencies and voltages available.
56 devfreq, a generic DVFS framework can be registered for a device
drivers/md/Kconfig+1−0
@@ -5,6 +5,7 @@ · 4 unmodified lines
55 menuconfig MD
66 bool "Multiple devices driver support (RAID and LVM)"
77 depends on BLOCK
8+ select SRCU
89 help
910 Support multiple physical spindles through a single logical device.
1011 Required for RAID and logical volume management.
drivers/net/Kconfig+1−0
@@ -197,6 +197,7 @@ config NETCONSOLE_DYNAMIC · 196 unmodified lines
197197
198198 config NETPOLL
199199 def_bool NETCONSOLE
200+ select SRCU
200201
201202 config NET_POLL_CONTROLLER
202203 def_bool NETPOLL
fs/btrfs/Kconfig+1−0
@@ -8,6 +8,7 @@ config BTRFS_FS · 7 unmodified lines
88 select LZO_DECOMPRESS
99 select RAID6_PQ
1010 select XOR_BLOCKS
11+ select SRCU
1112
1213 help
1314 Btrfs is a general purpose copy-on-write filesystem with extents,
fs/notify/Kconfig+1−0
@@ -1,5 +1,6 @@
11 config FSNOTIFY
22 def_bool n
3+ select SRCU
34
45 source "fs/notify/dnotify/Kconfig"
56 source "fs/notify/inotify/Kconfig"
fs/quota/Kconfig+1−0
@@ -5,6 +5,7 @@ · 4 unmodified lines
55 config QUOTA
66 bool "Quota support"
77 select QUOTACTL
8+ select SRCU
89 help
910 If you say Y here, you will be able to set per user limits for disk
1011 usage (also called disk quotas). Currently, it works for the
include/linux/compiler.h+1−1
@@ -385,7 +385,7 @@ static __always_inline void __assign_once_size(volatile void *p, void *res, int · 384 unmodified lines
385385
386386 /* Is this type a native word size -- useful for atomic operations */
387387 #ifndef __native_word
388−# define __native_word(t) (sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
388+# define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
389389 #endif
390390
391391 /* Compile time object size, -1 for unknown */
include/linux/rculist.h+8−8
@@ -524,11 +524,11 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, · 523 unmodified lines
524524 * @member: the name of the hlist_node within the struct.
525525 */
526526 #define hlist_for_each_entry_continue_rcu(pos, member) \
527− for (pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\
528− typeof(*(pos)), member); \
527+ for (pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
528+ &(pos)->member)), typeof(*(pos)), member); \
529529 pos; \
530− pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\
531− typeof(*(pos)), member))
530+ pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
531+ &(pos)->member)), typeof(*(pos)), member))
532532
533533 /**
534534 * hlist_for_each_entry_continue_rcu_bh - iterate over a hlist continuing after current point
@@ -536,11 +536,11 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, · 1 unmodified line
536536 * @member: the name of the hlist_node within the struct.
537537 */
538538 #define hlist_for_each_entry_continue_rcu_bh(pos, member) \
539− for (pos = hlist_entry_safe(rcu_dereference_bh((pos)->member.next),\
540− typeof(*(pos)), member); \
539+ for (pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \
540+ &(pos)->member)), typeof(*(pos)), member); \
541541 pos; \
542− pos = hlist_entry_safe(rcu_dereference_bh((pos)->member.next),\
543− typeof(*(pos)), member))
542+ pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \
543+ &(pos)->member)), typeof(*(pos)), member))
544544
545545 /**
546546 * hlist_for_each_entry_from_rcu - iterate over a hlist continuing from current point
include/linux/rcupdate.h+7−6
@@ -331,12 +331,13 @@ static inline void rcu_init_nohz(void) · 330 unmodified lines
331331 extern struct srcu_struct tasks_rcu_exit_srcu;
332332 #define rcu_note_voluntary_context_switch(t) \
333333 do { \
334+ rcu_all_qs(); \
334335 if (ACCESS_ONCE((t)->rcu_tasks_holdout)) \
335336 ACCESS_ONCE((t)->rcu_tasks_holdout) = false; \
336337 } while (0)
337338 #else /* #ifdef CONFIG_TASKS_RCU */
338339 #define TASKS_RCU(x) do { } while (0)
339−#define rcu_note_voluntary_context_switch(t) do { } while (0)
340+#define rcu_note_voluntary_context_switch(t) rcu_all_qs()
340341 #endif /* #else #ifdef CONFIG_TASKS_RCU */
341342
342343 /**
@@ -582,11 +583,11 @@ static inline void rcu_preempt_sleep_check(void) · 239 unmodified lines
582583 })
583584 #define __rcu_dereference_check(p, c, space) \
584585 ({ \
585− typeof(*p) *_________p1 = (typeof(*p) *__force)ACCESS_ONCE(p); \
586+ /* Dependency order vs. p above. */ \
587+ typeof(*p) *________p1 = (typeof(*p) *__force)lockless_dereference(p); \
586588 rcu_lockdep_assert(c, "suspicious rcu_dereference_check() usage"); \
587589 rcu_dereference_sparse(p, space); \
588− smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
589− ((typeof(*p) __force __kernel *)(_________p1)); \
590+ ((typeof(*p) __force __kernel *)(________p1)); \
590591 })
591592 #define __rcu_dereference_protected(p, c, space) \
592593 ({ \
@@ -603,10 +604,10 @@ static inline void rcu_preempt_sleep_check(void) · 10 unmodified lines
603604 })
604605 #define __rcu_dereference_index_check(p, c) \
605606 ({ \
606− typeof(p) _________p1 = ACCESS_ONCE(p); \
607+ /* Dependency order vs. p above. */ \
608+ typeof(p) _________p1 = lockless_dereference(p); \
607609 rcu_lockdep_assert(c, \
608610 "suspicious rcu_dereference_index_check() usage"); \
609− smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
610611 (_________p1); \
611612 })
612613
include/linux/rcutiny.h+40−5
@@ -92,17 +92,49 @@ static inline void rcu_virt_note_context_switch(int cpu) · 91 unmodified lines
9292 }
9393
9494 /*
95− * Return the number of grace periods.
95+ * Return the number of grace periods started.
9696 */
97−static inline long rcu_batches_completed(void)
97+static inline unsigned long rcu_batches_started(void)
9898 {
9999 return 0;
100100 }
101101
102102 /*
103− * Return the number of bottom-half grace periods.
103+ * Return the number of bottom-half grace periods started.
104104 */
105−static inline long rcu_batches_completed_bh(void)
105+static inline unsigned long rcu_batches_started_bh(void)
106+{
107+ return 0;
108+}
109+
110+/*
111+ * Return the number of sched grace periods started.
112+ */
113+static inline unsigned long rcu_batches_started_sched(void)
114+{
115+ return 0;
116+}
117+
118+/*
119+ * Return the number of grace periods completed.
120+ */
121+static inline unsigned long rcu_batches_completed(void)
122+{
123+ return 0;
124+}
125+
126+/*
127+ * Return the number of bottom-half grace periods completed.
128+ */
129+static inline unsigned long rcu_batches_completed_bh(void)
130+{
131+ return 0;
132+}
133+
134+/*
135+ * Return the number of sched grace periods completed.
136+ */
137+static inline unsigned long rcu_batches_completed_sched(void)
106138 {
107139 return 0;
108140 }
@@ -154,7 +186,10 @@ static inline bool rcu_is_watching(void) · 45 unmodified lines
154186 return true;
155187 }
156188
157−
158189 #endif /* #else defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) */
159190
191+static inline void rcu_all_qs(void)
192+{
193+}
194+
160195 #endif /* __LINUX_RCUTINY_H */
include/linux/rcutree.h+8−3
@@ -81,9 +81,12 @@ void cond_synchronize_rcu(unsigned long oldstate); · 80 unmodified lines
8181
8282 extern unsigned long rcutorture_testseq;
8383 extern unsigned long rcutorture_vernum;
84−long rcu_batches_completed(void);
85−long rcu_batches_completed_bh(void);
86−long rcu_batches_completed_sched(void);
84+unsigned long rcu_batches_started(void);
85+unsigned long rcu_batches_started_bh(void);
86+unsigned long rcu_batches_started_sched(void);
87+unsigned long rcu_batches_completed(void);
88+unsigned long rcu_batches_completed_bh(void);
89+unsigned long rcu_batches_completed_sched(void);
8790 void show_rcu_gp_kthreads(void);
8891
8992 void rcu_force_quiescent_state(void);
@@ -97,4 +100,6 @@ extern int rcu_scheduler_active __read_mostly; · 7 unmodified lines
97100
98101 bool rcu_is_watching(void);
99102
103+void rcu_all_qs(void);
104+
100105 #endif /* __LINUX_RCUTREE_H */
include/linux/srcu.h+6−8
@@ -45,7 +45,7 @@ struct rcu_batch { · 44 unmodified lines
4545 #define RCU_BATCH_INIT(name) { NULL, &(name.head) }
4646
4747 struct srcu_struct {
48− unsigned completed;
48+ unsigned long completed;
4949 struct srcu_struct_array __percpu *per_cpu_ref;
5050 spinlock_t queue_lock; /* protect ->batch_queue, ->running */
5151 bool running;
@@ -102,13 +102,11 @@ void process_srcu(struct work_struct *work); · 50 unmodified lines
102102 * define and init a srcu struct at build time.
103103 * dont't call init_srcu_struct() nor cleanup_srcu_struct() on it.
104104 */
105−#define DEFINE_SRCU(name) \
105+#define __DEFINE_SRCU(name, is_static) \
106106 static DEFINE_PER_CPU(struct srcu_struct_array, name##_srcu_array);\
107− struct srcu_struct name = __SRCU_STRUCT_INIT(name);
108−
109−#define DEFINE_STATIC_SRCU(name) \
110− static DEFINE_PER_CPU(struct srcu_struct_array, name##_srcu_array);\
111− static struct srcu_struct name = __SRCU_STRUCT_INIT(name);
107+ is_static struct srcu_struct name = __SRCU_STRUCT_INIT(name)
108+#define DEFINE_SRCU(name) __DEFINE_SRCU(name, /* not static */)
109+#define DEFINE_STATIC_SRCU(name) __DEFINE_SRCU(name, static)
112110
113111 /**
114112 * call_srcu() - Queue a callback for invocation after an SRCU grace period
@@ -135,7 +133,7 @@ int __srcu_read_lock(struct srcu_struct *sp) __acquires(sp); · 20 unmodified lines
135133 void __srcu_read_unlock(struct srcu_struct *sp, int idx) __releases(sp);
136134 void synchronize_srcu(struct srcu_struct *sp);
137135 void synchronize_srcu_expedited(struct srcu_struct *sp);
138−long srcu_batches_completed(struct srcu_struct *sp);
136+unsigned long srcu_batches_completed(struct srcu_struct *sp);
139137 void srcu_barrier(struct srcu_struct *sp);
140138
141139 #ifdef CONFIG_DEBUG_LOCK_ALLOC
init/Kconfig+13−5
@@ -470,7 +470,6 @@ choice · 469 unmodified lines
470470 config TREE_RCU
471471 bool "Tree-based hierarchical RCU"
472472 depends on !PREEMPT && SMP
473− select IRQ_WORK
474473 help
475474 This option selects the RCU implementation that is
476475 designed for very large SMP system with hundreds or
@@ -480,7 +479,6 @@ config TREE_RCU · 3 unmodified lines
480479 config PREEMPT_RCU
481480 bool "Preemptible tree-based hierarchical RCU"
482481 depends on PREEMPT
483− select IRQ_WORK
484482 help
485483 This option selects the RCU implementation that is
486484 designed for very large SMP systems with hundreds or
@@ -501,9 +499,17 @@ config TINY_RCU · 14 unmodified lines
501499
502500 endchoice
503501
502+config SRCU
503+ bool
504+ help
505+ This option selects the sleepable version of RCU. This version
506+ permits arbitrary sleeping or blocking within RCU read-side critical
507+ sections.
508+
504509 config TASKS_RCU
505510 bool "Task_based RCU implementation using voluntary context switch"
506511 default n
512+ select SRCU
507513 help
508514 This option enables a task-based RCU implementation that uses
509515 only voluntary context switch (not preemption!), idle, and
@@ -668,9 +674,10 @@ config RCU_BOOST · 158 unmodified lines
668674
669675 config RCU_KTHREAD_PRIO
670676 int "Real-time priority to use for RCU worker threads"
671− range 1 99
672− depends on RCU_BOOST
673− default 1
677+ range 1 99 if RCU_BOOST
678+ range 0 99 if !RCU_BOOST
679+ default 1 if RCU_BOOST
680+ default 0 if !RCU_BOOST
674681 help
675682 This option specifies the SCHED_FIFO priority value that will be
676683 assigned to the rcuc/n and rcub/n threads and is also the value
@@ -1595,6 +1602,7 @@ config PERF_EVENTS · 918 unmodified lines
15951602 depends on HAVE_PERF_EVENTS
15961603 select ANON_INODES
15971604 select IRQ_WORK
1605+ select SRCU
15981606 help
15991607 Enable kernel support for various performance events provided
16001608 by software and hardware.
kernel/cpu.c+23−33
@@ -58,22 +58,23 @@ static int cpu_hotplug_disabled; · 57 unmodified lines
5858
5959 static struct {
6060 struct task_struct *active_writer;
61− struct mutex lock; /* Synchronizes accesses to refcount, */
61+ /* wait queue to wake up the active_writer */
62+ wait_queue_head_t wq;
63+ /* verifies that no writer will get active while readers are active */
64+ struct mutex lock;
6265 /*
6366 * Also blocks the new readers during
6467 * an ongoing cpu hotplug operation.
6568 */
66− int refcount;
67− /* And allows lockless put_online_cpus(). */
68− atomic_t puts_pending;
69+ atomic_t refcount;
6970
7071 #ifdef CONFIG_DEBUG_LOCK_ALLOC
7172 struct lockdep_map dep_map;
7273 #endif
7374 } cpu_hotplug = {
7475 .active_writer = NULL,
76+ .wq = __WAIT_QUEUE_HEAD_INITIALIZER(cpu_hotplug.wq),
7577 .lock = __MUTEX_INITIALIZER(cpu_hotplug.lock),
76− .refcount = 0,
7778 #ifdef CONFIG_DEBUG_LOCK_ALLOC
7879 .dep_map = {.name = "cpu_hotplug.lock" },
7980 #endif
@@ -86,15 +87,6 @@ static struct { · 6 unmodified lines
8687 #define cpuhp_lock_acquire() lock_map_acquire(&cpu_hotplug.dep_map)
8788 #define cpuhp_lock_release() lock_map_release(&cpu_hotplug.dep_map)
8889
89−static void apply_puts_pending(int max)
90−{
91− int delta;
92−
93− if (atomic_read(&cpu_hotplug.puts_pending) >= max) {
94− delta = atomic_xchg(&cpu_hotplug.puts_pending, 0);
95− cpu_hotplug.refcount -= delta;
96− }
97−}
9890
9991 void get_online_cpus(void)
10092 {
@@ -103,8 +95,7 @@ void get_online_cpus(void) · 2 unmodified lines
10395 return;
10496 cpuhp_lock_acquire_read();
10597 mutex_lock(&cpu_hotplug.lock);
106− apply_puts_pending(65536);
107− cpu_hotplug.refcount++;
98+ atomic_inc(&cpu_hotplug.refcount);
10899 mutex_unlock(&cpu_hotplug.lock);
109100 }
110101 EXPORT_SYMBOL_GPL(get_online_cpus);
@@ -116,8 +107,7 @@ bool try_get_online_cpus(void) · 5 unmodified lines
116107 if (!mutex_trylock(&cpu_hotplug.lock))
117108 return false;
118109 cpuhp_lock_acquire_tryread();
119− apply_puts_pending(65536);
120− cpu_hotplug.refcount++;
110+ atomic_inc(&cpu_hotplug.refcount);
121111 mutex_unlock(&cpu_hotplug.lock);
122112 return true;
123113 }
@@ -125,20 +115,18 @@ EXPORT_SYMBOL_GPL(try_get_online_cpus); · 1 unmodified line
125115
126116 void put_online_cpus(void)
127117 {
118+ int refcount;
119+
128120 if (cpu_hotplug.active_writer == current)
129121 return;
130− if (!mutex_trylock(&cpu_hotplug.lock)) {
131− atomic_inc(&cpu_hotplug.puts_pending);
132− cpuhp_lock_release();
133− return;
134− }
135122
136− if (WARN_ON(!cpu_hotplug.refcount))
137− cpu_hotplug.refcount++; /* try to fix things up */
123+ refcount = atomic_dec_return(&cpu_hotplug.refcount);
124+ if (WARN_ON(refcount < 0)) /* try to fix things up */
125+ atomic_inc(&cpu_hotplug.refcount);
126+
127+ if (refcount <= 0 && waitqueue_active(&cpu_hotplug.wq))
128+ wake_up(&cpu_hotplug.wq);
138129
139− if (!--cpu_hotplug.refcount && unlikely(cpu_hotplug.active_writer))
140− wake_up_process(cpu_hotplug.active_writer);
141− mutex_unlock(&cpu_hotplug.lock);
142130 cpuhp_lock_release();
143131
144132 }
@@ -168,18 +156,20 @@ EXPORT_SYMBOL_GPL(put_online_cpus); · 23 unmodified lines
168156 */
169157 void cpu_hotplug_begin(void)
170158 {
171− cpu_hotplug.active_writer = current;
159+ DEFINE_WAIT(wait);
172160
161+ cpu_hotplug.active_writer = current;
173162 cpuhp_lock_acquire();
163+
174164 for (;;) {
175165 mutex_lock(&cpu_hotplug.lock);
176− apply_puts_pending(1);
177− if (likely(!cpu_hotplug.refcount))
178− break;
179− __set_current_state(TASK_UNINTERRUPTIBLE);
166+ prepare_to_wait(&cpu_hotplug.wq, &wait, TASK_UNINTERRUPTIBLE);
167+ if (likely(!atomic_read(&cpu_hotplug.refcount)))
168+ break;
180169 mutex_unlock(&cpu_hotplug.lock);
181170 schedule();
182171 }
172+ finish_wait(&cpu_hotplug.wq, &wait);
183173 }
184174
185175 void cpu_hotplug_done(void)
kernel/notifier.c+3−0
@@ -402,6 +402,7 @@ int raw_notifier_call_chain(struct raw_notifier_head *nh, · 401 unmodified lines
402402 }
403403 EXPORT_SYMBOL_GPL(raw_notifier_call_chain);
404404
405+#ifdef CONFIG_SRCU
405406 /*
406407 * SRCU notifier chain routines. Registration and unregistration
407408 * use a mutex, and call_chain is synchronized by SRCU (no locks).
@@ -528,6 +529,8 @@ void srcu_init_notifier_head(struct srcu_notifier_head *nh) · 120 unmodified lines
528529 }
529530 EXPORT_SYMBOL_GPL(srcu_init_notifier_head);
530531
532+#endif /* CONFIG_SRCU */
533+
531534 static ATOMIC_NOTIFIER_HEAD(die_chain);
532535
533536 int notrace notify_die(enum die_val val, const char *str,
kernel/power/Kconfig+1−0
@@ -251,6 +251,7 @@ config APM_EMULATION · 250 unmodified lines
251251
252252 config PM_OPP
253253 bool
254+ select SRCU
254255 ---help---
255256 SOCs have a standard set of tuples consisting of frequency and
256257 voltage pairs that the device will support per voltage domain. This
kernel/rcu/Makefile+2−1
@@ -1,4 +1,5 @@
1−obj-y += update.o srcu.o
1+obj-y += update.o
2+obj-$(CONFIG_SRCU) += srcu.o
23 obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
34 obj-$(CONFIG_TREE_RCU) += tree.o
45 obj-$(CONFIG_PREEMPT_RCU) += tree.o
kernel/rcu/rcu.h+6−0
@@ -137,4 +137,10 @@ int rcu_jiffies_till_stall_check(void); · 136 unmodified lines
137137
138138 void rcu_early_boot_tests(void);
139139
140+/*
141+ * This function really isn't for public consumption, but RCU is special in
142+ * that context switches can allow the state machine to make progress.
143+ */
144+extern void resched_cpu(int cpu);
145+
140146 #endif /* __LINUX_RCU_H */
kernel/rcu/rcutorture.c+38−28
@@ -244,7 +244,8 @@ struct rcu_torture_ops { · 243 unmodified lines
244244 int (*readlock)(void);
245245 void (*read_delay)(struct torture_random_state *rrsp);
246246 void (*readunlock)(int idx);
247− int (*completed)(void);
247+ unsigned long (*started)(void);
248+ unsigned long (*completed)(void);
248249 void (*deferred_free)(struct rcu_torture *p);
249250 void (*sync)(void);
250251 void (*exp_sync)(void);
@@ -296,11 +297,6 @@ static void rcu_torture_read_unlock(int idx) __releases(RCU) · 45 unmodified lines
296297 rcu_read_unlock();
297298 }
298299
299−static int rcu_torture_completed(void)
300−{
301− return rcu_batches_completed();
302−}
303−
304300 /*
305301 * Update callback in the pipe. This should be invoked after a grace period.
306302 */
@@ -356,7 +352,7 @@ rcu_torture_cb(struct rcu_head *p) · 49 unmodified lines
356352 cur_ops->deferred_free(rp);
357353 }
358354
359−static int rcu_no_completed(void)
355+static unsigned long rcu_no_completed(void)
360356 {
361357 return 0;
362358 }
@@ -377,7 +373,8 @@ static struct rcu_torture_ops rcu_ops = { · 14 unmodified lines
377373 .readlock = rcu_torture_read_lock,
378374 .read_delay = rcu_read_delay,
379375 .readunlock = rcu_torture_read_unlock,
380− .completed = rcu_torture_completed,
376+ .started = rcu_batches_started,
377+ .completed = rcu_batches_completed,
381378 .deferred_free = rcu_torture_deferred_free,
382379 .sync = synchronize_rcu,
383380 .exp_sync = synchronize_rcu_expedited,
@@ -407,11 +404,6 @@ static void rcu_bh_torture_read_unlock(int idx) __releases(RCU_BH) · 23 unmodified lines
407404 rcu_read_unlock_bh();
408405 }
409406
410−static int rcu_bh_torture_completed(void)
411−{
412− return rcu_batches_completed_bh();
413−}
414−
415407 static void rcu_bh_torture_deferred_free(struct rcu_torture *p)
416408 {
417409 call_rcu_bh(&p->rtort_rcu, rcu_torture_cb);
@@ -423,7 +415,8 @@ static struct rcu_torture_ops rcu_bh_ops = { · 5 unmodified lines
423415 .readlock = rcu_bh_torture_read_lock,
424416 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
425417 .readunlock = rcu_bh_torture_read_unlock,
426− .completed = rcu_bh_torture_completed,
418+ .started = rcu_batches_started_bh,
419+ .completed = rcu_batches_completed_bh,
427420 .deferred_free = rcu_bh_torture_deferred_free,
428421 .sync = synchronize_rcu_bh,
429422 .exp_sync = synchronize_rcu_bh_expedited,
@@ -466,6 +459,7 @@ static struct rcu_torture_ops rcu_busted_ops = { · 36 unmodified lines
466459 .readlock = rcu_torture_read_lock,
467460 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
468461 .readunlock = rcu_torture_read_unlock,
462+ .started = rcu_no_completed,
469463 .completed = rcu_no_completed,
470464 .deferred_free = rcu_busted_torture_deferred_free,
471465 .sync = synchronize_rcu_busted,
@@ -510,7 +504,7 @@ static void srcu_torture_read_unlock(int idx) __releases(&srcu_ctl) · 38 unmodified lines
510504 srcu_read_unlock(&srcu_ctl, idx);
511505 }
512506
513−static int srcu_torture_completed(void)
507+static unsigned long srcu_torture_completed(void)
514508 {
515509 return srcu_batches_completed(&srcu_ctl);
516510 }
@@ -564,6 +558,7 @@ static struct rcu_torture_ops srcu_ops = { · 47 unmodified lines
564558 .readlock = srcu_torture_read_lock,
565559 .read_delay = srcu_read_delay,
566560 .readunlock = srcu_torture_read_unlock,
561+ .started = NULL,
567562 .completed = srcu_torture_completed,
568563 .deferred_free = srcu_torture_deferred_free,
569564 .sync = srcu_torture_synchronize,
@@ -600,7 +595,8 @@ static struct rcu_torture_ops sched_ops = { · 30 unmodified lines
600595 .readlock = sched_torture_read_lock,
601596 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
602597 .readunlock = sched_torture_read_unlock,
603− .completed = rcu_no_completed,
598+ .started = rcu_batches_started_sched,
599+ .completed = rcu_batches_completed_sched,
604600 .deferred_free = rcu_sched_torture_deferred_free,
605601 .sync = synchronize_sched,
606602 .exp_sync = synchronize_sched_expedited,
@@ -638,6 +634,7 @@ static struct rcu_torture_ops tasks_ops = { · 31 unmodified lines
638634 .readlock = tasks_torture_read_lock,
639635 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
640636 .readunlock = tasks_torture_read_unlock,
637+ .started = rcu_no_completed,
641638 .completed = rcu_no_completed,
642639 .deferred_free = rcu_tasks_torture_deferred_free,
643640 .sync = synchronize_rcu_tasks,
@@ -1015,8 +1012,8 @@ static void rcutorture_trace_dump(void) · 371 unmodified lines
10151012 static void rcu_torture_timer(unsigned long unused)
10161013 {
10171014 int idx;
1018− int completed;
1019− int completed_end;
1015+ unsigned long started;
1016+ unsigned long completed;
10201017 static DEFINE_TORTURE_RANDOM(rand);
10211018 static DEFINE_SPINLOCK(rand_lock);
10221019 struct rcu_torture *p;
@@ -1024,7 +1021,10 @@ static void rcu_torture_timer(unsigned long unused) · 1 unmodified line
10241021 unsigned long long ts;
10251022
10261023 idx = cur_ops->readlock();
1027− completed = cur_ops->completed();
1024+ if (cur_ops->started)
1025+ started = cur_ops->started();
1026+ else
1027+ started = cur_ops->completed();
10281028 ts = rcu_trace_clock_local();
10291029 p = rcu_dereference_check(rcu_torture_current,
10301030 rcu_read_lock_bh_held() ||
@@ -1047,14 +1047,16 @@ static void rcu_torture_timer(unsigned long unused) · 16 unmodified lines
10471047 /* Should not happen, but... */
10481048 pipe_count = RCU_TORTURE_PIPE_LEN;
10491049 }
1050− completed_end = cur_ops->completed();
1050+ completed = cur_ops->completed();
10511051 if (pipe_count > 1) {
10521052 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu, ts,
1053− completed, completed_end);
1053+ started, completed);
10541054 rcutorture_trace_dump();
10551055 }
10561056 __this_cpu_inc(rcu_torture_count[pipe_count]);
1057− completed = completed_end - completed;
1057+ completed = completed - started;
1058+ if (cur_ops->started)
1059+ completed++;
10581060 if (completed > RCU_TORTURE_PIPE_LEN) {
10591061 /* Should not happen, but... */
10601062 completed = RCU_TORTURE_PIPE_LEN;
@@ -1073,8 +1075,8 @@ static void rcu_torture_timer(unsigned long unused) · 12 unmodified lines
10731075 static int
10741076 rcu_torture_reader(void *arg)
10751077 {
1076− int completed;
1077− int completed_end;
1078+ unsigned long started;
1079+ unsigned long completed;
10781080 int idx;
10791081 DEFINE_TORTURE_RANDOM(rand);
10801082 struct rcu_torture *p;
@@ -1093,7 +1095,10 @@ rcu_torture_reader(void *arg) · 12 unmodified lines
10931095 mod_timer(&t, jiffies + 1);
10941096 }
10951097 idx = cur_ops->readlock();
1096− completed = cur_ops->completed();
1098+ if (cur_ops->started)
1099+ started = cur_ops->started();
1100+ else
1101+ started = cur_ops->completed();
10971102 ts = rcu_trace_clock_local();
10981103 p = rcu_dereference_check(rcu_torture_current,
10991104 rcu_read_lock_bh_held() ||
@@ -1114,14 +1119,16 @@ rcu_torture_reader(void *arg) · 14 unmodified lines
11141119 /* Should not happen, but... */
11151120 pipe_count = RCU_TORTURE_PIPE_LEN;
11161121 }
1117− completed_end = cur_ops->completed();
1122+ completed = cur_ops->completed();
11181123 if (pipe_count > 1) {
11191124 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu,
1120− ts, completed, completed_end);
1125+ ts, started, completed);
11211126 rcutorture_trace_dump();
11221127 }
11231128 __this_cpu_inc(rcu_torture_count[pipe_count]);
1124− completed = completed_end - completed;
1129+ completed = completed - started;
1130+ if (cur_ops->started)
1131+ completed++;
11251132 if (completed > RCU_TORTURE_PIPE_LEN) {
11261133 /* Should not happen, but... */
11271134 completed = RCU_TORTURE_PIPE_LEN;
@@ -1420,6 +1427,9 @@ static int rcu_torture_barrier(void *arg) · 292 unmodified lines
14201427 cur_ops->cb_barrier(); /* Implies smp_mb() for wait_event(). */
14211428 if (atomic_read(&barrier_cbs_invoked) != n_barrier_cbs) {
14221429 n_rcu_torture_barrier_error++;
1430+ pr_err("barrier_cbs_invoked = %d, n_barrier_cbs = %d\n",
1431+ atomic_read(&barrier_cbs_invoked),
1432+ n_barrier_cbs);
14231433 WARN_ON_ONCE(1);
14241434 }
14251435 n_barrier_successes++;
kernel/rcu/srcu.c+1−1
@@ -546,7 +546,7 @@ EXPORT_SYMBOL_GPL(srcu_barrier); · 545 unmodified lines
546546 * Report the number of batches, correlated with, but not necessarily
547547 * precisely the same as, the number of grace periods that have elapsed.
548548 */
549−long srcu_batches_completed(struct srcu_struct *sp)
549+unsigned long srcu_batches_completed(struct srcu_struct *sp)
550550 {
551551 return sp->completed;
552552 }
kernel/rcu/tiny.c+10−103
@@ -47,54 +47,14 @@ static void __call_rcu(struct rcu_head *head, · 46 unmodified lines
4747 void (*func)(struct rcu_head *rcu),
4848 struct rcu_ctrlblk *rcp);
4949
50−static long long rcu_dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
51−
5250 #include "tiny_plugin.h"
5351
54−/* Common code for rcu_idle_enter() and rcu_irq_exit(), see kernel/rcu/tree.c. */
55−static void rcu_idle_enter_common(long long newval)
56−{
57− if (newval) {
58− RCU_TRACE(trace_rcu_dyntick(TPS("--="),
59− rcu_dynticks_nesting, newval));
60− rcu_dynticks_nesting = newval;
61− return;
62− }
63− RCU_TRACE(trace_rcu_dyntick(TPS("Start"),
64− rcu_dynticks_nesting, newval));
65− if (IS_ENABLED(CONFIG_RCU_TRACE) && !is_idle_task(current)) {
66− struct task_struct *idle __maybe_unused = idle_task(smp_processor_id());
67−
68− RCU_TRACE(trace_rcu_dyntick(TPS("Entry error: not idle task"),
69− rcu_dynticks_nesting, newval));
70− ftrace_dump(DUMP_ALL);
71− WARN_ONCE(1, "Current pid: %d comm: %s / Idle pid: %d comm: %s",
72− current->pid, current->comm,
73− idle->pid, idle->comm); /* must be idle task! */
74− }
75− rcu_sched_qs(); /* implies rcu_bh_inc() */
76− barrier();
77− rcu_dynticks_nesting = newval;
78−}
79−
8052 /*
8153 * Enter idle, which is an extended quiescent state if we have fully
82− * entered that mode (i.e., if the new value of dynticks_nesting is zero).
54+ * entered that mode.
8355 */
8456 void rcu_idle_enter(void)
8557 {
86− unsigned long flags;
87− long long newval;
88−
89− local_irq_save(flags);
90− WARN_ON_ONCE((rcu_dynticks_nesting & DYNTICK_TASK_NEST_MASK) == 0);
91− if ((rcu_dynticks_nesting & DYNTICK_TASK_NEST_MASK) ==
92− DYNTICK_TASK_NEST_VALUE)
93− newval = 0;
94− else
95− newval = rcu_dynticks_nesting - DYNTICK_TASK_NEST_VALUE;
96− rcu_idle_enter_common(newval);
97− local_irq_restore(flags);
9858 }
9959 EXPORT_SYMBOL_GPL(rcu_idle_enter);
10060
@@ -103,55 +63,14 @@ EXPORT_SYMBOL_GPL(rcu_idle_enter); · 2 unmodified lines
10363 */
10464 void rcu_irq_exit(void)
10565 {
106− unsigned long flags;
107− long long newval;
108−
109− local_irq_save(flags);
110− newval = rcu_dynticks_nesting - 1;
111− WARN_ON_ONCE(newval < 0);
112− rcu_idle_enter_common(newval);
113− local_irq_restore(flags);
11466 }
11567 EXPORT_SYMBOL_GPL(rcu_irq_exit);
11668
117−/* Common code for rcu_idle_exit() and rcu_irq_enter(), see kernel/rcu/tree.c. */
118−static void rcu_idle_exit_common(long long oldval)
119−{
120− if (oldval) {
121− RCU_TRACE(trace_rcu_dyntick(TPS("++="),
122− oldval, rcu_dynticks_nesting));
123− return;
124− }
125− RCU_TRACE(trace_rcu_dyntick(TPS("End"), oldval, rcu_dynticks_nesting));
126− if (IS_ENABLED(CONFIG_RCU_TRACE) && !is_idle_task(current)) {
127− struct task_struct *idle __maybe_unused = idle_task(smp_processor_id());
128−
129− RCU_TRACE(trace_rcu_dyntick(TPS("Exit error: not idle task"),
130− oldval, rcu_dynticks_nesting));
131− ftrace_dump(DUMP_ALL);
132− WARN_ONCE(1, "Current pid: %d comm: %s / Idle pid: %d comm: %s",
133− current->pid, current->comm,
134− idle->pid, idle->comm); /* must be idle task! */
135− }
136−}
137−
13869 /*
13970 * Exit idle, so that we are no longer in an extended quiescent state.
14071 */
14172 void rcu_idle_exit(void)
14273 {
143− unsigned long flags;
144− long long oldval;
145−
146− local_irq_save(flags);
147− oldval = rcu_dynticks_nesting;
148− WARN_ON_ONCE(rcu_dynticks_nesting < 0);
149− if (rcu_dynticks_nesting & DYNTICK_TASK_NEST_MASK)
150− rcu_dynticks_nesting += DYNTICK_TASK_NEST_VALUE;
151− else
152− rcu_dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
153− rcu_idle_exit_common(oldval);
154− local_irq_restore(flags);
15574 }
15675 EXPORT_SYMBOL_GPL(rcu_idle_exit);
15776
@@ -160,15 +79,6 @@ EXPORT_SYMBOL_GPL(rcu_idle_exit); · 2 unmodified lines
16079 */
16180 void rcu_irq_enter(void)
16281 {
163− unsigned long flags;
164− long long oldval;
165−
166− local_irq_save(flags);
167− oldval = rcu_dynticks_nesting;
168− rcu_dynticks_nesting++;
169− WARN_ON_ONCE(rcu_dynticks_nesting == 0);
170− rcu_idle_exit_common(oldval);
171− local_irq_restore(flags);
17282 }
17383 EXPORT_SYMBOL_GPL(rcu_irq_enter);
17484
@@ -179,22 +89,12 @@ EXPORT_SYMBOL_GPL(rcu_irq_enter); · 4 unmodified lines
17989 */
18090 bool notrace __rcu_is_watching(void)
18191 {
182− return rcu_dynticks_nesting;
92+ return true;
18393 }
18494 EXPORT_SYMBOL(__rcu_is_watching);
18595
18696 #endif /* defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) */
18797
188−/*
189− * Test whether the current CPU was interrupted from idle. Nested
190− * interrupts don't count, we must be running at the first interrupt
191− * level.
192− */
193−static int rcu_is_cpu_rrupt_from_idle(void)
194−{
195− return rcu_dynticks_nesting <= 1;
196−}
197−
19898 /*
19999 * Helper function for rcu_sched_qs() and rcu_bh_qs().
200100 * Also irqs are disabled to avoid confusion due to interrupt handlers
@@ -250,7 +150,7 @@ void rcu_bh_qs(void) · 49 unmodified lines
250150 void rcu_check_callbacks(int user)
251151 {
252152 RCU_TRACE(check_cpu_stalls());
253− if (user || rcu_is_cpu_rrupt_from_idle())
153+ if (user)
254154 rcu_sched_qs();
255155 else if (!in_softirq())
256156 rcu_bh_qs();
@@ -357,6 +257,11 @@ static void __call_rcu(struct rcu_head *head, · 100 unmodified lines
357257 rcp->curtail = &head->next;
358258 RCU_TRACE(rcp->qlen++);
359259 local_irq_restore(flags);
260+
261+ if (unlikely(is_idle_task(current))) {
262+ /* force scheduling for rcu_sched_qs() */
263+ resched_cpu(0);
264+ }
360265 }
361266
362267 /*
@@ -383,6 +288,8 @@ EXPORT_SYMBOL_GPL(call_rcu_bh); · 20 unmodified lines
383288 void __init rcu_init(void)
384289 {
385290 open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
291+ RCU_TRACE(reset_cpu_stall_ticks(&rcu_sched_ctrlblk));
292+ RCU_TRACE(reset_cpu_stall_ticks(&rcu_bh_ctrlblk));
386293
387294 rcu_early_boot_tests();
388295 }
kernel/rcu/tiny_plugin.h+4−5
@@ -145,17 +145,16 @@ static void check_cpu_stall(struct rcu_ctrlblk *rcp) · 144 unmodified lines
145145 rcp->ticks_this_gp++;
146146 j = jiffies;
147147 js = ACCESS_ONCE(rcp->jiffies_stall);
148− if (*rcp->curtail && ULONG_CMP_GE(j, js)) {
148+ if (rcp->rcucblist && ULONG_CMP_GE(j, js)) {
149149 pr_err("INFO: %s stall on CPU (%lu ticks this GP) idle=%llx (t=%lu jiffies q=%ld)\n",
150− rcp->name, rcp->ticks_this_gp, rcu_dynticks_nesting,
150+ rcp->name, rcp->ticks_this_gp, DYNTICK_TASK_EXIT_IDLE,
151151 jiffies - rcp->gp_start, rcp->qlen);
152152 dump_stack();
153− }
154− if (*rcp->curtail && ULONG_CMP_GE(j, js))
155153 ACCESS_ONCE(rcp->jiffies_stall) = jiffies +
156154 3 * rcu_jiffies_till_stall_check() + 3;
157− else if (ULONG_CMP_GE(j, js))
155+ } else if (ULONG_CMP_GE(j, js)) {
158156 ACCESS_ONCE(rcp->jiffies_stall) = jiffies + rcu_jiffies_till_stall_check();
157+ }
159158 }
160159
161160 static void reset_cpu_stall_ticks(struct rcu_ctrlblk *rcp)
kernel/rcu/tree.c+209−80
@@ -156,6 +156,10 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) · 155 unmodified lines
156156 static void invoke_rcu_core(void);
157157 static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp);
158158
159+/* rcuc/rcub kthread realtime priority */
160+static int kthread_prio = CONFIG_RCU_KTHREAD_PRIO;
161+module_param(kthread_prio, int, 0644);
162+
159163 /*
160164 * Track the rcutorture test sequence number and the update version
161165 * number within a given test. The rcutorture_testseq is incremented
@@ -215,6 +219,9 @@ static DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = { · 53 unmodified lines
215219 #endif /* #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */
216220 };
217221
222+DEFINE_PER_CPU_SHARED_ALIGNED(unsigned long, rcu_qs_ctr);
223+EXPORT_PER_CPU_SYMBOL_GPL(rcu_qs_ctr);
224+
218225 /*
219226 * Let the RCU core know that this CPU has gone through the scheduler,
220227 * which is a quiescent state. This is called when the need for a
@@ -284,6 +291,22 @@ void rcu_note_context_switch(void) · 63 unmodified lines
284291 }
285292 EXPORT_SYMBOL_GPL(rcu_note_context_switch);
286293
294+/*
295+ * Register a quiesecent state for all RCU flavors. If there is an
296+ * emergency, invoke rcu_momentary_dyntick_idle() to do a heavy-weight
297+ * dyntick-idle quiescent state visible to other CPUs (but only for those
298+ * RCU flavors in desparate need of a quiescent state, which will normally
299+ * be none of them). Either way, do a lightweight quiescent state for
300+ * all RCU flavors.
301+ */
302+void rcu_all_qs(void)
303+{
304+ if (unlikely(raw_cpu_read(rcu_sched_qs_mask)))
305+ rcu_momentary_dyntick_idle();
306+ this_cpu_inc(rcu_qs_ctr);
307+}
308+EXPORT_SYMBOL_GPL(rcu_all_qs);
309+
287310 static long blimit = 10; /* Maximum callbacks per rcu_do_batch. */
288311 static long qhimark = 10000; /* If this many pending, ignore blimit. */
289312 static long qlowmark = 100; /* Once only this many pending, use blimit. */
@@ -315,18 +338,54 @@ static void force_quiescent_state(struct rcu_state *rsp); · 25 unmodified lines
315338 static int rcu_pending(void);
316339
317340 /*
318− * Return the number of RCU-sched batches processed thus far for debug & stats.
341+ * Return the number of RCU batches started thus far for debug & stats.
342+ */
343+unsigned long rcu_batches_started(void)
344+{
345+ return rcu_state_p->gpnum;
346+}
347+EXPORT_SYMBOL_GPL(rcu_batches_started);
348+
349+/*
350+ * Return the number of RCU-sched batches started thus far for debug & stats.
319351 */
320−long rcu_batches_completed_sched(void)
352+unsigned long rcu_batches_started_sched(void)
353+{
354+ return rcu_sched_state.gpnum;
355+}
356+EXPORT_SYMBOL_GPL(rcu_batches_started_sched);
357+
358+/*
359+ * Return the number of RCU BH batches started thus far for debug & stats.
360+ */
361+unsigned long rcu_batches_started_bh(void)
362+{
363+ return rcu_bh_state.gpnum;
364+}
365+EXPORT_SYMBOL_GPL(rcu_batches_started_bh);
366+
367+/*
368+ * Return the number of RCU batches completed thus far for debug & stats.
369+ */
370+unsigned long rcu_batches_completed(void)
371+{
372+ return rcu_state_p->completed;
373+}
374+EXPORT_SYMBOL_GPL(rcu_batches_completed);
375+
376+/*
377+ * Return the number of RCU-sched batches completed thus far for debug & stats.
378+ */
379+unsigned long rcu_batches_completed_sched(void)
321380 {
322381 return rcu_sched_state.completed;
323382 }
324383 EXPORT_SYMBOL_GPL(rcu_batches_completed_sched);
325384
326385 /*
327− * Return the number of RCU BH batches processed thus far for debug & stats.
386+ * Return the number of RCU BH batches completed thus far for debug & stats.
328387 */
329−long rcu_batches_completed_bh(void)
388+unsigned long rcu_batches_completed_bh(void)
330389 {
331390 return rcu_bh_state.completed;
332391 }
@@ -930,16 +989,13 @@ static int dyntick_save_progress_counter(struct rcu_data *rdp, · 597 unmodified lines
930989 trace_rcu_fqs(rdp->rsp->name, rdp->gpnum, rdp->cpu, TPS("dti"));
931990 return 1;
932991 } else {
992+ if (ULONG_CMP_LT(ACCESS_ONCE(rdp->gpnum) + ULONG_MAX / 4,
993+ rdp->mynode->gpnum))
994+ ACCESS_ONCE(rdp->gpwrap) = true;
933995 return 0;
934996 }
935997 }
936998
937−/*
938− * This function really isn't for public consumption, but RCU is special in
939− * that context switches can allow the state machine to make progress.
940− */
941−extern void resched_cpu(int cpu);
942−
943999 /*
9441000 * Return true if the specified CPU has passed through a quiescent
9451001 * state by virtue of being in or having passed through an dynticks
@@ -1043,6 +1099,22 @@ static void record_gp_stall_check_time(struct rcu_state *rsp) · 97 unmodified lines
10431099 j1 = rcu_jiffies_till_stall_check();
10441100 ACCESS_ONCE(rsp->jiffies_stall) = j + j1;
10451101 rsp->jiffies_resched = j + j1 / 2;
1102+ rsp->n_force_qs_gpstart = ACCESS_ONCE(rsp->n_force_qs);
1103+}
1104+
1105+/*
1106+ * Complain about starvation of grace-period kthread.
1107+ */
1108+static void rcu_check_gp_kthread_starvation(struct rcu_state *rsp)
1109+{
1110+ unsigned long gpa;
1111+ unsigned long j;
1112+
1113+ j = jiffies;
1114+ gpa = ACCESS_ONCE(rsp->gp_activity);
1115+ if (j - gpa > 2 * HZ)
1116+ pr_err("%s kthread starved for %ld jiffies!\n",
1117+ rsp->name, j - gpa);
10461118 }
10471119
10481120 /*
@@ -1065,11 +1137,13 @@ static void rcu_dump_cpu_stacks(struct rcu_state *rsp) · 16 unmodified lines
10651137 }
10661138 }
10671139
1068−static void print_other_cpu_stall(struct rcu_state *rsp)
1140+static void print_other_cpu_stall(struct rcu_state *rsp, unsigned long gpnum)
10691141 {
10701142 int cpu;
10711143 long delta;
10721144 unsigned long flags;
1145+ unsigned long gpa;
1146+ unsigned long j;
10731147 int ndetected = 0;
10741148 struct rcu_node *rnp = rcu_get_root(rsp);
10751149 long totqlen = 0;
@@ -1107,30 +1181,34 @@ static void print_other_cpu_stall(struct rcu_state *rsp) · 31 unmodified lines
11071181 raw_spin_unlock_irqrestore(&rnp->lock, flags);
11081182 }
11091183
1110− /*
1111− * Now rat on any tasks that got kicked up to the root rcu_node
1112− * due to CPU offlining.
1113− */
1114− rnp = rcu_get_root(rsp);
1115− raw_spin_lock_irqsave(&rnp->lock, flags);
1116− ndetected += rcu_print_task_stall(rnp);
1117− raw_spin_unlock_irqrestore(&rnp->lock, flags);
1118−
11191184 print_cpu_stall_info_end();
11201185 for_each_possible_cpu(cpu)
11211186 totqlen += per_cpu_ptr(rsp->rda, cpu)->qlen;
11221187 pr_cont("(detected by %d, t=%ld jiffies, g=%ld, c=%ld, q=%lu)\n",
11231188 smp_processor_id(), (long)(jiffies - rsp->gp_start),
11241189 (long)rsp->gpnum, (long)rsp->completed, totqlen);
1125− if (ndetected == 0)
1126− pr_err("INFO: Stall ended before state dump start\n");
1127− else
1190+ if (ndetected) {
11281191 rcu_dump_cpu_stacks(rsp);
1192+ } else {
1193+ if (ACCESS_ONCE(rsp->gpnum) != gpnum ||
1194+ ACCESS_ONCE(rsp->completed) == gpnum) {
1195+ pr_err("INFO: Stall ended before state dump start\n");
1196+ } else {
1197+ j = jiffies;
1198+ gpa = ACCESS_ONCE(rsp->gp_activity);
1199+ pr_err("All QSes seen, last %s kthread activity %ld (%ld-%ld), jiffies_till_next_fqs=%ld\n",
1200+ rsp->name, j - gpa, j, gpa,
1201+ jiffies_till_next_fqs);
1202+ /* In this case, the current CPU might be at fault. */
1203+ sched_show_task(current);
1204+ }
1205+ }
11291206
11301207 /* Complain about tasks blocking the grace period. */
1131−
11321208 rcu_print_detail_task_stall(rsp);
11331209
1210+ rcu_check_gp_kthread_starvation(rsp);
1211+
11341212 force_quiescent_state(rsp); /* Kick them all. */
11351213 }
11361214
@@ -1155,6 +1233,9 @@ static void print_cpu_stall(struct rcu_state *rsp) · 18 unmodified lines
11551233 pr_cont(" (t=%lu jiffies g=%ld c=%ld q=%lu)\n",
11561234 jiffies - rsp->gp_start,
11571235 (long)rsp->gpnum, (long)rsp->completed, totqlen);
1236+
1237+ rcu_check_gp_kthread_starvation(rsp);
1238+
11581239 rcu_dump_cpu_stacks(rsp);
11591240
11601241 raw_spin_lock_irqsave(&rnp->lock, flags);
@@ -1225,7 +1306,7 @@ static void check_cpu_stall(struct rcu_state *rsp, struct rcu_data *rdp) · 64 unmodified lines
12251306 ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY)) {
12261307
12271308 /* They had a few time units to dump stack, so complain. */
1228− print_other_cpu_stall(rsp);
1309+ print_other_cpu_stall(rsp, gpnum);
12291310 }
12301311 }
12311312
@@ -1562,7 +1643,8 @@ static bool __note_gp_changes(struct rcu_state *rsp, struct rcu_node *rnp, · 330 unmodified lines
15621643 bool ret;
15631644
15641645 /* Handle the ends of any preceding grace periods first. */
1565− if (rdp->completed == rnp->completed) {
1646+ if (rdp->completed == rnp->completed &&
1647+ !unlikely(ACCESS_ONCE(rdp->gpwrap))) {
15661648
15671649 /* No grace period end, so just accelerate recent callbacks. */
15681650 ret = rcu_accelerate_cbs(rsp, rnp, rdp);
@@ -1577,7 +1659,7 @@ static bool __note_gp_changes(struct rcu_state *rsp, struct rcu_node *rnp, · 8 unmodified lines
15771659 trace_rcu_grace_period(rsp->name, rdp->gpnum, TPS("cpuend"));
15781660 }
15791661
1580− if (rdp->gpnum != rnp->gpnum) {
1662+ if (rdp->gpnum != rnp->gpnum || unlikely(ACCESS_ONCE(rdp->gpwrap))) {
15811663 /*
15821664 * If the current grace period is waiting for this CPU,
15831665 * set up to detect a quiescent state, otherwise don't
@@ -1586,8 +1668,10 @@ static bool __note_gp_changes(struct rcu_state *rsp, struct rcu_node *rnp, · 2 unmodified lines
15861668 rdp->gpnum = rnp->gpnum;
15871669 trace_rcu_grace_period(rsp->name, rdp->gpnum, TPS("cpustart"));
15881670 rdp->passed_quiesce = 0;
1671+ rdp->rcu_qs_ctr_snap = __this_cpu_read(rcu_qs_ctr);
15891672 rdp->qs_pending = !!(rnp->qsmask & rdp->grpmask);
15901673 zero_cpu_stall_ticks(rdp);
1674+ ACCESS_ONCE(rdp->gpwrap) = false;
15911675 }
15921676 return ret;
15931677 }
@@ -1601,7 +1685,8 @@ static void note_gp_changes(struct rcu_state *rsp, struct rcu_data *rdp) · 7 unmodified lines
16011685 local_irq_save(flags);
16021686 rnp = rdp->mynode;
16031687 if ((rdp->gpnum == ACCESS_ONCE(rnp->gpnum) &&
1604− rdp->completed == ACCESS_ONCE(rnp->completed)) || /* w/out lock. */
1688+ rdp->completed == ACCESS_ONCE(rnp->completed) &&
1689+ !unlikely(ACCESS_ONCE(rdp->gpwrap))) || /* w/out lock. */
16051690 !raw_spin_trylock(&rnp->lock)) { /* irqs already off, so later. */
16061691 local_irq_restore(flags);
16071692 return;
@@ -1621,6 +1706,7 @@ static int rcu_gp_init(struct rcu_state *rsp) · 13 unmodified lines
16211706 struct rcu_data *rdp;
16221707 struct rcu_node *rnp = rcu_get_root(rsp);
16231708
1709+ ACCESS_ONCE(rsp->gp_activity) = jiffies;
16241710 rcu_bind_gp_kthread();
16251711 raw_spin_lock_irq(&rnp->lock);
16261712 smp_mb__after_unlock_lock();
@@ -1681,6 +1767,7 @@ static int rcu_gp_init(struct rcu_state *rsp) · 54 unmodified lines
16811767 rnp->grphi, rnp->qsmask);
16821768 raw_spin_unlock_irq(&rnp->lock);
16831769 cond_resched_rcu_qs();
1770+ ACCESS_ONCE(rsp->gp_activity) = jiffies;
16841771 }
16851772
16861773 mutex_unlock(&rsp->onoff_mutex);
@@ -1697,6 +1784,7 @@ static int rcu_gp_fqs(struct rcu_state *rsp, int fqs_state_in) · 10 unmodified lines
16971784 unsigned long maxj;
16981785 struct rcu_node *rnp = rcu_get_root(rsp);
16991786
1787+ ACCESS_ONCE(rsp->gp_activity) = jiffies;
17001788 rsp->n_force_qs++;
17011789 if (fqs_state == RCU_SAVE_DYNTICK) {
17021790 /* Collect dyntick-idle snapshots. */
@@ -1735,6 +1823,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp) · 32 unmodified lines
17351823 struct rcu_data *rdp;
17361824 struct rcu_node *rnp = rcu_get_root(rsp);
17371825
1826+ ACCESS_ONCE(rsp->gp_activity) = jiffies;
17381827 raw_spin_lock_irq(&rnp->lock);
17391828 smp_mb__after_unlock_lock();
17401829 gp_duration = jiffies - rsp->gp_start;
@@ -1771,6 +1860,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp) · 30 unmodified lines
17711860 nocb += rcu_future_gp_cleanup(rsp, rnp);
17721861 raw_spin_unlock_irq(&rnp->lock);
17731862 cond_resched_rcu_qs();
1863+ ACCESS_ONCE(rsp->gp_activity) = jiffies;
17741864 }
17751865 rnp = rcu_get_root(rsp);
17761866 raw_spin_lock_irq(&rnp->lock);
@@ -1820,6 +1910,7 @@ static int __noreturn rcu_gp_kthread(void *arg) · 43 unmodified lines
18201910 if (rcu_gp_init(rsp))
18211911 break;
18221912 cond_resched_rcu_qs();
1913+ ACCESS_ONCE(rsp->gp_activity) = jiffies;
18231914 WARN_ON(signal_pending(current));
18241915 trace_rcu_grace_period(rsp->name,
18251916 ACCESS_ONCE(rsp->gpnum),
@@ -1863,9 +1954,11 @@ static int __noreturn rcu_gp_kthread(void *arg) · 37 unmodified lines
18631954 ACCESS_ONCE(rsp->gpnum),
18641955 TPS("fqsend"));
18651956 cond_resched_rcu_qs();
1957+ ACCESS_ONCE(rsp->gp_activity) = jiffies;
18661958 } else {
18671959 /* Deal with stray signal. */
18681960 cond_resched_rcu_qs();
1961+ ACCESS_ONCE(rsp->gp_activity) = jiffies;
18691962 WARN_ON(signal_pending(current));
18701963 trace_rcu_grace_period(rsp->name,
18711964 ACCESS_ONCE(rsp->gpnum),
@@ -2042,8 +2135,10 @@ rcu_report_qs_rdp(int cpu, struct rcu_state *rsp, struct rcu_data *rdp) · 170 unmodified lines
20422135 rnp = rdp->mynode;
20432136 raw_spin_lock_irqsave(&rnp->lock, flags);
20442137 smp_mb__after_unlock_lock();
2045− if (rdp->passed_quiesce == 0 || rdp->gpnum != rnp->gpnum ||
2046− rnp->completed == rnp->gpnum) {
2138+ if ((rdp->passed_quiesce == 0 &&
2139+ rdp->rcu_qs_ctr_snap == __this_cpu_read(rcu_qs_ctr)) ||
2140+ rdp->gpnum != rnp->gpnum || rnp->completed == rnp->gpnum ||
2141+ rdp->gpwrap) {
20472142
20482143 /*
20492144 * The grace period in which this quiescent state was
@@ -2052,6 +2147,7 @@ rcu_report_qs_rdp(int cpu, struct rcu_state *rsp, struct rcu_data *rdp) · 2 unmodified lines
20522147 * within the current grace period.
20532148 */
20542149 rdp->passed_quiesce = 0; /* need qs for new gp. */
2150+ rdp->rcu_qs_ctr_snap = __this_cpu_read(rcu_qs_ctr);
20552151 raw_spin_unlock_irqrestore(&rnp->lock, flags);
20562152 return;
20572153 }
@@ -2096,7 +2192,8 @@ rcu_check_quiescent_state(struct rcu_state *rsp, struct rcu_data *rdp) · 38 unmodified lines
20962192 * Was there a quiescent state since the beginning of the grace
20972193 * period? If no, then exit and wait for the next call.
20982194 */
2099− if (!rdp->passed_quiesce)
2195+ if (!rdp->passed_quiesce &&
2196+ rdp->rcu_qs_ctr_snap == __this_cpu_read(rcu_qs_ctr))
21002197 return;
21012198
21022199 /*
@@ -2226,6 +2323,46 @@ static void rcu_cleanup_dying_cpu(struct rcu_state *rsp) · 123 unmodified lines
22262323 TPS("cpuofl"));
22272324 }
22282325
2326+/*
2327+ * All CPUs for the specified rcu_node structure have gone offline,
2328+ * and all tasks that were preempted within an RCU read-side critical
2329+ * section while running on one of those CPUs have since exited their RCU
2330+ * read-side critical section. Some other CPU is reporting this fact with
2331+ * the specified rcu_node structure's ->lock held and interrupts disabled.
2332+ * This function therefore goes up the tree of rcu_node structures,
2333+ * clearing the corresponding bits in the ->qsmaskinit fields. Note that
2334+ * the leaf rcu_node structure's ->qsmaskinit field has already been
2335+ * updated
2336+ *
2337+ * This function does check that the specified rcu_node structure has
2338+ * all CPUs offline and no blocked tasks, so it is OK to invoke it
2339+ * prematurely. That said, invoking it after the fact will cost you
2340+ * a needless lock acquisition. So once it has done its work, don't
2341+ * invoke it again.
2342+ */
2343+static void rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf)
2344+{
2345+ long mask;
2346+ struct rcu_node *rnp = rnp_leaf;
2347+
2348+ if (rnp->qsmaskinit || rcu_preempt_has_tasks(rnp))
2349+ return;
2350+ for (;;) {
2351+ mask = rnp->grpmask;
2352+ rnp = rnp->parent;
2353+ if (!rnp)
2354+ break;
2355+ raw_spin_lock(&rnp->lock); /* irqs already disabled. */
2356+ smp_mb__after_unlock_lock(); /* GP memory ordering. */
2357+ rnp->qsmaskinit &= ~mask;
2358+ if (rnp->qsmaskinit) {
2359+ raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
2360+ return;
2361+ }
2362+ raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
2363+ }
2364+}
2365+
22292366 /*
22302367 * The CPU has been completely removed, and some other CPU is reporting
22312368 * this fact from process context. Do the remainder of the cleanup,
@@ -2236,8 +2373,6 @@ static void rcu_cleanup_dying_cpu(struct rcu_state *rsp) · 4 unmodified lines
22362373 static void rcu_cleanup_dead_cpu(int cpu, struct rcu_state *rsp)
22372374 {
22382375 unsigned long flags;
2239− unsigned long mask;
2240− int need_report = 0;
22412376 struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
22422377 struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */
22432378
@@ -2251,40 +2386,15 @@ static void rcu_cleanup_dead_cpu(int cpu, struct rcu_state *rsp) · 7 unmodified lines
22512386 /* Orphan the dead CPU's callbacks, and adopt them if appropriate. */
22522387 rcu_send_cbs_to_orphanage(cpu, rsp, rnp, rdp);
22532388 rcu_adopt_orphan_cbs(rsp, flags);
2389+ raw_spin_unlock_irqrestore(&rsp->orphan_lock, flags);
22542390
2255− /* Remove the outgoing CPU from the masks in the rcu_node hierarchy. */
2256− mask = rdp->grpmask; /* rnp->grplo is constant. */
2257− do {
2258− raw_spin_lock(&rnp->lock); /* irqs already disabled. */
2259− smp_mb__after_unlock_lock();
2260− rnp->qsmaskinit &= ~mask;
2261− if (rnp->qsmaskinit != 0) {
2262− if (rnp != rdp->mynode)
2263− raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
2264− break;
2265− }
2266− if (rnp == rdp->mynode)
2267− need_report = rcu_preempt_offline_tasks(rsp, rnp, rdp);
2268− else
2269− raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
2270− mask = rnp->grpmask;
2271− rnp = rnp->parent;
2272− } while (rnp != NULL);
2273−
2274− /*
2275− * We still hold the leaf rcu_node structure lock here, and
2276− * irqs are still disabled. The reason for this subterfuge is
2277− * because invoking rcu_report_unblock_qs_rnp() with ->orphan_lock
2278− * held leads to deadlock.
2279− */
2280− raw_spin_unlock(&rsp->orphan_lock); /* irqs remain disabled. */
2281− rnp = rdp->mynode;
2282− if (need_report & RCU_OFL_TASKS_NORM_GP)
2283− rcu_report_unblock_qs_rnp(rnp, flags);
2284− else
2285− raw_spin_unlock_irqrestore(&rnp->lock, flags);
2286− if (need_report & RCU_OFL_TASKS_EXP_GP)
2287− rcu_report_exp_rnp(rsp, rnp, true);
2391+ /* Remove outgoing CPU from mask in the leaf rcu_node structure. */
2392+ raw_spin_lock_irqsave(&rnp->lock, flags);
2393+ smp_mb__after_unlock_lock(); /* Enforce GP memory-order guarantee. */
2394+ rnp->qsmaskinit &= ~rdp->grpmask;
2395+ if (rnp->qsmaskinit == 0 && !rcu_preempt_has_tasks(rnp))
2396+ rcu_cleanup_dead_rnp(rnp);
2397+ rcu_report_qs_rnp(rdp->grpmask, rsp, rnp, flags); /* Rlses rnp->lock. */
22882398 WARN_ONCE(rdp->qlen != 0 || rdp->nxtlist != NULL,
22892399 "rcu_cleanup_dead_cpu: Callbacks on offline CPU %d: qlen=%lu, nxtlist=%p\n",
22902400 cpu, rdp->qlen, rdp->nxtlist);
@@ -2300,6 +2410,10 @@ static void rcu_cleanup_dying_cpu(struct rcu_state *rsp) · 9 unmodified lines
23002410 {
23012411 }
23022412
2413+static void __maybe_unused rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf)
2414+{
2415+}
2416+
23032417 static void rcu_cleanup_dead_cpu(int cpu, struct rcu_state *rsp)
23042418 {
23052419 }
@@ -2496,12 +2610,6 @@ static void force_qs_rnp(struct rcu_state *rsp, · 190 unmodified lines
24962610 }
24972611 raw_spin_unlock_irqrestore(&rnp->lock, flags);
24982612 }
2499− rnp = rcu_get_root(rsp);
2500− if (rnp->qsmask == 0) {
2501− raw_spin_lock_irqsave(&rnp->lock, flags);
2502− smp_mb__after_unlock_lock();
2503− rcu_initiate_boost(rnp, flags); /* releases rnp->lock. */
2504− }
25052613 }
25062614
25072615 /*
@@ -2601,7 +2709,7 @@ static void rcu_process_callbacks(struct softirq_action *unused) · 93 unmodified lines
26012709 * Schedule RCU callback invocation. If the specified type of RCU
26022710 * does not support RCU priority boosting, just do a direct call,
26032711 * otherwise wake up the per-CPU kernel kthread. Note that because we
2604− * are running on the current CPU with interrupts disabled, the
2712+ * are running on the current CPU with softirqs disabled, the
26052713 * rcu_cpu_kthread_task cannot disappear out from under us.
26062714 */
26072715 static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp)
@@ -3141,9 +3249,12 @@ static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp) · 533 unmodified lines
31413249
31423250 /* Is the RCU core waiting for a quiescent state from this CPU? */
31433251 if (rcu_scheduler_fully_active &&
3144− rdp->qs_pending && !rdp->passed_quiesce) {
3252+ rdp->qs_pending && !rdp->passed_quiesce &&
3253+ rdp->rcu_qs_ctr_snap == __this_cpu_read(rcu_qs_ctr)) {
31453254 rdp->n_rp_qs_pending++;
3146− } else if (rdp->qs_pending && rdp->passed_quiesce) {
3255+ } else if (rdp->qs_pending &&
3256+ (rdp->passed_quiesce ||
3257+ rdp->rcu_qs_ctr_snap != __this_cpu_read(rcu_qs_ctr))) {
31473258 rdp->n_rp_report_qs++;
31483259 return 1;
31493260 }
@@ -3167,7 +3278,8 @@ static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp) · 17 unmodified lines
31673278 }
31683279
31693280 /* Has a new RCU grace period started? */
3170− if (ACCESS_ONCE(rnp->gpnum) != rdp->gpnum) { /* outside lock */
3281+ if (ACCESS_ONCE(rnp->gpnum) != rdp->gpnum ||
3282+ unlikely(ACCESS_ONCE(rdp->gpwrap))) { /* outside lock */
31713283 rdp->n_rp_gp_started++;
31723284 return 1;
31733285 }
@@ -3350,6 +3462,7 @@ static void _rcu_barrier(struct rcu_state *rsp) · 176 unmodified lines
33503462 } else {
33513463 _rcu_barrier_trace(rsp, "OnlineNoCB", cpu,
33523464 rsp->n_barrier_done);
3465+ smp_mb__before_atomic();
33533466 atomic_inc(&rsp->barrier_cpu_count);
33543467 __call_rcu(&rdp->barrier_head,
33553468 rcu_barrier_callback, rsp, cpu, 0);
@@ -3417,9 +3530,6 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp) · 61 unmodified lines
34173530 /* Set up local state, ensuring consistent view of global state. */
34183531 raw_spin_lock_irqsave(&rnp->lock, flags);
34193532 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
3420− init_callback_list(rdp);
3421− rdp->qlen_lazy = 0;
3422− ACCESS_ONCE(rdp->qlen) = 0;
34233533 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
34243534 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
34253535 WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
@@ -3476,6 +3586,7 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp) · 50 unmodified lines
34763586 rdp->gpnum = rnp->completed;
34773587 rdp->completed = rnp->completed;
34783588 rdp->passed_quiesce = 0;
3589+ rdp->rcu_qs_ctr_snap = __this_cpu_read(rcu_qs_ctr);
34793590 rdp->qs_pending = 0;
34803591 trace_rcu_grace_period(rsp->name, rdp->gpnum, TPS("cpuonl"));
34813592 }
@@ -3567,17 +3678,35 @@ static int rcu_pm_notify(struct notifier_block *self, · 85 unmodified lines
35673678 static int __init rcu_spawn_gp_kthread(void)
35683679 {
35693680 unsigned long flags;
3681+ int kthread_prio_in = kthread_prio;
35703682 struct rcu_node *rnp;
35713683 struct rcu_state *rsp;
3684+ struct sched_param sp;
35723685 struct task_struct *t;
35733686
3687+ /* Force priority into range. */
3688+ if (IS_ENABLED(CONFIG_RCU_BOOST) && kthread_prio < 1)
3689+ kthread_prio = 1;
3690+ else if (kthread_prio < 0)
3691+ kthread_prio = 0;
3692+ else if (kthread_prio > 99)
3693+ kthread_prio = 99;
3694+ if (kthread_prio != kthread_prio_in)
3695+ pr_alert("rcu_spawn_gp_kthread(): Limited prio to %d from %d\n",
3696+ kthread_prio, kthread_prio_in);
3697+
35743698 rcu_scheduler_fully_active = 1;
35753699 for_each_rcu_flavor(rsp) {
3576− t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
3700+ t = kthread_create(rcu_gp_kthread, rsp, "%s", rsp->name);
35773701 BUG_ON(IS_ERR(t));
35783702 rnp = rcu_get_root(rsp);
35793703 raw_spin_lock_irqsave(&rnp->lock, flags);
35803704 rsp->gp_kthread = t;
3705+ if (kthread_prio) {
3706+ sp.sched_priority = kthread_prio;
3707+ sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
3708+ }
3709+ wake_up_process(t);
35813710 raw_spin_unlock_irqrestore(&rnp->lock, flags);
35823711 }
35833712 rcu_spawn_nocb_kthreads();
kernel/rcu/tree.h+15−47
@@ -27,7 +27,6 @@ · 26 unmodified lines
2727 #include <linux/threads.h>
2828 #include <linux/cpumask.h>
2929 #include <linux/seqlock.h>
30−#include <linux/irq_work.h>
3130
3231 /*
3332 * Define shape of hierarchy based on NR_CPUS, CONFIG_RCU_FANOUT, and
@@ -172,11 +171,6 @@ struct rcu_node { · 138 unmodified lines
172171 /* queued on this rcu_node structure that */
173172 /* are blocking the current grace period, */
174173 /* there can be no such task. */
175− struct completion boost_completion;
176− /* Used to ensure that the rt_mutex used */
177− /* to carry out the boosting is fully */
178− /* released with no future boostee accesses */
179− /* before that rt_mutex is re-initialized. */
180174 struct rt_mutex boost_mtx;
181175 /* Used only for the priority-boosting */
182176 /* side effect, not as a lock. */
@@ -257,9 +251,12 @@ struct rcu_data { · 74 unmodified lines
257251 /* in order to detect GP end. */
258252 unsigned long gpnum; /* Highest gp number that this CPU */
259253 /* is aware of having started. */
254+ unsigned long rcu_qs_ctr_snap;/* Snapshot of rcu_qs_ctr to check */
255+ /* for rcu_all_qs() invocations. */
260256 bool passed_quiesce; /* User-mode/idle loop etc. */
261257 bool qs_pending; /* Core waits for quiesc state. */
262258 bool beenonline; /* CPU online at least once. */
259+ bool gpwrap; /* Possible gpnum/completed wrap. */
263260 struct rcu_node *mynode; /* This CPU's leaf of hierarchy */
264261 unsigned long grpmask; /* Mask to apply to leaf qsmask. */
265262 #ifdef CONFIG_RCU_CPU_STALL_INFO
@@ -340,14 +337,10 @@ struct rcu_data { · 74 unmodified lines
340337 #ifdef CONFIG_RCU_NOCB_CPU
341338 struct rcu_head *nocb_head; /* CBs waiting for kthread. */
342339 struct rcu_head **nocb_tail;
343− atomic_long_t nocb_q_count; /* # CBs waiting for kthread */
344− atomic_long_t nocb_q_count_lazy; /* (approximate). */
340+ atomic_long_t nocb_q_count; /* # CBs waiting for nocb */
341+ atomic_long_t nocb_q_count_lazy; /* invocation (all stages). */
345342 struct rcu_head *nocb_follower_head; /* CBs ready to invoke. */
346343 struct rcu_head **nocb_follower_tail;
347− atomic_long_t nocb_follower_count; /* # CBs ready to invoke. */
348− atomic_long_t nocb_follower_count_lazy; /* (approximate). */
349− int nocb_p_count; /* # CBs being invoked by kthread */
350− int nocb_p_count_lazy; /* (approximate). */
351344 wait_queue_head_t nocb_wq; /* For nocb kthreads to sleep on. */
352345 struct task_struct *nocb_kthread;
353346 int nocb_defer_wakeup; /* Defer wakeup of nocb_kthread. */
@@ -356,8 +349,6 @@ struct rcu_data { · 2 unmodified lines
356349 struct rcu_head *nocb_gp_head ____cacheline_internodealigned_in_smp;
357350 /* CBs waiting for GP. */
358351 struct rcu_head **nocb_gp_tail;
359− long nocb_gp_count;
360− long nocb_gp_count_lazy;
361352 bool nocb_leader_sleep; /* Is the nocb leader thread asleep? */
362353 struct rcu_data *nocb_next_follower;
363354 /* Next follower in wakeup chain. */
@@ -488,10 +479,14 @@ struct rcu_state { · 124 unmodified lines
488479 /* due to no GP active. */
489480 unsigned long gp_start; /* Time at which GP started, */
490481 /* but in jiffies. */
482+ unsigned long gp_activity; /* Time of last GP kthread */
483+ /* activity in jiffies. */
491484 unsigned long jiffies_stall; /* Time at which to check */
492485 /* for CPU stalls. */
493486 unsigned long jiffies_resched; /* Time at which to resched */
494487 /* a reluctant CPU. */
488+ unsigned long n_force_qs_gpstart; /* Snapshot of n_force_qs at */
489+ /* GP start. */
495490 unsigned long gp_max; /* Maximum GP duration in */
496491 /* jiffies. */
497492 const char *name; /* Name of structure. */
@@ -514,13 +509,6 @@ extern struct list_head rcu_struct_flavors; · 16 unmodified lines
514509 #define for_each_rcu_flavor(rsp) \
515510 list_for_each_entry((rsp), &rcu_struct_flavors, flavors)
516511
517−/* Return values for rcu_preempt_offline_tasks(). */
518−
519−#define RCU_OFL_TASKS_NORM_GP 0x1 /* Tasks blocking normal */
520− /* GP were moved to root. */
521−#define RCU_OFL_TASKS_EXP_GP 0x2 /* Tasks blocking expedited */
522− /* GP were moved to root. */
523−
524512 /*
525513 * RCU implementation internal declarations:
526514 */
@@ -546,27 +534,16 @@ DECLARE_PER_CPU(char, rcu_cpu_has_work); · 19 unmodified lines
546534
547535 /* Forward declarations for rcutree_plugin.h */
548536 static void rcu_bootup_announce(void);
549−long rcu_batches_completed(void);
550537 static void rcu_preempt_note_context_switch(void);
551538 static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp);
552539 #ifdef CONFIG_HOTPLUG_CPU
553−static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp,
554− unsigned long flags);
540+static bool rcu_preempt_has_tasks(struct rcu_node *rnp);
555541 #endif /* #ifdef CONFIG_HOTPLUG_CPU */
556542 static void rcu_print_detail_task_stall(struct rcu_state *rsp);
557543 static int rcu_print_task_stall(struct rcu_node *rnp);
558544 static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp);
559−#ifdef CONFIG_HOTPLUG_CPU
560−static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
561− struct rcu_node *rnp,
562− struct rcu_data *rdp);
563−#endif /* #ifdef CONFIG_HOTPLUG_CPU */
564545 static void rcu_preempt_check_callbacks(void);
565546 void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu));
566−#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PREEMPT_RCU)
567−static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp,
568− bool wake);
569−#endif /* #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PREEMPT_RCU) */
570547 static void __init __rcu_init_preempt(void);
571548 static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags);
572549 static void rcu_preempt_boost_start_gp(struct rcu_node *rnp);
@@ -622,24 +599,15 @@ static void rcu_dynticks_task_exit(void); · 49 unmodified lines
622599 #endif /* #ifndef RCU_TREE_NONCORE */
623600
624601 #ifdef CONFIG_RCU_TRACE
625−#ifdef CONFIG_RCU_NOCB_CPU
626−/* Sum up queue lengths for tracing. */
602+/* Read out queue lengths for tracing. */
627603 static inline void rcu_nocb_q_lengths(struct rcu_data *rdp, long *ql, long *qll)
628604 {
629− *ql = atomic_long_read(&rdp->nocb_q_count) +
630− rdp->nocb_p_count +
631− atomic_long_read(&rdp->nocb_follower_count) +
632− rdp->nocb_p_count + rdp->nocb_gp_count;
633− *qll = atomic_long_read(&rdp->nocb_q_count_lazy) +
634− rdp->nocb_p_count_lazy +
635− atomic_long_read(&rdp->nocb_follower_count_lazy) +
636− rdp->nocb_p_count_lazy + rdp->nocb_gp_count_lazy;
637−}
605+#ifdef CONFIG_RCU_NOCB_CPU
606+ *ql = atomic_long_read(&rdp->nocb_q_count);
607+ *qll = atomic_long_read(&rdp->nocb_q_count_lazy);
638608 #else /* #ifdef CONFIG_RCU_NOCB_CPU */
639−static inline void rcu_nocb_q_lengths(struct rcu_data *rdp, long *ql, long *qll)
640−{
641609 *ql = 0;
642610 *qll = 0;
643−}
644611 #endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */
612+}
645613 #endif /* #ifdef CONFIG_RCU_TRACE */
kernel/rcu/tree_plugin.h+72−199
@@ -34,10 +34,6 @@ · 33 unmodified lines
3434
3535 #include "../locking/rtmutex_common.h"
3636
37−/* rcuc/rcub kthread realtime priority */
38−static int kthread_prio = CONFIG_RCU_KTHREAD_PRIO;
39−module_param(kthread_prio, int, 0644);
40−
4137 /*
4238 * Control variables for per-CPU and per-rcu_node kthreads. These
4339 * handle all flavors of RCU.
@@ -103,6 +99,8 @@ RCU_STATE_INITIALIZER(rcu_preempt, 'p', call_rcu); · 59 unmodified lines
10399 static struct rcu_state *rcu_state_p = &rcu_preempt_state;
104100
105101 static int rcu_preempted_readers_exp(struct rcu_node *rnp);
102+static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp,
103+ bool wake);
106104
107105 /*
108106 * Tell them what RCU they are running.
@@ -113,25 +111,6 @@ static void __init rcu_bootup_announce(void) · 4 unmodified lines
113111 rcu_bootup_announce_oddness();
114112 }
115113
116−/*
117− * Return the number of RCU-preempt batches processed thus far
118− * for debug and statistics.
119− */
120−static long rcu_batches_completed_preempt(void)
121−{
122− return rcu_preempt_state.completed;
123−}
124−EXPORT_SYMBOL_GPL(rcu_batches_completed_preempt);
125−
126−/*
127− * Return the number of RCU batches processed thus far for debug & stats.
128− */
129−long rcu_batches_completed(void)
130−{
131− return rcu_batches_completed_preempt();
132−}
133−EXPORT_SYMBOL_GPL(rcu_batches_completed);
134−
135114 /*
136115 * Record a preemptible-RCU quiescent state for the specified CPU. Note
137116 * that this just means that the task currently running on the CPU is
@@ -306,6 +285,15 @@ static struct list_head *rcu_next_node_entry(struct task_struct *t, · 168 unmodified lines
306285 return np;
307286 }
308287
288+/*
289+ * Return true if the specified rcu_node structure has tasks that were
290+ * preempted within an RCU read-side critical section.
291+ */
292+static bool rcu_preempt_has_tasks(struct rcu_node *rnp)
293+{
294+ return !list_empty(&rnp->blkd_tasks);
295+}
296+
309297 /*
310298 * Handle special cases during rcu_read_unlock(), such as needing to
311299 * notify RCU core processing or task having blocked during the RCU
@@ -313,9 +301,10 @@ static struct list_head *rcu_next_node_entry(struct task_struct *t, · 1 unmodified line
313301 */
314302 void rcu_read_unlock_special(struct task_struct *t)
315303 {
316− int empty;
317− int empty_exp;
318− int empty_exp_now;
304+ bool empty;
305+ bool empty_exp;
306+ bool empty_norm;
307+ bool empty_exp_now;
319308 unsigned long flags;
320309 struct list_head *np;
321310 #ifdef CONFIG_RCU_BOOST
@@ -367,7 +356,8 @@ void rcu_read_unlock_special(struct task_struct *t) · 45 unmodified lines
367356 break;
368357 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
369358 }
370− empty = !rcu_preempt_blocked_readers_cgp(rnp);
359+ empty = !rcu_preempt_has_tasks(rnp);
360+ empty_norm = !rcu_preempt_blocked_readers_cgp(rnp);
371361 empty_exp = !rcu_preempted_readers_exp(rnp);
372362 smp_mb(); /* ensure expedited fastpath sees end of RCU c-s. */
373363 np = rcu_next_node_entry(t, rnp);
@@ -386,6 +376,14 @@ void rcu_read_unlock_special(struct task_struct *t) · 12 unmodified lines
386376 drop_boost_mutex = rt_mutex_owner(&rnp->boost_mtx) == t;
387377 #endif /* #ifdef CONFIG_RCU_BOOST */
388378
379+ /*
380+ * If this was the last task on the list, go see if we
381+ * need to propagate ->qsmaskinit bit clearing up the
382+ * rcu_node tree.
383+ */
384+ if (!empty && !rcu_preempt_has_tasks(rnp))
385+ rcu_cleanup_dead_rnp(rnp);
386+
389387 /*
390388 * If this was the last task on the current list, and if
391389 * we aren't waiting on any CPUs, report the quiescent state.
@@ -393,7 +391,7 @@ void rcu_read_unlock_special(struct task_struct *t) · 1 unmodified line
393391 * so we must take a snapshot of the expedited state.
394392 */
395393 empty_exp_now = !rcu_preempted_readers_exp(rnp);
396− if (!empty && !rcu_preempt_blocked_readers_cgp(rnp)) {
394+ if (!empty_norm && !rcu_preempt_blocked_readers_cgp(rnp)) {
397395 trace_rcu_quiescent_state_report(TPS("preempt_rcu"),
398396 rnp->gpnum,
399397 0, rnp->qsmask,
@@ -408,10 +406,8 @@ void rcu_read_unlock_special(struct task_struct *t) · 8 unmodified lines
408406
409407 #ifdef CONFIG_RCU_BOOST
410408 /* Unboost if we were boosted. */
411− if (drop_boost_mutex) {
409+ if (drop_boost_mutex)
412410 rt_mutex_unlock(&rnp->boost_mtx);
413− complete(&rnp->boost_completion);
414− }
415411 #endif /* #ifdef CONFIG_RCU_BOOST */
416412
417413 /*
@@ -519,99 +515,13 @@ static int rcu_print_task_stall(struct rcu_node *rnp) · 101 unmodified lines
519515 static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp)
520516 {
521517 WARN_ON_ONCE(rcu_preempt_blocked_readers_cgp(rnp));
522− if (!list_empty(&rnp->blkd_tasks))
518+ if (rcu_preempt_has_tasks(rnp))
523519 rnp->gp_tasks = rnp->blkd_tasks.next;
524520 WARN_ON_ONCE(rnp->qsmask);
525521 }
526522
527523 #ifdef CONFIG_HOTPLUG_CPU
528524
529−/*
530− * Handle tasklist migration for case in which all CPUs covered by the
531− * specified rcu_node have gone offline. Move them up to the root
532− * rcu_node. The reason for not just moving them to the immediate
533− * parent is to remove the need for rcu_read_unlock_special() to
534− * make more than two attempts to acquire the target rcu_node's lock.
535− * Returns true if there were tasks blocking the current RCU grace
536− * period.
537− *
538− * Returns 1 if there was previously a task blocking the current grace
539− * period on the specified rcu_node structure.
540− *
541− * The caller must hold rnp->lock with irqs disabled.
542− */
543−static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
544− struct rcu_node *rnp,
545− struct rcu_data *rdp)
546−{
547− struct list_head *lp;
548− struct list_head *lp_root;
549− int retval = 0;
550− struct rcu_node *rnp_root = rcu_get_root(rsp);
551− struct task_struct *t;
552−
553− if (rnp == rnp_root) {
554− WARN_ONCE(1, "Last CPU thought to be offlined?");
555− return 0; /* Shouldn't happen: at least one CPU online. */
556− }
557−
558− /* If we are on an internal node, complain bitterly. */
559− WARN_ON_ONCE(rnp != rdp->mynode);
560−
561− /*
562− * Move tasks up to root rcu_node. Don't try to get fancy for
563− * this corner-case operation -- just put this node's tasks
564− * at the head of the root node's list, and update the root node's
565− * ->gp_tasks and ->exp_tasks pointers to those of this node's,
566− * if non-NULL. This might result in waiting for more tasks than
567− * absolutely necessary, but this is a good performance/complexity
568− * tradeoff.
569− */
570− if (rcu_preempt_blocked_readers_cgp(rnp) && rnp->qsmask == 0)
571− retval |= RCU_OFL_TASKS_NORM_GP;
572− if (rcu_preempted_readers_exp(rnp))
573− retval |= RCU_OFL_TASKS_EXP_GP;
574− lp = &rnp->blkd_tasks;
575− lp_root = &rnp_root->blkd_tasks;
576− while (!list_empty(lp)) {
577− t = list_entry(lp->next, typeof(*t), rcu_node_entry);
578− raw_spin_lock(&rnp_root->lock); /* irqs already disabled */
579− smp_mb__after_unlock_lock();
580− list_del(&t->rcu_node_entry);
581− t->rcu_blocked_node = rnp_root;
582− list_add(&t->rcu_node_entry, lp_root);
583− if (&t->rcu_node_entry == rnp->gp_tasks)
584− rnp_root->gp_tasks = rnp->gp_tasks;
585− if (&t->rcu_node_entry == rnp->exp_tasks)
586− rnp_root->exp_tasks = rnp->exp_tasks;
587−#ifdef CONFIG_RCU_BOOST
588− if (&t->rcu_node_entry == rnp->boost_tasks)
589− rnp_root->boost_tasks = rnp->boost_tasks;
590−#endif /* #ifdef CONFIG_RCU_BOOST */
591− raw_spin_unlock(&rnp_root->lock); /* irqs still disabled */
592− }
593−
594− rnp->gp_tasks = NULL;
595− rnp->exp_tasks = NULL;
596−#ifdef CONFIG_RCU_BOOST
597− rnp->boost_tasks = NULL;
598− /*
599− * In case root is being boosted and leaf was not. Make sure
600− * that we boost the tasks blocking the current grace period
601− * in this case.
602− */
603− raw_spin_lock(&rnp_root->lock); /* irqs already disabled */
604− smp_mb__after_unlock_lock();
605− if (rnp_root->boost_tasks != NULL &&
606− rnp_root->boost_tasks != rnp_root->gp_tasks &&
607− rnp_root->boost_tasks != rnp_root->exp_tasks)
608− rnp_root->boost_tasks = rnp_root->gp_tasks;
609− raw_spin_unlock(&rnp_root->lock); /* irqs still disabled */
610−#endif /* #ifdef CONFIG_RCU_BOOST */
611−
612− return retval;
613−}
614−
615525 #endif /* #ifdef CONFIG_HOTPLUG_CPU */
616526
617527 /*
@@ -771,7 +681,7 @@ sync_rcu_preempt_exp_init(struct rcu_state *rsp, struct rcu_node *rnp) · 153 unmodified lines
771681
772682 raw_spin_lock_irqsave(&rnp->lock, flags);
773683 smp_mb__after_unlock_lock();
774− if (list_empty(&rnp->blkd_tasks)) {
684+ if (!rcu_preempt_has_tasks(rnp)) {
775685 raw_spin_unlock_irqrestore(&rnp->lock, flags);
776686 } else {
777687 rnp->exp_tasks = rnp->blkd_tasks.next;
@@ -932,15 +842,6 @@ static void __init rcu_bootup_announce(void) · 154 unmodified lines
932842 rcu_bootup_announce_oddness();
933843 }
934844
935−/*
936− * Return the number of RCU batches processed thus far for debug & stats.
937− */
938−long rcu_batches_completed(void)
939−{
940− return rcu_batches_completed_sched();
941−}
942−EXPORT_SYMBOL_GPL(rcu_batches_completed);
943−
944845 /*
945846 * Because preemptible RCU does not exist, we never have to check for
946847 * CPUs being in quiescent states.
@@ -960,11 +861,12 @@ static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp) · 13 unmodified lines
960861
961862 #ifdef CONFIG_HOTPLUG_CPU
962863
963−/* Because preemptible RCU does not exist, no quieting of tasks. */
964−static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, unsigned long flags)
965− __releases(rnp->lock)
864+/*
865+ * Because there is no preemptible RCU, there can be no readers blocked.
866+ */
867+static bool rcu_preempt_has_tasks(struct rcu_node *rnp)
966868 {
967− raw_spin_unlock_irqrestore(&rnp->lock, flags);
869+ return false;
968870 }
969871
970872 #endif /* #ifdef CONFIG_HOTPLUG_CPU */
@@ -996,23 +898,6 @@ static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) · 25 unmodified lines
996898 WARN_ON_ONCE(rnp->qsmask);
997899 }
998900
999−#ifdef CONFIG_HOTPLUG_CPU
1000−
1001−/*
1002− * Because preemptible RCU does not exist, it never needs to migrate
1003− * tasks that were blocked within RCU read-side critical sections, and
1004− * such non-existent tasks cannot possibly have been blocking the current
1005− * grace period.
1006− */
1007−static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
1008− struct rcu_node *rnp,
1009− struct rcu_data *rdp)
1010−{
1011− return 0;
1012−}
1013−
1014−#endif /* #ifdef CONFIG_HOTPLUG_CPU */
1015−
1016901 /*
1017902 * Because preemptible RCU does not exist, it never has any callbacks
1018903 * to check.
@@ -1031,20 +916,6 @@ void synchronize_rcu_expedited(void) · 12 unmodified lines
1031916 }
1032917 EXPORT_SYMBOL_GPL(synchronize_rcu_expedited);
1033918
1034−#ifdef CONFIG_HOTPLUG_CPU
1035−
1036−/*
1037− * Because preemptible RCU does not exist, there is never any need to
1038− * report on tasks preempted in RCU read-side critical sections during
1039− * expedited RCU grace periods.
1040− */
1041−static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp,
1042− bool wake)
1043−{
1044−}
1045−
1046−#endif /* #ifdef CONFIG_HOTPLUG_CPU */
1047−
1048919 /*
1049920 * Because preemptible RCU does not exist, rcu_barrier() is just
1050921 * another name for rcu_barrier_sched().
@@ -1080,7 +951,7 @@ void exit_rcu(void) · 29 unmodified lines
1080951
1081952 static void rcu_initiate_boost_trace(struct rcu_node *rnp)
1082953 {
1083− if (list_empty(&rnp->blkd_tasks))
954+ if (!rcu_preempt_has_tasks(rnp))
1084955 rnp->n_balk_blkd_tasks++;
1085956 else if (rnp->exp_tasks == NULL && rnp->gp_tasks == NULL)
1086957 rnp->n_balk_exp_gp_tasks++;
@@ -1127,7 +998,8 @@ static int rcu_boost(struct rcu_node *rnp) · 40 unmodified lines
1127998 struct task_struct *t;
1128999 struct list_head *tb;
11291000
1130− if (rnp->exp_tasks == NULL && rnp->boost_tasks == NULL)
1001+ if (ACCESS_ONCE(rnp->exp_tasks) == NULL &&
1002+ ACCESS_ONCE(rnp->boost_tasks) == NULL)
11311003 return 0; /* Nothing left to boost. */
11321004
11331005 raw_spin_lock_irqsave(&rnp->lock, flags);
@@ -1175,15 +1047,11 @@ static int rcu_boost(struct rcu_node *rnp) · 41 unmodified lines
11751047 */
11761048 t = container_of(tb, struct task_struct, rcu_node_entry);
11771049 rt_mutex_init_proxy_locked(&rnp->boost_mtx, t);
1178− init_completion(&rnp->boost_completion);
11791050 raw_spin_unlock_irqrestore(&rnp->lock, flags);
11801051 /* Lock only for side effect: boosts task t's priority. */
11811052 rt_mutex_lock(&rnp->boost_mtx);
11821053 rt_mutex_unlock(&rnp->boost_mtx); /* Then keep lockdep happy. */
11831054
1184− /* Wait for boostee to be done w/boost_mtx before reinitializing. */
1185− wait_for_completion(&rnp->boost_completion);
1186−
11871055 return ACCESS_ONCE(rnp->exp_tasks) != NULL ||
11881056 ACCESS_ONCE(rnp->boost_tasks) != NULL;
11891057 }
@@ -1416,12 +1284,8 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) · 226 unmodified lines
14161284 for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++, mask >>= 1)
14171285 if ((mask & 0x1) && cpu != outgoingcpu)
14181286 cpumask_set_cpu(cpu, cm);
1419− if (cpumask_weight(cm) == 0) {
1287+ if (cpumask_weight(cm) == 0)
14201288 cpumask_setall(cm);
1421− for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++)
1422− cpumask_clear_cpu(cpu, cm);
1423− WARN_ON_ONCE(cpumask_weight(cm) == 0);
1424− }
14251289 set_cpus_allowed_ptr(t, cm);
14261290 free_cpumask_var(cm);
14271291 }
@@ -1446,12 +1310,8 @@ static void __init rcu_spawn_boost_kthreads(void) · 18 unmodified lines
14461310 for_each_possible_cpu(cpu)
14471311 per_cpu(rcu_cpu_has_work, cpu) = 0;
14481312 BUG_ON(smpboot_register_percpu_thread(&rcu_cpu_thread_spec));
1449− rnp = rcu_get_root(rcu_state_p);
1450− (void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp);
1451− if (NUM_RCU_NODES > 1) {
1452− rcu_for_each_leaf_node(rcu_state_p, rnp)
1453− (void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp);
1454− }
1313+ rcu_for_each_leaf_node(rcu_state_p, rnp)
1314+ (void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp);
14551315 }
14561316
14571317 static void rcu_prepare_kthreads(int cpu)
@@ -1605,7 +1465,8 @@ static bool __maybe_unused rcu_try_advance_all_cbs(void) · 147 unmodified lines
16051465 * completed since we last checked and there are
16061466 * callbacks not yet ready to invoke.
16071467 */
1608− if (rdp->completed != rnp->completed &&
1468+ if ((rdp->completed != rnp->completed ||
1469+ unlikely(ACCESS_ONCE(rdp->gpwrap))) &&
16091470 rdp->nxttail[RCU_DONE_TAIL] != rdp->nxttail[RCU_NEXT_TAIL])
16101471 note_gp_changes(rsp, rdp);
16111472
@@ -1898,11 +1759,12 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu) · 286 unmodified lines
18981759 ticks_value = rsp->gpnum - rdp->gpnum;
18991760 }
19001761 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
1901− pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
1762+ pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u fqs=%ld %s\n",
19021763 cpu, ticks_value, ticks_title,
19031764 atomic_read(&rdtp->dynticks) & 0xfff,
19041765 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
19051766 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
1767+ ACCESS_ONCE(rsp->n_force_qs) - rsp->n_force_qs_gpstart,
19061768 fast_no_hz);
19071769 }
19081770
@@ -2056,9 +1918,26 @@ static void wake_nocb_leader(struct rcu_data *rdp, bool force) · 147 unmodified lines
20561918 static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu)
20571919 {
20581920 struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
1921+ unsigned long ret;
1922+#ifdef CONFIG_PROVE_RCU
20591923 struct rcu_head *rhp;
1924+#endif /* #ifdef CONFIG_PROVE_RCU */
20601925
2061− /* No-CBs CPUs might have callbacks on any of three lists. */
1926+ /*
1927+ * Check count of all no-CBs callbacks awaiting invocation.
1928+ * There needs to be a barrier before this function is called,
1929+ * but associated with a prior determination that no more
1930+ * callbacks would be posted. In the worst case, the first
1931+ * barrier in _rcu_barrier() suffices (but the caller cannot
1932+ * necessarily rely on this, not a substitute for the caller
1933+ * getting the concurrency design right!). There must also be
1934+ * a barrier between the following load an posting of a callback
1935+ * (if a callback is in fact needed). This is associated with an
1936+ * atomic_inc() in the caller.
1937+ */
1938+ ret = atomic_long_read(&rdp->nocb_q_count);
1939+
1940+#ifdef CONFIG_PROVE_RCU
20621941 rhp = ACCESS_ONCE(rdp->nocb_head);
20631942 if (!rhp)
20641943 rhp = ACCESS_ONCE(rdp->nocb_gp_head);
@@ -2072,8 +1951,9 @@ static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu) · 7 unmodified lines
20721951 cpu, rhp->func);
20731952 WARN_ON_ONCE(1);
20741953 }
1954+#endif /* #ifdef CONFIG_PROVE_RCU */
20751955
2076− return !!rhp;
1956+ return !!ret;
20771957 }
20781958
20791959 /*
@@ -2095,9 +1975,10 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp, · 15 unmodified lines
20951975 struct task_struct *t;
20961976
20971977 /* Enqueue the callback on the nocb list and update counts. */
1978+ atomic_long_add(rhcount, &rdp->nocb_q_count);
1979+ /* rcu_barrier() relies on ->nocb_q_count add before xchg. */
20981980 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
20991981 ACCESS_ONCE(*old_rhpp) = rhp;
2100− atomic_long_add(rhcount, &rdp->nocb_q_count);
21011982 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
21021983 smp_mb__after_atomic(); /* Store *old_rhpp before _wake test. */
21031984
@@ -2288,9 +2169,6 @@ wait_again: · 184 unmodified lines
22882169 /* Move callbacks to wait-for-GP list, which is empty. */
22892170 ACCESS_ONCE(rdp->nocb_head) = NULL;
22902171 rdp->nocb_gp_tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
2291− rdp->nocb_gp_count = atomic_long_xchg(&rdp->nocb_q_count, 0);
2292− rdp->nocb_gp_count_lazy =
2293− atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
22942172 gotcbs = true;
22952173 }
22962174
@@ -2338,9 +2216,6 @@ wait_again: · 41 unmodified lines
23382216 /* Append callbacks to follower's "done" list. */
23392217 tail = xchg(&rdp->nocb_follower_tail, rdp->nocb_gp_tail);
23402218 *tail = rdp->nocb_gp_head;
2341− atomic_long_add(rdp->nocb_gp_count, &rdp->nocb_follower_count);
2342− atomic_long_add(rdp->nocb_gp_count_lazy,
2343− &rdp->nocb_follower_count_lazy);
23442219 smp_mb__after_atomic(); /* Store *tail before wakeup. */
23452220 if (rdp != my_rdp && tail == &rdp->nocb_follower_head) {
23462221 /*
@@ -2415,13 +2290,11 @@ static int rcu_nocb_kthread(void *arg) · 68 unmodified lines
24152290 trace_rcu_nocb_wake(rdp->rsp->name, rdp->cpu, "WokeNonEmpty");
24162291 ACCESS_ONCE(rdp->nocb_follower_head) = NULL;
24172292 tail = xchg(&rdp->nocb_follower_tail, &rdp->nocb_follower_head);
2418− c = atomic_long_xchg(&rdp->nocb_follower_count, 0);
2419− cl = atomic_long_xchg(&rdp->nocb_follower_count_lazy, 0);
2420− rdp->nocb_p_count += c;
2421− rdp->nocb_p_count_lazy += cl;
24222293
24232294 /* Each pass through the following loop invokes a callback. */
2424− trace_rcu_batch_start(rdp->rsp->name, cl, c, -1);
2295+ trace_rcu_batch_start(rdp->rsp->name,
2296+ atomic_long_read(&rdp->nocb_q_count_lazy),
2297+ atomic_long_read(&rdp->nocb_q_count), -1);
24252298 c = cl = 0;
24262299 while (list) {
24272300 next = list->next;
@@ -2443,9 +2316,9 @@ static int rcu_nocb_kthread(void *arg) · 15 unmodified lines
24432316 list = next;
24442317 }
24452318 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
2446− ACCESS_ONCE(rdp->nocb_p_count) = rdp->nocb_p_count - c;
2447− ACCESS_ONCE(rdp->nocb_p_count_lazy) =
2448− rdp->nocb_p_count_lazy - cl;
2319+ smp_mb__before_atomic(); /* _add after CB invocation. */
2320+ atomic_long_add(-c, &rdp->nocb_q_count);
2321+ atomic_long_add(-cl, &rdp->nocb_q_count_lazy);
24492322 rdp->n_nocbs_invoked += c;
24502323 }
24512324 return 0;
kernel/rcu/tree_trace.c+6−2
@@ -46,6 +46,8 @@ · 45 unmodified lines
4646 #define RCU_TREE_NONCORE
4747 #include "tree.h"
4848
49+DECLARE_PER_CPU_SHARED_ALIGNED(unsigned long, rcu_qs_ctr);
50+
4951 static int r_open(struct inode *inode, struct file *file,
5052 const struct seq_operations *op)
5153 {
@@ -115,11 +117,13 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp) · 63 unmodified lines
115117
116118 if (!rdp->beenonline)
117119 return;
118− seq_printf(m, "%3d%cc=%ld g=%ld pq=%d qp=%d",
120+ seq_printf(m, "%3d%cc=%ld g=%ld pq=%d/%d qp=%d",
119121 rdp->cpu,
120122 cpu_is_offline(rdp->cpu) ? '!' : ' ',
121123 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
122− rdp->passed_quiesce, rdp->qs_pending);
124+ rdp->passed_quiesce,
125+ rdp->rcu_qs_ctr_snap == per_cpu(rcu_qs_ctr, rdp->cpu),
126+ rdp->qs_pending);
123127 seq_printf(m, " dt=%d/%llx/%d df=%lu",
124128 atomic_read(&rdp->dynticks->dynticks),
125129 rdp->dynticks->dynticks_nesting,
kernel/softirq.c+1−2
@@ -656,9 +656,8 @@ static void run_ksoftirqd(unsigned int cpu) · 655 unmodified lines
656656 * in the task stack here.
657657 */
658658 __do_softirq();
659− rcu_note_context_switch();
660659 local_irq_enable();
661− cond_resched();
660+ cond_resched_rcu_qs();
662661 return;
663662 }
664663 local_irq_enable();
lib/Kconfig.debug+2−1
@@ -1215,6 +1215,7 @@ config RCU_TORTURE_TEST · 1214 unmodified lines
12151215 tristate "torture tests for RCU"
12161216 depends on DEBUG_KERNEL
12171217 select TORTURE_TEST
1218+ select SRCU
12181219 default n
12191220 help
12201221 This option provides a kernel module that runs torture tests
@@ -1257,7 +1258,7 @@ config RCU_CPU_STALL_TIMEOUT · 36 unmodified lines
12571258 config RCU_CPU_STALL_INFO
12581259 bool "Print additional diagnostics on RCU CPU stall"
12591260 depends on (TREE_RCU || PREEMPT_RCU) && DEBUG_KERNEL
1260− default n
1261+ default y
12611262 help
12621263 For each stalled CPU that is aware of the current RCU grace
12631264 period, print out additional per-CPU diagnostic information
mm/Kconfig+1−0
@@ -325,6 +325,7 @@ config VIRT_TO_BUS · 324 unmodified lines
325325
326326 config MMU_NOTIFIER
327327 bool
328+ select SRCU
328329
329330 config KSM
330331 bool "Enable KSM for page merging"
security/tomoyo/Kconfig+1−0
@@ -5,6 +5,7 @@ config SECURITY_TOMOYO · 4 unmodified lines
55 select SECURITYFS
66 select SECURITY_PATH
77 select SECURITY_NETWORK
8+ select SRCU
89 default n
910 help
1011 This selects TOMOYO Linux, pathname-based access control.
tools/testing/selftests/rcutorture/bin/cpus2use.sh+1−1
@@ -24,7 +24,7 @@ · 23 unmodified lines
2424
2525 ncpus=`grep '^processor' /proc/cpuinfo | wc -l`
2626 idlecpus=`mpstat | tail -1 | \
27− awk -v ncpus=$ncpus '{ print ncpus * ($7 + $12) / 100 }'`
27+ awk -v ncpus=$ncpus '{ print ncpus * ($7 + $NF) / 100 }'`
2828 awk -v ncpus=$ncpus -v idlecpus=$idlecpus < /dev/null '
2929 BEGIN {
3030 cpus2use = idlecpus;
tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh+18−0
@@ -30,6 +30,7 @@ else · 29 unmodified lines
3030 echo Unreadable results directory: $i
3131 exit 1
3232 fi
33+. tools/testing/selftests/rcutorture/bin/functions.sh
3334
3435 configfile=`echo $i | sed -e 's/^.*\///'`
3536 ngps=`grep ver: $i/console.log 2> /dev/null | tail -1 | sed -e 's/^.* ver: //' -e 's/ .*$//'`
@@ -48,4 +49,21 @@ else · 12 unmodified lines
4849 title="$title ($ngpsps per second)"
4950 fi
5051 echo $title
52+ nclosecalls=`grep --binary-files=text 'torture: Reader Batch' $i/console.log | tail -1 | awk '{for (i=NF-8;i<=NF;i++) sum+=$i; } END {print sum}'`
53+ if test -z "$nclosecalls"
54+ then
55+ exit 0
56+ fi
57+ if test "$nclosecalls" -eq 0
58+ then
59+ exit 0
60+ fi
61+ # Compute number of close calls per tenth of an hour
62+ nclosecalls10=`awk -v nclosecalls=$nclosecalls -v dur=$dur 'BEGIN { print int(nclosecalls * 36000 / dur) }' < /dev/null`
63+ if test $nclosecalls10 -gt 5 -a $nclosecalls -gt 1
64+ then
65+ print_bug $nclosecalls "Reader Batch close calls in" $(($dur/60)) minute run: $i
66+ else
67+ print_warning $nclosecalls "Reader Batch close calls in" $(($dur/60)) minute run: $i
68+ fi
5169 fi
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh+5−4
@@ -8,9 +8,9 @@ · 7 unmodified lines
88 #
99 # Usage: kvm-test-1-run.sh config builddir resdir minutes qemu-args boot_args
1010 #
11−# qemu-args defaults to "-nographic", along with arguments specifying the
12−# number of CPUs and other options generated from
13−# the underlying CPU architecture.
11+# qemu-args defaults to "-enable-kvm -soundhw pcspk -nographic", along with
12+# arguments specifying the number of CPUs and other
13+# options generated from the underlying CPU architecture.
1414 # boot_args defaults to value returned by the per_version_boot_params
1515 # shell function.
1616 #
@@ -138,7 +138,7 @@ then · 121 unmodified lines
138138 fi
139139
140140 # Generate -smp qemu argument.
141−qemu_args="-nographic $qemu_args"
141+qemu_args="-enable-kvm -soundhw pcspk -nographic $qemu_args"
142142 cpu_count=`configNR_CPUS.sh $config_template`
143143 cpu_count=`configfrag_boot_cpus "$boot_args" "$config_template" "$cpu_count"`
144144 vcpus=`identify_qemu_vcpus`
@@ -168,6 +168,7 @@ then · 23 unmodified lines
168168 touch $resdir/buildonly
169169 exit 0
170170 fi
171+echo "NOTE: $QEMU either did not run or was interactive" > $builddir/console.log
171172 echo $QEMU $qemu_args -m 512 -kernel $resdir/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
172173 ( $QEMU $qemu_args -m 512 -kernel $resdir/bzImage -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval ) &
173174 qemu_pid=$!
tools/testing/selftests/rcutorture/bin/parse-build.sh+13−7
@@ -26,12 +26,15 @@ · 25 unmodified lines
2626 #
2727 # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
2828
29−T=$1
29+F=$1
3030 title=$2
31+T=/tmp/parse-build.sh.$$
32+trap 'rm -rf $T' 0
33+mkdir $T
3134
3235 . functions.sh
3336
34−if grep -q CC < $T
37+if grep -q CC < $F
3538 then
3639 :
3740 else
@@ -39,18 +42,21 @@ else · 1 unmodified line
3942 exit 1
4043 fi
4144
42−if grep -q "error:" < $T
45+if grep -q "error:" < $F
4346 then
4447 print_bug $title build errors:
45− grep "error:" < $T
48+ grep "error:" < $F
4649 exit 2
4750 fi
48−exit 0
4951
50−if egrep -q "rcu[^/]*\.c.*warning:|rcu.*\.h.*warning:" < $T
52+grep warning: < $F > $T/warnings
53+grep "include/linux/*rcu*\.h:" $T/warnings > $T/hwarnings
54+grep "kernel/rcu/[^/]*:" $T/warnings > $T/cwarnings
55+cat $T/hwarnings $T/cwarnings > $T/rcuwarnings
56+if test -s $T/rcuwarnings
5157 then
5258 print_warning $title build errors:
53− egrep "rcu[^/]*\.c.*warning:|rcu.*\.h.*warning:" < $T
59+ cat $T/rcuwarnings
5460 exit 2
5561 fi
5662 exit 0
tools/testing/selftests/rcutorture/bin/parse-console.sh+1−1
@@ -36,7 +36,7 @@ if grep -Pq '\x00' < $file · 35 unmodified lines
3636 then
3737 print_warning Console output contains nul bytes, old qemu still running?
3838 fi
39−egrep 'Badness|WARNING:|Warn|BUG|===========|Call Trace:|Oops:' < $file | grep -v 'ODEBUG: ' | grep -v 'Warning: unable to open an initial console' > $T
39+egrep 'Badness|WARNING:|Warn|BUG|===========|Call Trace:|Oops:|Stall ended before state dump start' < $file | grep -v 'ODEBUG: ' | grep -v 'Warning: unable to open an initial console' > $T
4040 if test -s $T
4141 then
4242 print_warning Assertion failure in $file $title

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t