Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu into core/rcu

Pull RCU updates from Paul E. McKenney:

- Documentation updates.

- Miscellaneous fixes.

- Preemptible-RCU fixes, including fixing an old bug in the
interaction of RCU priority boosting and CPU hotplug.

- SRCU updates.

- RCU CPU stall-warning updates.

- RCU torture-test updates.

Signed-off-by: Ingo Molnar <mingo@kernel.org>

+658 -587
+15 -1
Documentation/RCU/stallwarn.txt
··· 15 15 21 seconds. 16 16 17 17 This configuration parameter may be changed at runtime via the 18 - /sys/module/rcutree/parameters/rcu_cpu_stall_timeout, however 18 + /sys/module/rcupdate/parameters/rcu_cpu_stall_timeout, however 19 19 this parameter is checked only at the beginning of a cycle. 20 20 So if you are 10 seconds into a 40-second stall, setting this 21 21 sysfs parameter to (say) five will shorten the timeout for the ··· 152 152 "D" indicates that dyntick-idle processing is enabled ("." is printed 153 153 otherwise, for example, if disabled via the "nohz=" kernel boot parameter). 154 154 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 + 155 164 156 165 Multiple Warnings From One Stall 157 166 ··· 195 186 if the looping in the kernel is really expected and desirable 196 187 behavior, you might need to replace some of the cond_resched() 197 188 calls with calls to cond_resched_rcu_qs(). 189 + 190 + o Anything that prevents RCU's grace-period kthreads from running. 191 + This can result in the "All QSes seen" console-log message. 192 + This message will include information on when the kthread last 193 + ran and how often it should be expected to run. 198 194 199 195 o A CPU-bound real-time task in a CONFIG_PREEMPT kernel, which might 200 196 happen to preempt a low-priority task in the middle of an RCU
+16 -16
Documentation/RCU/trace.txt
··· 56 56 57 57 The output of "cat rcu/rcu_preempt/rcudata" looks as follows: 58 58 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 67 67 68 68 This file has one line per CPU, or eight for this 8-CPU system. 69 69 The fields are as follows: ··· 188 188 Kernels compiled with CONFIG_RCU_BOOST=y display the following from 189 189 /debug/rcu/rcu_preempt/rcudata: 190 190 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 199 199 200 200 This is similar to the output discussed above, but contains the following 201 201 additional fields:
+45 -1
Documentation/memory-barriers.txt
··· 269 269 STORE *(A + 4) = Y; STORE *A = X; 270 270 STORE {*A, *(A + 4) } = {X, Y}; 271 271 272 + And there are anti-guarantees: 273 + 274 + (*) These guarantees do not apply to bitfields, because compilers often 275 + generate code to modify these using non-atomic read-modify-write 276 + sequences. Do not attempt to use bitfields to synchronize parallel 277 + algorithms. 278 + 279 + (*) Even in cases where bitfields are protected by locks, all fields 280 + in a given bitfield must be protected by one lock. If two fields 281 + in a given bitfield are protected by different locks, the compiler's 282 + non-atomic read-modify-write sequences can cause an update to one 283 + field to corrupt the value of an adjacent field. 284 + 285 + (*) These guarantees apply only to properly aligned and sized scalar 286 + variables. "Properly sized" currently means variables that are 287 + the same size as "char", "short", "int" and "long". "Properly 288 + aligned" means the natural alignment, thus no constraints for 289 + "char", two-byte alignment for "short", four-byte alignment for 290 + "int", and either four-byte or eight-byte alignment for "long", 291 + on 32-bit and 64-bit systems, respectively. Note that these 292 + guarantees were introduced into the C11 standard, so beware when 293 + using older pre-C11 compilers (for example, gcc 4.6). The portion 294 + of the standard containing this guarantee is Section 3.14, which 295 + defines "memory location" as follows: 296 + 297 + memory location 298 + either an object of scalar type, or a maximal sequence 299 + of adjacent bit-fields all having nonzero width 300 + 301 + NOTE 1: Two threads of execution can update and access 302 + separate memory locations without interfering with 303 + each other. 304 + 305 + NOTE 2: A bit-field and an adjacent non-bit-field member 306 + are in separate memory locations. The same applies 307 + to two bit-fields, if one is declared inside a nested 308 + structure declaration and the other is not, or if the two 309 + are separated by a zero-length bit-field declaration, 310 + or if they are separated by a non-bit-field member 311 + declaration. It is not safe to concurrently update two 312 + bit-fields in the same structure if all members declared 313 + between them are also bit-fields, no matter what the 314 + sizes of those intervening bit-fields happen to be. 315 + 272 316 273 317 ========================= 274 318 WHAT ARE MEMORY BARRIERS? ··· 794 750 However, they do -not- guarantee any other sort of ordering: 795 751 Not prior loads against later loads, nor prior stores against 796 752 later anything. If you need these other forms of ordering, 797 - use smb_rmb(), smp_wmb(), or, in the case of prior stores and 753 + use smp_rmb(), smp_wmb(), or, in the case of prior stores and 798 754 later loads, smp_mb(). 799 755 800 756 (*) If both legs of the "if" statement begin with identical stores
+1
arch/arm/kvm/Kconfig
··· 23 23 select HAVE_KVM_CPU_RELAX_INTERCEPT 24 24 select KVM_MMIO 25 25 select KVM_ARM_HOST 26 + select SRCU 26 27 depends on ARM_VIRT_EXT && ARM_LPAE 27 28 ---help--- 28 29 Support hosting virtualized guest machines. You will also
+1
arch/arm64/kvm/Kconfig
··· 26 26 select KVM_ARM_HOST 27 27 select KVM_ARM_VGIC 28 28 select KVM_ARM_TIMER 29 + select SRCU 29 30 ---help--- 30 31 Support hosting virtualized guest machines. 31 32
+1
arch/mips/kvm/Kconfig
··· 20 20 select PREEMPT_NOTIFIERS 21 21 select ANON_INODES 22 22 select KVM_MMIO 23 + select SRCU 23 24 ---help--- 24 25 Support for hosting Guest kernels. 25 26 Currently supported on MIPS32 processors.
+1
arch/powerpc/kvm/Kconfig
··· 21 21 select PREEMPT_NOTIFIERS 22 22 select ANON_INODES 23 23 select HAVE_KVM_EVENTFD 24 + select SRCU 24 25 25 26 config KVM_BOOK3S_HANDLER 26 27 bool
+1
arch/s390/kvm/Kconfig
··· 28 28 select HAVE_KVM_IRQCHIP 29 29 select HAVE_KVM_IRQFD 30 30 select HAVE_KVM_IRQ_ROUTING 31 + select SRCU 31 32 ---help--- 32 33 Support hosting paravirtualized guest machines using the SIE 33 34 virtualization capability on the mainframe. This should work
+1
arch/tile/kvm/Kconfig
··· 21 21 depends on HAVE_KVM && MODULES 22 22 select PREEMPT_NOTIFIERS 23 23 select ANON_INODES 24 + select SRCU 24 25 ---help--- 25 26 Support hosting paravirtualized guest machines. 26 27
+1
arch/x86/Kconfig
··· 138 138 select HAVE_ACPI_APEI_NMI if ACPI 139 139 select ACPI_LEGACY_TABLES_LOOKUP if ACPI 140 140 select X86_FEATURE_NAMES if PROC_FS 141 + select SRCU 141 142 142 143 config INSTRUCTION_DECODER 143 144 def_bool y
+1
arch/x86/kvm/Kconfig
··· 40 40 select HAVE_KVM_MSI 41 41 select HAVE_KVM_CPU_RELAX_INTERCEPT 42 42 select KVM_VFIO 43 + select SRCU 43 44 ---help--- 44 45 Support hosting fully virtualized guest machines using hardware 45 46 virtualization extensions. You will need a fairly recent
+1
drivers/clk/Kconfig
··· 13 13 bool 14 14 select HAVE_CLK_PREPARE 15 15 select CLKDEV_LOOKUP 16 + select SRCU 16 17 ---help--- 17 18 The common clock framework is a single definition of struct 18 19 clk, useful across many platforms, as well as an
+1
drivers/cpufreq/Kconfig
··· 2 2 3 3 config CPU_FREQ 4 4 bool "CPU Frequency scaling" 5 + select SRCU 5 6 help 6 7 CPU Frequency scaling allows you to change the clock speed of 7 8 CPUs on the fly. This is a nice method to save power, because
+1
drivers/devfreq/Kconfig
··· 1 1 menuconfig PM_DEVFREQ 2 2 bool "Generic Dynamic Voltage and Frequency Scaling (DVFS) support" 3 + select SRCU 3 4 help 4 5 A device may have a list of frequencies and voltages available. 5 6 devfreq, a generic DVFS framework can be registered for a device
+1
drivers/md/Kconfig
··· 5 5 menuconfig MD 6 6 bool "Multiple devices driver support (RAID and LVM)" 7 7 depends on BLOCK 8 + select SRCU 8 9 help 9 10 Support multiple physical spindles through a single logical device. 10 11 Required for RAID and logical volume management.
+1
drivers/net/Kconfig
··· 197 197 198 198 config NETPOLL 199 199 def_bool NETCONSOLE 200 + select SRCU 200 201 201 202 config NET_POLL_CONTROLLER 202 203 def_bool NETPOLL
+1
fs/btrfs/Kconfig
··· 8 8 select LZO_DECOMPRESS 9 9 select RAID6_PQ 10 10 select XOR_BLOCKS 11 + select SRCU 11 12 12 13 help 13 14 Btrfs is a general purpose copy-on-write filesystem with extents,
+1
fs/notify/Kconfig
··· 1 1 config FSNOTIFY 2 2 def_bool n 3 + select SRCU 3 4 4 5 source "fs/notify/dnotify/Kconfig" 5 6 source "fs/notify/inotify/Kconfig"
+1
fs/quota/Kconfig
··· 5 5 config QUOTA 6 6 bool "Quota support" 7 7 select QUOTACTL 8 + select SRCU 8 9 help 9 10 If you say Y here, you will be able to set per user limits for disk 10 11 usage (also called disk quotas). Currently, it works for the
+1 -1
include/linux/compiler.h
··· 385 385 386 386 /* Is this type a native word size -- useful for atomic operations */ 387 387 #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)) 389 389 #endif 390 390 391 391 /* Compile time object size, -1 for unknown */
+8 -8
include/linux/rculist.h
··· 524 524 * @member: the name of the hlist_node within the struct. 525 525 */ 526 526 #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); \ 529 529 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)) 532 532 533 533 /** 534 534 * hlist_for_each_entry_continue_rcu_bh - iterate over a hlist continuing after current point ··· 536 536 * @member: the name of the hlist_node within the struct. 537 537 */ 538 538 #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); \ 541 541 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)) 544 544 545 545 /** 546 546 * hlist_for_each_entry_from_rcu - iterate over a hlist continuing from current point
+7 -6
include/linux/rcupdate.h
··· 331 331 extern struct srcu_struct tasks_rcu_exit_srcu; 332 332 #define rcu_note_voluntary_context_switch(t) \ 333 333 do { \ 334 + rcu_all_qs(); \ 334 335 if (ACCESS_ONCE((t)->rcu_tasks_holdout)) \ 335 336 ACCESS_ONCE((t)->rcu_tasks_holdout) = false; \ 336 337 } while (0) 337 338 #else /* #ifdef CONFIG_TASKS_RCU */ 338 339 #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() 340 341 #endif /* #else #ifdef CONFIG_TASKS_RCU */ 341 342 342 343 /** ··· 583 582 }) 584 583 #define __rcu_dereference_check(p, c, space) \ 585 584 ({ \ 586 - typeof(*p) *_________p1 = (typeof(*p) *__force)ACCESS_ONCE(p); \ 585 + /* Dependency order vs. p above. */ \ 586 + typeof(*p) *________p1 = (typeof(*p) *__force)lockless_dereference(p); \ 587 587 rcu_lockdep_assert(c, "suspicious rcu_dereference_check() usage"); \ 588 588 rcu_dereference_sparse(p, space); \ 589 - smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ 590 - ((typeof(*p) __force __kernel *)(_________p1)); \ 589 + ((typeof(*p) __force __kernel *)(________p1)); \ 591 590 }) 592 591 #define __rcu_dereference_protected(p, c, space) \ 593 592 ({ \ ··· 604 603 }) 605 604 #define __rcu_dereference_index_check(p, c) \ 606 605 ({ \ 607 - typeof(p) _________p1 = ACCESS_ONCE(p); \ 606 + /* Dependency order vs. p above. */ \ 607 + typeof(p) _________p1 = lockless_dereference(p); \ 608 608 rcu_lockdep_assert(c, \ 609 609 "suspicious rcu_dereference_index_check() usage"); \ 610 - smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ 611 610 (_________p1); \ 612 611 }) 613 612
+40 -5
include/linux/rcutiny.h
··· 92 92 } 93 93 94 94 /* 95 - * Return the number of grace periods. 95 + * Return the number of grace periods started. 96 96 */ 97 - static inline long rcu_batches_completed(void) 97 + static inline unsigned long rcu_batches_started(void) 98 98 { 99 99 return 0; 100 100 } 101 101 102 102 /* 103 - * Return the number of bottom-half grace periods. 103 + * Return the number of bottom-half grace periods started. 104 104 */ 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) 106 138 { 107 139 return 0; 108 140 } ··· 186 154 return true; 187 155 } 188 156 189 - 190 157 #endif /* #else defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) */ 158 + 159 + static inline void rcu_all_qs(void) 160 + { 161 + } 191 162 192 163 #endif /* __LINUX_RCUTINY_H */
+8 -3
include/linux/rcutree.h
··· 81 81 82 82 extern unsigned long rcutorture_testseq; 83 83 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); 87 90 void show_rcu_gp_kthreads(void); 88 91 89 92 void rcu_force_quiescent_state(void); ··· 99 96 extern int rcu_scheduler_active __read_mostly; 100 97 101 98 bool rcu_is_watching(void); 99 + 100 + void rcu_all_qs(void); 102 101 103 102 #endif /* __LINUX_RCUTREE_H */
+6 -8
include/linux/srcu.h
··· 45 45 #define RCU_BATCH_INIT(name) { NULL, &(name.head) } 46 46 47 47 struct srcu_struct { 48 - unsigned completed; 48 + unsigned long completed; 49 49 struct srcu_struct_array __percpu *per_cpu_ref; 50 50 spinlock_t queue_lock; /* protect ->batch_queue, ->running */ 51 51 bool running; ··· 102 102 * define and init a srcu struct at build time. 103 103 * dont't call init_srcu_struct() nor cleanup_srcu_struct() on it. 104 104 */ 105 - #define DEFINE_SRCU(name) \ 105 + #define __DEFINE_SRCU(name, is_static) \ 106 106 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) 112 110 113 111 /** 114 112 * call_srcu() - Queue a callback for invocation after an SRCU grace period ··· 133 135 void __srcu_read_unlock(struct srcu_struct *sp, int idx) __releases(sp); 134 136 void synchronize_srcu(struct srcu_struct *sp); 135 137 void synchronize_srcu_expedited(struct srcu_struct *sp); 136 - long srcu_batches_completed(struct srcu_struct *sp); 138 + unsigned long srcu_batches_completed(struct srcu_struct *sp); 137 139 void srcu_barrier(struct srcu_struct *sp); 138 140 139 141 #ifdef CONFIG_DEBUG_LOCK_ALLOC
+13 -5
init/Kconfig
··· 470 470 config TREE_RCU 471 471 bool "Tree-based hierarchical RCU" 472 472 depends on !PREEMPT && SMP 473 - select IRQ_WORK 474 473 help 475 474 This option selects the RCU implementation that is 476 475 designed for very large SMP system with hundreds or ··· 479 480 config PREEMPT_RCU 480 481 bool "Preemptible tree-based hierarchical RCU" 481 482 depends on PREEMPT 482 - select IRQ_WORK 483 483 help 484 484 This option selects the RCU implementation that is 485 485 designed for very large SMP systems with hundreds or ··· 499 501 500 502 endchoice 501 503 504 + config SRCU 505 + bool 506 + help 507 + This option selects the sleepable version of RCU. This version 508 + permits arbitrary sleeping or blocking within RCU read-side critical 509 + sections. 510 + 502 511 config TASKS_RCU 503 512 bool "Task_based RCU implementation using voluntary context switch" 504 513 default n 514 + select SRCU 505 515 help 506 516 This option enables a task-based RCU implementation that uses 507 517 only voluntary context switch (not preemption!), idle, and ··· 674 668 675 669 config RCU_KTHREAD_PRIO 676 670 int "Real-time priority to use for RCU worker threads" 677 - range 1 99 678 - depends on RCU_BOOST 679 - default 1 671 + range 1 99 if RCU_BOOST 672 + range 0 99 if !RCU_BOOST 673 + default 1 if RCU_BOOST 674 + default 0 if !RCU_BOOST 680 675 help 681 676 This option specifies the SCHED_FIFO priority value that will be 682 677 assigned to the rcuc/n and rcub/n threads and is also the value ··· 1602 1595 depends on HAVE_PERF_EVENTS 1603 1596 select ANON_INODES 1604 1597 select IRQ_WORK 1598 + select SRCU 1605 1599 help 1606 1600 Enable kernel support for various performance events provided 1607 1601 by software and hardware.
+23 -33
kernel/cpu.c
··· 58 58 59 59 static struct { 60 60 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; 62 65 /* 63 66 * Also blocks the new readers during 64 67 * an ongoing cpu hotplug operation. 65 68 */ 66 - int refcount; 67 - /* And allows lockless put_online_cpus(). */ 68 - atomic_t puts_pending; 69 + atomic_t refcount; 69 70 70 71 #ifdef CONFIG_DEBUG_LOCK_ALLOC 71 72 struct lockdep_map dep_map; 72 73 #endif 73 74 } cpu_hotplug = { 74 75 .active_writer = NULL, 76 + .wq = __WAIT_QUEUE_HEAD_INITIALIZER(cpu_hotplug.wq), 75 77 .lock = __MUTEX_INITIALIZER(cpu_hotplug.lock), 76 - .refcount = 0, 77 78 #ifdef CONFIG_DEBUG_LOCK_ALLOC 78 79 .dep_map = {.name = "cpu_hotplug.lock" }, 79 80 #endif ··· 87 86 #define cpuhp_lock_acquire() lock_map_acquire(&cpu_hotplug.dep_map) 88 87 #define cpuhp_lock_release() lock_map_release(&cpu_hotplug.dep_map) 89 88 90 - static void apply_puts_pending(int max) 91 - { 92 - int delta; 93 - 94 - if (atomic_read(&cpu_hotplug.puts_pending) >= max) { 95 - delta = atomic_xchg(&cpu_hotplug.puts_pending, 0); 96 - cpu_hotplug.refcount -= delta; 97 - } 98 - } 99 89 100 90 void get_online_cpus(void) 101 91 { ··· 95 103 return; 96 104 cpuhp_lock_acquire_read(); 97 105 mutex_lock(&cpu_hotplug.lock); 98 - apply_puts_pending(65536); 99 - cpu_hotplug.refcount++; 106 + atomic_inc(&cpu_hotplug.refcount); 100 107 mutex_unlock(&cpu_hotplug.lock); 101 108 } 102 109 EXPORT_SYMBOL_GPL(get_online_cpus); ··· 107 116 if (!mutex_trylock(&cpu_hotplug.lock)) 108 117 return false; 109 118 cpuhp_lock_acquire_tryread(); 110 - apply_puts_pending(65536); 111 - cpu_hotplug.refcount++; 119 + atomic_inc(&cpu_hotplug.refcount); 112 120 mutex_unlock(&cpu_hotplug.lock); 113 121 return true; 114 122 } ··· 115 125 116 126 void put_online_cpus(void) 117 127 { 128 + int refcount; 129 + 118 130 if (cpu_hotplug.active_writer == current) 119 131 return; 120 - if (!mutex_trylock(&cpu_hotplug.lock)) { 121 - atomic_inc(&cpu_hotplug.puts_pending); 122 - cpuhp_lock_release(); 123 - return; 124 - } 125 132 126 - if (WARN_ON(!cpu_hotplug.refcount)) 127 - cpu_hotplug.refcount++; /* try to fix things up */ 133 + refcount = atomic_dec_return(&cpu_hotplug.refcount); 134 + if (WARN_ON(refcount < 0)) /* try to fix things up */ 135 + atomic_inc(&cpu_hotplug.refcount); 128 136 129 - if (!--cpu_hotplug.refcount && unlikely(cpu_hotplug.active_writer)) 130 - wake_up_process(cpu_hotplug.active_writer); 131 - mutex_unlock(&cpu_hotplug.lock); 137 + if (refcount <= 0 && waitqueue_active(&cpu_hotplug.wq)) 138 + wake_up(&cpu_hotplug.wq); 139 + 132 140 cpuhp_lock_release(); 133 141 134 142 } ··· 156 168 */ 157 169 void cpu_hotplug_begin(void) 158 170 { 159 - cpu_hotplug.active_writer = current; 171 + DEFINE_WAIT(wait); 160 172 173 + cpu_hotplug.active_writer = current; 161 174 cpuhp_lock_acquire(); 175 + 162 176 for (;;) { 163 177 mutex_lock(&cpu_hotplug.lock); 164 - apply_puts_pending(1); 165 - if (likely(!cpu_hotplug.refcount)) 166 - break; 167 - __set_current_state(TASK_UNINTERRUPTIBLE); 178 + prepare_to_wait(&cpu_hotplug.wq, &wait, TASK_UNINTERRUPTIBLE); 179 + if (likely(!atomic_read(&cpu_hotplug.refcount))) 180 + break; 168 181 mutex_unlock(&cpu_hotplug.lock); 169 182 schedule(); 170 183 } 184 + finish_wait(&cpu_hotplug.wq, &wait); 171 185 } 172 186 173 187 void cpu_hotplug_done(void)
+3
kernel/notifier.c
··· 402 402 } 403 403 EXPORT_SYMBOL_GPL(raw_notifier_call_chain); 404 404 405 + #ifdef CONFIG_SRCU 405 406 /* 406 407 * SRCU notifier chain routines. Registration and unregistration 407 408 * use a mutex, and call_chain is synchronized by SRCU (no locks). ··· 528 527 nh->head = NULL; 529 528 } 530 529 EXPORT_SYMBOL_GPL(srcu_init_notifier_head); 530 + 531 + #endif /* CONFIG_SRCU */ 531 532 532 533 static ATOMIC_NOTIFIER_HEAD(die_chain); 533 534
+1
kernel/power/Kconfig
··· 251 251 252 252 config PM_OPP 253 253 bool 254 + select SRCU 254 255 ---help--- 255 256 SOCs have a standard set of tuples consisting of frequency and 256 257 voltage pairs that the device will support per voltage domain. This
+2 -1
kernel/rcu/Makefile
··· 1 - obj-y += update.o srcu.o 1 + obj-y += update.o 2 + obj-$(CONFIG_SRCU) += srcu.o 2 3 obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o 3 4 obj-$(CONFIG_TREE_RCU) += tree.o 4 5 obj-$(CONFIG_PREEMPT_RCU) += tree.o
+6
kernel/rcu/rcu.h
··· 137 137 138 138 void rcu_early_boot_tests(void); 139 139 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 + 140 146 #endif /* __LINUX_RCU_H */
+38 -28
kernel/rcu/rcutorture.c
··· 244 244 int (*readlock)(void); 245 245 void (*read_delay)(struct torture_random_state *rrsp); 246 246 void (*readunlock)(int idx); 247 - int (*completed)(void); 247 + unsigned long (*started)(void); 248 + unsigned long (*completed)(void); 248 249 void (*deferred_free)(struct rcu_torture *p); 249 250 void (*sync)(void); 250 251 void (*exp_sync)(void); ··· 295 294 static void rcu_torture_read_unlock(int idx) __releases(RCU) 296 295 { 297 296 rcu_read_unlock(); 298 - } 299 - 300 - static int rcu_torture_completed(void) 301 - { 302 - return rcu_batches_completed(); 303 297 } 304 298 305 299 /* ··· 352 356 cur_ops->deferred_free(rp); 353 357 } 354 358 355 - static int rcu_no_completed(void) 359 + static unsigned long rcu_no_completed(void) 356 360 { 357 361 return 0; 358 362 } ··· 373 377 .readlock = rcu_torture_read_lock, 374 378 .read_delay = rcu_read_delay, 375 379 .readunlock = rcu_torture_read_unlock, 376 - .completed = rcu_torture_completed, 380 + .started = rcu_batches_started, 381 + .completed = rcu_batches_completed, 377 382 .deferred_free = rcu_torture_deferred_free, 378 383 .sync = synchronize_rcu, 379 384 .exp_sync = synchronize_rcu_expedited, ··· 404 407 rcu_read_unlock_bh(); 405 408 } 406 409 407 - static int rcu_bh_torture_completed(void) 408 - { 409 - return rcu_batches_completed_bh(); 410 - } 411 - 412 410 static void rcu_bh_torture_deferred_free(struct rcu_torture *p) 413 411 { 414 412 call_rcu_bh(&p->rtort_rcu, rcu_torture_cb); ··· 415 423 .readlock = rcu_bh_torture_read_lock, 416 424 .read_delay = rcu_read_delay, /* just reuse rcu's version. */ 417 425 .readunlock = rcu_bh_torture_read_unlock, 418 - .completed = rcu_bh_torture_completed, 426 + .started = rcu_batches_started_bh, 427 + .completed = rcu_batches_completed_bh, 419 428 .deferred_free = rcu_bh_torture_deferred_free, 420 429 .sync = synchronize_rcu_bh, 421 430 .exp_sync = synchronize_rcu_bh_expedited, ··· 459 466 .readlock = rcu_torture_read_lock, 460 467 .read_delay = rcu_read_delay, /* just reuse rcu's version. */ 461 468 .readunlock = rcu_torture_read_unlock, 469 + .started = rcu_no_completed, 462 470 .completed = rcu_no_completed, 463 471 .deferred_free = rcu_busted_torture_deferred_free, 464 472 .sync = synchronize_rcu_busted, ··· 504 510 srcu_read_unlock(&srcu_ctl, idx); 505 511 } 506 512 507 - static int srcu_torture_completed(void) 513 + static unsigned long srcu_torture_completed(void) 508 514 { 509 515 return srcu_batches_completed(&srcu_ctl); 510 516 } ··· 558 564 .readlock = srcu_torture_read_lock, 559 565 .read_delay = srcu_read_delay, 560 566 .readunlock = srcu_torture_read_unlock, 567 + .started = NULL, 561 568 .completed = srcu_torture_completed, 562 569 .deferred_free = srcu_torture_deferred_free, 563 570 .sync = srcu_torture_synchronize, ··· 595 600 .readlock = sched_torture_read_lock, 596 601 .read_delay = rcu_read_delay, /* just reuse rcu's version. */ 597 602 .readunlock = sched_torture_read_unlock, 598 - .completed = rcu_no_completed, 603 + .started = rcu_batches_started_sched, 604 + .completed = rcu_batches_completed_sched, 599 605 .deferred_free = rcu_sched_torture_deferred_free, 600 606 .sync = synchronize_sched, 601 607 .exp_sync = synchronize_sched_expedited, ··· 634 638 .readlock = tasks_torture_read_lock, 635 639 .read_delay = rcu_read_delay, /* just reuse rcu's version. */ 636 640 .readunlock = tasks_torture_read_unlock, 641 + .started = rcu_no_completed, 637 642 .completed = rcu_no_completed, 638 643 .deferred_free = rcu_tasks_torture_deferred_free, 639 644 .sync = synchronize_rcu_tasks, ··· 1012 1015 static void rcu_torture_timer(unsigned long unused) 1013 1016 { 1014 1017 int idx; 1015 - int completed; 1016 - int completed_end; 1018 + unsigned long started; 1019 + unsigned long completed; 1017 1020 static DEFINE_TORTURE_RANDOM(rand); 1018 1021 static DEFINE_SPINLOCK(rand_lock); 1019 1022 struct rcu_torture *p; ··· 1021 1024 unsigned long long ts; 1022 1025 1023 1026 idx = cur_ops->readlock(); 1024 - completed = cur_ops->completed(); 1027 + if (cur_ops->started) 1028 + started = cur_ops->started(); 1029 + else 1030 + started = cur_ops->completed(); 1025 1031 ts = rcu_trace_clock_local(); 1026 1032 p = rcu_dereference_check(rcu_torture_current, 1027 1033 rcu_read_lock_bh_held() || ··· 1047 1047 /* Should not happen, but... */ 1048 1048 pipe_count = RCU_TORTURE_PIPE_LEN; 1049 1049 } 1050 - completed_end = cur_ops->completed(); 1050 + completed = cur_ops->completed(); 1051 1051 if (pipe_count > 1) { 1052 1052 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu, ts, 1053 - completed, completed_end); 1053 + started, completed); 1054 1054 rcutorture_trace_dump(); 1055 1055 } 1056 1056 __this_cpu_inc(rcu_torture_count[pipe_count]); 1057 - completed = completed_end - completed; 1057 + completed = completed - started; 1058 + if (cur_ops->started) 1059 + completed++; 1058 1060 if (completed > RCU_TORTURE_PIPE_LEN) { 1059 1061 /* Should not happen, but... */ 1060 1062 completed = RCU_TORTURE_PIPE_LEN; ··· 1075 1073 static int 1076 1074 rcu_torture_reader(void *arg) 1077 1075 { 1078 - int completed; 1079 - int completed_end; 1076 + unsigned long started; 1077 + unsigned long completed; 1080 1078 int idx; 1081 1079 DEFINE_TORTURE_RANDOM(rand); 1082 1080 struct rcu_torture *p; ··· 1095 1093 mod_timer(&t, jiffies + 1); 1096 1094 } 1097 1095 idx = cur_ops->readlock(); 1098 - completed = cur_ops->completed(); 1096 + if (cur_ops->started) 1097 + started = cur_ops->started(); 1098 + else 1099 + started = cur_ops->completed(); 1099 1100 ts = rcu_trace_clock_local(); 1100 1101 p = rcu_dereference_check(rcu_torture_current, 1101 1102 rcu_read_lock_bh_held() || ··· 1119 1114 /* Should not happen, but... */ 1120 1115 pipe_count = RCU_TORTURE_PIPE_LEN; 1121 1116 } 1122 - completed_end = cur_ops->completed(); 1117 + completed = cur_ops->completed(); 1123 1118 if (pipe_count > 1) { 1124 1119 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu, 1125 - ts, completed, completed_end); 1120 + ts, started, completed); 1126 1121 rcutorture_trace_dump(); 1127 1122 } 1128 1123 __this_cpu_inc(rcu_torture_count[pipe_count]); 1129 - completed = completed_end - completed; 1124 + completed = completed - started; 1125 + if (cur_ops->started) 1126 + completed++; 1130 1127 if (completed > RCU_TORTURE_PIPE_LEN) { 1131 1128 /* Should not happen, but... */ 1132 1129 completed = RCU_TORTURE_PIPE_LEN; ··· 1427 1420 cur_ops->cb_barrier(); /* Implies smp_mb() for wait_event(). */ 1428 1421 if (atomic_read(&barrier_cbs_invoked) != n_barrier_cbs) { 1429 1422 n_rcu_torture_barrier_error++; 1423 + pr_err("barrier_cbs_invoked = %d, n_barrier_cbs = %d\n", 1424 + atomic_read(&barrier_cbs_invoked), 1425 + n_barrier_cbs); 1430 1426 WARN_ON_ONCE(1); 1431 1427 } 1432 1428 n_barrier_successes++;
+1 -1
kernel/rcu/srcu.c
··· 546 546 * Report the number of batches, correlated with, but not necessarily 547 547 * precisely the same as, the number of grace periods that have elapsed. 548 548 */ 549 - long srcu_batches_completed(struct srcu_struct *sp) 549 + unsigned long srcu_batches_completed(struct srcu_struct *sp) 550 550 { 551 551 return sp->completed; 552 552 }
+10 -103
kernel/rcu/tiny.c
··· 47 47 void (*func)(struct rcu_head *rcu), 48 48 struct rcu_ctrlblk *rcp); 49 49 50 - static long long rcu_dynticks_nesting = DYNTICK_TASK_EXIT_IDLE; 51 - 52 50 #include "tiny_plugin.h" 53 - 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 51 80 52 /* 81 53 * 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. 83 55 */ 84 56 void rcu_idle_enter(void) 85 57 { 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); 98 58 } 99 59 EXPORT_SYMBOL_GPL(rcu_idle_enter); 100 60 ··· 63 103 */ 64 104 void rcu_irq_exit(void) 65 105 { 66 - unsigned long flags; 67 - long long newval; 68 - 69 - local_irq_save(flags); 70 - newval = rcu_dynticks_nesting - 1; 71 - WARN_ON_ONCE(newval < 0); 72 - rcu_idle_enter_common(newval); 73 - local_irq_restore(flags); 74 106 } 75 107 EXPORT_SYMBOL_GPL(rcu_irq_exit); 76 - 77 - /* Common code for rcu_idle_exit() and rcu_irq_enter(), see kernel/rcu/tree.c. */ 78 - static void rcu_idle_exit_common(long long oldval) 79 - { 80 - if (oldval) { 81 - RCU_TRACE(trace_rcu_dyntick(TPS("++="), 82 - oldval, rcu_dynticks_nesting)); 83 - return; 84 - } 85 - RCU_TRACE(trace_rcu_dyntick(TPS("End"), oldval, rcu_dynticks_nesting)); 86 - if (IS_ENABLED(CONFIG_RCU_TRACE) && !is_idle_task(current)) { 87 - struct task_struct *idle __maybe_unused = idle_task(smp_processor_id()); 88 - 89 - RCU_TRACE(trace_rcu_dyntick(TPS("Exit error: not idle task"), 90 - oldval, rcu_dynticks_nesting)); 91 - ftrace_dump(DUMP_ALL); 92 - WARN_ONCE(1, "Current pid: %d comm: %s / Idle pid: %d comm: %s", 93 - current->pid, current->comm, 94 - idle->pid, idle->comm); /* must be idle task! */ 95 - } 96 - } 97 108 98 109 /* 99 110 * Exit idle, so that we are no longer in an extended quiescent state. 100 111 */ 101 112 void rcu_idle_exit(void) 102 113 { 103 - unsigned long flags; 104 - long long oldval; 105 - 106 - local_irq_save(flags); 107 - oldval = rcu_dynticks_nesting; 108 - WARN_ON_ONCE(rcu_dynticks_nesting < 0); 109 - if (rcu_dynticks_nesting & DYNTICK_TASK_NEST_MASK) 110 - rcu_dynticks_nesting += DYNTICK_TASK_NEST_VALUE; 111 - else 112 - rcu_dynticks_nesting = DYNTICK_TASK_EXIT_IDLE; 113 - rcu_idle_exit_common(oldval); 114 - local_irq_restore(flags); 115 114 } 116 115 EXPORT_SYMBOL_GPL(rcu_idle_exit); 117 116 ··· 79 160 */ 80 161 void rcu_irq_enter(void) 81 162 { 82 - unsigned long flags; 83 - long long oldval; 84 - 85 - local_irq_save(flags); 86 - oldval = rcu_dynticks_nesting; 87 - rcu_dynticks_nesting++; 88 - WARN_ON_ONCE(rcu_dynticks_nesting == 0); 89 - rcu_idle_exit_common(oldval); 90 - local_irq_restore(flags); 91 163 } 92 164 EXPORT_SYMBOL_GPL(rcu_irq_enter); 93 165 ··· 89 179 */ 90 180 bool notrace __rcu_is_watching(void) 91 181 { 92 - return rcu_dynticks_nesting; 182 + return true; 93 183 } 94 184 EXPORT_SYMBOL(__rcu_is_watching); 95 185 96 186 #endif /* defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) */ 97 - 98 - /* 99 - * Test whether the current CPU was interrupted from idle. Nested 100 - * interrupts don't count, we must be running at the first interrupt 101 - * level. 102 - */ 103 - static int rcu_is_cpu_rrupt_from_idle(void) 104 - { 105 - return rcu_dynticks_nesting <= 1; 106 - } 107 187 108 188 /* 109 189 * Helper function for rcu_sched_qs() and rcu_bh_qs(). ··· 150 250 void rcu_check_callbacks(int user) 151 251 { 152 252 RCU_TRACE(check_cpu_stalls()); 153 - if (user || rcu_is_cpu_rrupt_from_idle()) 253 + if (user) 154 254 rcu_sched_qs(); 155 255 else if (!in_softirq()) 156 256 rcu_bh_qs(); ··· 257 357 rcp->curtail = &head->next; 258 358 RCU_TRACE(rcp->qlen++); 259 359 local_irq_restore(flags); 360 + 361 + if (unlikely(is_idle_task(current))) { 362 + /* force scheduling for rcu_sched_qs() */ 363 + resched_cpu(0); 364 + } 260 365 } 261 366 262 367 /* ··· 288 383 void __init rcu_init(void) 289 384 { 290 385 open_softirq(RCU_SOFTIRQ, rcu_process_callbacks); 386 + RCU_TRACE(reset_cpu_stall_ticks(&rcu_sched_ctrlblk)); 387 + RCU_TRACE(reset_cpu_stall_ticks(&rcu_bh_ctrlblk)); 291 388 292 389 rcu_early_boot_tests(); 293 390 }
+4 -5
kernel/rcu/tiny_plugin.h
··· 145 145 rcp->ticks_this_gp++; 146 146 j = jiffies; 147 147 js = ACCESS_ONCE(rcp->jiffies_stall); 148 - if (*rcp->curtail && ULONG_CMP_GE(j, js)) { 148 + if (rcp->rcucblist && ULONG_CMP_GE(j, js)) { 149 149 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, 151 151 jiffies - rcp->gp_start, rcp->qlen); 152 152 dump_stack(); 153 - } 154 - if (*rcp->curtail && ULONG_CMP_GE(j, js)) 155 153 ACCESS_ONCE(rcp->jiffies_stall) = jiffies + 156 154 3 * rcu_jiffies_till_stall_check() + 3; 157 - else if (ULONG_CMP_GE(j, js)) 155 + } else if (ULONG_CMP_GE(j, js)) { 158 156 ACCESS_ONCE(rcp->jiffies_stall) = jiffies + rcu_jiffies_till_stall_check(); 157 + } 159 158 } 160 159 161 160 static void reset_cpu_stall_ticks(struct rcu_ctrlblk *rcp)
+258 -97
kernel/rcu/tree.c
··· 156 156 static void invoke_rcu_core(void); 157 157 static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp); 158 158 159 + /* rcuc/rcub kthread realtime priority */ 160 + static int kthread_prio = CONFIG_RCU_KTHREAD_PRIO; 161 + module_param(kthread_prio, int, 0644); 162 + 159 163 /* 160 164 * Track the rcutorture test sequence number and the update version 161 165 * number within a given test. The rcutorture_testseq is incremented ··· 218 214 .dynticks_idle = ATOMIC_INIT(1), 219 215 #endif /* #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */ 220 216 }; 217 + 218 + DEFINE_PER_CPU_SHARED_ALIGNED(unsigned long, rcu_qs_ctr); 219 + EXPORT_PER_CPU_SYMBOL_GPL(rcu_qs_ctr); 221 220 222 221 /* 223 222 * Let the RCU core know that this CPU has gone through the scheduler, ··· 291 284 } 292 285 EXPORT_SYMBOL_GPL(rcu_note_context_switch); 293 286 287 + /* 288 + * Register a quiesecent state for all RCU flavors. If there is an 289 + * emergency, invoke rcu_momentary_dyntick_idle() to do a heavy-weight 290 + * dyntick-idle quiescent state visible to other CPUs (but only for those 291 + * RCU flavors in desparate need of a quiescent state, which will normally 292 + * be none of them). Either way, do a lightweight quiescent state for 293 + * all RCU flavors. 294 + */ 295 + void rcu_all_qs(void) 296 + { 297 + if (unlikely(raw_cpu_read(rcu_sched_qs_mask))) 298 + rcu_momentary_dyntick_idle(); 299 + this_cpu_inc(rcu_qs_ctr); 300 + } 301 + EXPORT_SYMBOL_GPL(rcu_all_qs); 302 + 294 303 static long blimit = 10; /* Maximum callbacks per rcu_do_batch. */ 295 304 static long qhimark = 10000; /* If this many pending, ignore blimit. */ 296 305 static long qlowmark = 100; /* Once only this many pending, use blimit. */ ··· 338 315 static int rcu_pending(void); 339 316 340 317 /* 341 - * Return the number of RCU-sched batches processed thus far for debug & stats. 318 + * Return the number of RCU batches started thus far for debug & stats. 342 319 */ 343 - long rcu_batches_completed_sched(void) 320 + unsigned long rcu_batches_started(void) 321 + { 322 + return rcu_state_p->gpnum; 323 + } 324 + EXPORT_SYMBOL_GPL(rcu_batches_started); 325 + 326 + /* 327 + * Return the number of RCU-sched batches started thus far for debug & stats. 328 + */ 329 + unsigned long rcu_batches_started_sched(void) 330 + { 331 + return rcu_sched_state.gpnum; 332 + } 333 + EXPORT_SYMBOL_GPL(rcu_batches_started_sched); 334 + 335 + /* 336 + * Return the number of RCU BH batches started thus far for debug & stats. 337 + */ 338 + unsigned long rcu_batches_started_bh(void) 339 + { 340 + return rcu_bh_state.gpnum; 341 + } 342 + EXPORT_SYMBOL_GPL(rcu_batches_started_bh); 343 + 344 + /* 345 + * Return the number of RCU batches completed thus far for debug & stats. 346 + */ 347 + unsigned long rcu_batches_completed(void) 348 + { 349 + return rcu_state_p->completed; 350 + } 351 + EXPORT_SYMBOL_GPL(rcu_batches_completed); 352 + 353 + /* 354 + * Return the number of RCU-sched batches completed thus far for debug & stats. 355 + */ 356 + unsigned long rcu_batches_completed_sched(void) 344 357 { 345 358 return rcu_sched_state.completed; 346 359 } 347 360 EXPORT_SYMBOL_GPL(rcu_batches_completed_sched); 348 361 349 362 /* 350 - * Return the number of RCU BH batches processed thus far for debug & stats. 363 + * Return the number of RCU BH batches completed thus far for debug & stats. 351 364 */ 352 - long rcu_batches_completed_bh(void) 365 + unsigned long rcu_batches_completed_bh(void) 353 366 { 354 367 return rcu_bh_state.completed; 355 368 } ··· 818 759 /** 819 760 * rcu_nmi_enter - inform RCU of entry to NMI context 820 761 * 821 - * If the CPU was idle with dynamic ticks active, and there is no 822 - * irq handler running, this updates rdtp->dynticks_nmi to let the 823 - * RCU grace-period handling know that the CPU is active. 762 + * If the CPU was idle from RCU's viewpoint, update rdtp->dynticks and 763 + * rdtp->dynticks_nmi_nesting to let the RCU grace-period handling know 764 + * that the CPU is active. This implementation permits nested NMIs, as 765 + * long as the nesting level does not overflow an int. (You will probably 766 + * run out of stack space first.) 824 767 */ 825 768 void rcu_nmi_enter(void) 826 769 { 827 770 struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); 771 + int incby = 2; 828 772 829 - if (rdtp->dynticks_nmi_nesting == 0 && 830 - (atomic_read(&rdtp->dynticks) & 0x1)) 831 - return; 832 - rdtp->dynticks_nmi_nesting++; 833 - smp_mb__before_atomic(); /* Force delay from prior write. */ 834 - atomic_inc(&rdtp->dynticks); 835 - /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */ 836 - smp_mb__after_atomic(); /* See above. */ 837 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1)); 773 + /* Complain about underflow. */ 774 + WARN_ON_ONCE(rdtp->dynticks_nmi_nesting < 0); 775 + 776 + /* 777 + * If idle from RCU viewpoint, atomically increment ->dynticks 778 + * to mark non-idle and increment ->dynticks_nmi_nesting by one. 779 + * Otherwise, increment ->dynticks_nmi_nesting by two. This means 780 + * if ->dynticks_nmi_nesting is equal to one, we are guaranteed 781 + * to be in the outermost NMI handler that interrupted an RCU-idle 782 + * period (observation due to Andy Lutomirski). 783 + */ 784 + if (!(atomic_read(&rdtp->dynticks) & 0x1)) { 785 + smp_mb__before_atomic(); /* Force delay from prior write. */ 786 + atomic_inc(&rdtp->dynticks); 787 + /* atomic_inc() before later RCU read-side crit sects */ 788 + smp_mb__after_atomic(); /* See above. */ 789 + WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1)); 790 + incby = 1; 791 + } 792 + rdtp->dynticks_nmi_nesting += incby; 793 + barrier(); 838 794 } 839 795 840 796 /** 841 797 * rcu_nmi_exit - inform RCU of exit from NMI context 842 798 * 843 - * If the CPU was idle with dynamic ticks active, and there is no 844 - * irq handler running, this updates rdtp->dynticks_nmi to let the 845 - * RCU grace-period handling know that the CPU is no longer active. 799 + * If we are returning from the outermost NMI handler that interrupted an 800 + * RCU-idle period, update rdtp->dynticks and rdtp->dynticks_nmi_nesting 801 + * to let the RCU grace-period handling know that the CPU is back to 802 + * being RCU-idle. 846 803 */ 847 804 void rcu_nmi_exit(void) 848 805 { 849 806 struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); 850 807 851 - if (rdtp->dynticks_nmi_nesting == 0 || 852 - --rdtp->dynticks_nmi_nesting != 0) 808 + /* 809 + * Check for ->dynticks_nmi_nesting underflow and bad ->dynticks. 810 + * (We are exiting an NMI handler, so RCU better be paying attention 811 + * to us!) 812 + */ 813 + WARN_ON_ONCE(rdtp->dynticks_nmi_nesting <= 0); 814 + WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1)); 815 + 816 + /* 817 + * If the nesting level is not 1, the CPU wasn't RCU-idle, so 818 + * leave it in non-RCU-idle state. 819 + */ 820 + if (rdtp->dynticks_nmi_nesting != 1) { 821 + rdtp->dynticks_nmi_nesting -= 2; 853 822 return; 823 + } 824 + 825 + /* This NMI interrupted an RCU-idle CPU, restore RCU-idleness. */ 826 + rdtp->dynticks_nmi_nesting = 0; 854 827 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */ 855 828 smp_mb__before_atomic(); /* See above. */ 856 829 atomic_inc(&rdtp->dynticks); ··· 989 898 trace_rcu_fqs(rdp->rsp->name, rdp->gpnum, rdp->cpu, TPS("dti")); 990 899 return 1; 991 900 } else { 901 + if (ULONG_CMP_LT(ACCESS_ONCE(rdp->gpnum) + ULONG_MAX / 4, 902 + rdp->mynode->gpnum)) 903 + ACCESS_ONCE(rdp->gpwrap) = true; 992 904 return 0; 993 905 } 994 906 } 995 - 996 - /* 997 - * This function really isn't for public consumption, but RCU is special in 998 - * that context switches can allow the state machine to make progress. 999 - */ 1000 - extern void resched_cpu(int cpu); 1001 907 1002 908 /* 1003 909 * Return true if the specified CPU has passed through a quiescent ··· 1099 1011 j1 = rcu_jiffies_till_stall_check(); 1100 1012 ACCESS_ONCE(rsp->jiffies_stall) = j + j1; 1101 1013 rsp->jiffies_resched = j + j1 / 2; 1014 + rsp->n_force_qs_gpstart = ACCESS_ONCE(rsp->n_force_qs); 1015 + } 1016 + 1017 + /* 1018 + * Complain about starvation of grace-period kthread. 1019 + */ 1020 + static void rcu_check_gp_kthread_starvation(struct rcu_state *rsp) 1021 + { 1022 + unsigned long gpa; 1023 + unsigned long j; 1024 + 1025 + j = jiffies; 1026 + gpa = ACCESS_ONCE(rsp->gp_activity); 1027 + if (j - gpa > 2 * HZ) 1028 + pr_err("%s kthread starved for %ld jiffies!\n", 1029 + rsp->name, j - gpa); 1102 1030 } 1103 1031 1104 1032 /* ··· 1137 1033 } 1138 1034 } 1139 1035 1140 - static void print_other_cpu_stall(struct rcu_state *rsp) 1036 + static void print_other_cpu_stall(struct rcu_state *rsp, unsigned long gpnum) 1141 1037 { 1142 1038 int cpu; 1143 1039 long delta; 1144 1040 unsigned long flags; 1041 + unsigned long gpa; 1042 + unsigned long j; 1145 1043 int ndetected = 0; 1146 1044 struct rcu_node *rnp = rcu_get_root(rsp); 1147 1045 long totqlen = 0; ··· 1181 1075 raw_spin_unlock_irqrestore(&rnp->lock, flags); 1182 1076 } 1183 1077 1184 - /* 1185 - * Now rat on any tasks that got kicked up to the root rcu_node 1186 - * due to CPU offlining. 1187 - */ 1188 - rnp = rcu_get_root(rsp); 1189 - raw_spin_lock_irqsave(&rnp->lock, flags); 1190 - ndetected += rcu_print_task_stall(rnp); 1191 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1192 - 1193 1078 print_cpu_stall_info_end(); 1194 1079 for_each_possible_cpu(cpu) 1195 1080 totqlen += per_cpu_ptr(rsp->rda, cpu)->qlen; 1196 1081 pr_cont("(detected by %d, t=%ld jiffies, g=%ld, c=%ld, q=%lu)\n", 1197 1082 smp_processor_id(), (long)(jiffies - rsp->gp_start), 1198 1083 (long)rsp->gpnum, (long)rsp->completed, totqlen); 1199 - if (ndetected == 0) 1200 - pr_err("INFO: Stall ended before state dump start\n"); 1201 - else 1084 + if (ndetected) { 1202 1085 rcu_dump_cpu_stacks(rsp); 1086 + } else { 1087 + if (ACCESS_ONCE(rsp->gpnum) != gpnum || 1088 + ACCESS_ONCE(rsp->completed) == gpnum) { 1089 + pr_err("INFO: Stall ended before state dump start\n"); 1090 + } else { 1091 + j = jiffies; 1092 + gpa = ACCESS_ONCE(rsp->gp_activity); 1093 + pr_err("All QSes seen, last %s kthread activity %ld (%ld-%ld), jiffies_till_next_fqs=%ld\n", 1094 + rsp->name, j - gpa, j, gpa, 1095 + jiffies_till_next_fqs); 1096 + /* In this case, the current CPU might be at fault. */ 1097 + sched_show_task(current); 1098 + } 1099 + } 1203 1100 1204 1101 /* Complain about tasks blocking the grace period. */ 1205 - 1206 1102 rcu_print_detail_task_stall(rsp); 1103 + 1104 + rcu_check_gp_kthread_starvation(rsp); 1207 1105 1208 1106 force_quiescent_state(rsp); /* Kick them all. */ 1209 1107 } ··· 1233 1123 pr_cont(" (t=%lu jiffies g=%ld c=%ld q=%lu)\n", 1234 1124 jiffies - rsp->gp_start, 1235 1125 (long)rsp->gpnum, (long)rsp->completed, totqlen); 1126 + 1127 + rcu_check_gp_kthread_starvation(rsp); 1128 + 1236 1129 rcu_dump_cpu_stacks(rsp); 1237 1130 1238 1131 raw_spin_lock_irqsave(&rnp->lock, flags); ··· 1306 1193 ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY)) { 1307 1194 1308 1195 /* They had a few time units to dump stack, so complain. */ 1309 - print_other_cpu_stall(rsp); 1196 + print_other_cpu_stall(rsp, gpnum); 1310 1197 } 1311 1198 } 1312 1199 ··· 1643 1530 bool ret; 1644 1531 1645 1532 /* Handle the ends of any preceding grace periods first. */ 1646 - if (rdp->completed == rnp->completed) { 1533 + if (rdp->completed == rnp->completed && 1534 + !unlikely(ACCESS_ONCE(rdp->gpwrap))) { 1647 1535 1648 1536 /* No grace period end, so just accelerate recent callbacks. */ 1649 1537 ret = rcu_accelerate_cbs(rsp, rnp, rdp); ··· 1659 1545 trace_rcu_grace_period(rsp->name, rdp->gpnum, TPS("cpuend")); 1660 1546 } 1661 1547 1662 - if (rdp->gpnum != rnp->gpnum) { 1548 + if (rdp->gpnum != rnp->gpnum || unlikely(ACCESS_ONCE(rdp->gpwrap))) { 1663 1549 /* 1664 1550 * If the current grace period is waiting for this CPU, 1665 1551 * set up to detect a quiescent state, otherwise don't ··· 1668 1554 rdp->gpnum = rnp->gpnum; 1669 1555 trace_rcu_grace_period(rsp->name, rdp->gpnum, TPS("cpustart")); 1670 1556 rdp->passed_quiesce = 0; 1557 + rdp->rcu_qs_ctr_snap = __this_cpu_read(rcu_qs_ctr); 1671 1558 rdp->qs_pending = !!(rnp->qsmask & rdp->grpmask); 1672 1559 zero_cpu_stall_ticks(rdp); 1560 + ACCESS_ONCE(rdp->gpwrap) = false; 1673 1561 } 1674 1562 return ret; 1675 1563 } ··· 1685 1569 local_irq_save(flags); 1686 1570 rnp = rdp->mynode; 1687 1571 if ((rdp->gpnum == ACCESS_ONCE(rnp->gpnum) && 1688 - rdp->completed == ACCESS_ONCE(rnp->completed)) || /* w/out lock. */ 1572 + rdp->completed == ACCESS_ONCE(rnp->completed) && 1573 + !unlikely(ACCESS_ONCE(rdp->gpwrap))) || /* w/out lock. */ 1689 1574 !raw_spin_trylock(&rnp->lock)) { /* irqs already off, so later. */ 1690 1575 local_irq_restore(flags); 1691 1576 return; ··· 1706 1589 struct rcu_data *rdp; 1707 1590 struct rcu_node *rnp = rcu_get_root(rsp); 1708 1591 1592 + ACCESS_ONCE(rsp->gp_activity) = jiffies; 1709 1593 rcu_bind_gp_kthread(); 1710 1594 raw_spin_lock_irq(&rnp->lock); 1711 1595 smp_mb__after_unlock_lock(); ··· 1767 1649 rnp->grphi, rnp->qsmask); 1768 1650 raw_spin_unlock_irq(&rnp->lock); 1769 1651 cond_resched_rcu_qs(); 1652 + ACCESS_ONCE(rsp->gp_activity) = jiffies; 1770 1653 } 1771 1654 1772 1655 mutex_unlock(&rsp->onoff_mutex); ··· 1784 1665 unsigned long maxj; 1785 1666 struct rcu_node *rnp = rcu_get_root(rsp); 1786 1667 1668 + ACCESS_ONCE(rsp->gp_activity) = jiffies; 1787 1669 rsp->n_force_qs++; 1788 1670 if (fqs_state == RCU_SAVE_DYNTICK) { 1789 1671 /* Collect dyntick-idle snapshots. */ ··· 1823 1703 struct rcu_data *rdp; 1824 1704 struct rcu_node *rnp = rcu_get_root(rsp); 1825 1705 1706 + ACCESS_ONCE(rsp->gp_activity) = jiffies; 1826 1707 raw_spin_lock_irq(&rnp->lock); 1827 1708 smp_mb__after_unlock_lock(); 1828 1709 gp_duration = jiffies - rsp->gp_start; ··· 1860 1739 nocb += rcu_future_gp_cleanup(rsp, rnp); 1861 1740 raw_spin_unlock_irq(&rnp->lock); 1862 1741 cond_resched_rcu_qs(); 1742 + ACCESS_ONCE(rsp->gp_activity) = jiffies; 1863 1743 } 1864 1744 rnp = rcu_get_root(rsp); 1865 1745 raw_spin_lock_irq(&rnp->lock); ··· 1910 1788 if (rcu_gp_init(rsp)) 1911 1789 break; 1912 1790 cond_resched_rcu_qs(); 1791 + ACCESS_ONCE(rsp->gp_activity) = jiffies; 1913 1792 WARN_ON(signal_pending(current)); 1914 1793 trace_rcu_grace_period(rsp->name, 1915 1794 ACCESS_ONCE(rsp->gpnum), ··· 1954 1831 ACCESS_ONCE(rsp->gpnum), 1955 1832 TPS("fqsend")); 1956 1833 cond_resched_rcu_qs(); 1834 + ACCESS_ONCE(rsp->gp_activity) = jiffies; 1957 1835 } else { 1958 1836 /* Deal with stray signal. */ 1959 1837 cond_resched_rcu_qs(); 1838 + ACCESS_ONCE(rsp->gp_activity) = jiffies; 1960 1839 WARN_ON(signal_pending(current)); 1961 1840 trace_rcu_grace_period(rsp->name, 1962 1841 ACCESS_ONCE(rsp->gpnum), ··· 2135 2010 rnp = rdp->mynode; 2136 2011 raw_spin_lock_irqsave(&rnp->lock, flags); 2137 2012 smp_mb__after_unlock_lock(); 2138 - if (rdp->passed_quiesce == 0 || rdp->gpnum != rnp->gpnum || 2139 - rnp->completed == rnp->gpnum) { 2013 + if ((rdp->passed_quiesce == 0 && 2014 + rdp->rcu_qs_ctr_snap == __this_cpu_read(rcu_qs_ctr)) || 2015 + rdp->gpnum != rnp->gpnum || rnp->completed == rnp->gpnum || 2016 + rdp->gpwrap) { 2140 2017 2141 2018 /* 2142 2019 * The grace period in which this quiescent state was ··· 2147 2020 * within the current grace period. 2148 2021 */ 2149 2022 rdp->passed_quiesce = 0; /* need qs for new gp. */ 2023 + rdp->rcu_qs_ctr_snap = __this_cpu_read(rcu_qs_ctr); 2150 2024 raw_spin_unlock_irqrestore(&rnp->lock, flags); 2151 2025 return; 2152 2026 } ··· 2192 2064 * Was there a quiescent state since the beginning of the grace 2193 2065 * period? If no, then exit and wait for the next call. 2194 2066 */ 2195 - if (!rdp->passed_quiesce) 2067 + if (!rdp->passed_quiesce && 2068 + rdp->rcu_qs_ctr_snap == __this_cpu_read(rcu_qs_ctr)) 2196 2069 return; 2197 2070 2198 2071 /* ··· 2324 2195 } 2325 2196 2326 2197 /* 2198 + * All CPUs for the specified rcu_node structure have gone offline, 2199 + * and all tasks that were preempted within an RCU read-side critical 2200 + * section while running on one of those CPUs have since exited their RCU 2201 + * read-side critical section. Some other CPU is reporting this fact with 2202 + * the specified rcu_node structure's ->lock held and interrupts disabled. 2203 + * This function therefore goes up the tree of rcu_node structures, 2204 + * clearing the corresponding bits in the ->qsmaskinit fields. Note that 2205 + * the leaf rcu_node structure's ->qsmaskinit field has already been 2206 + * updated 2207 + * 2208 + * This function does check that the specified rcu_node structure has 2209 + * all CPUs offline and no blocked tasks, so it is OK to invoke it 2210 + * prematurely. That said, invoking it after the fact will cost you 2211 + * a needless lock acquisition. So once it has done its work, don't 2212 + * invoke it again. 2213 + */ 2214 + static void rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf) 2215 + { 2216 + long mask; 2217 + struct rcu_node *rnp = rnp_leaf; 2218 + 2219 + if (rnp->qsmaskinit || rcu_preempt_has_tasks(rnp)) 2220 + return; 2221 + for (;;) { 2222 + mask = rnp->grpmask; 2223 + rnp = rnp->parent; 2224 + if (!rnp) 2225 + break; 2226 + raw_spin_lock(&rnp->lock); /* irqs already disabled. */ 2227 + smp_mb__after_unlock_lock(); /* GP memory ordering. */ 2228 + rnp->qsmaskinit &= ~mask; 2229 + if (rnp->qsmaskinit) { 2230 + raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 2231 + return; 2232 + } 2233 + raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 2234 + } 2235 + } 2236 + 2237 + /* 2327 2238 * The CPU has been completely removed, and some other CPU is reporting 2328 2239 * this fact from process context. Do the remainder of the cleanup, 2329 2240 * including orphaning the outgoing CPU's RCU callbacks, and also ··· 2373 2204 static void rcu_cleanup_dead_cpu(int cpu, struct rcu_state *rsp) 2374 2205 { 2375 2206 unsigned long flags; 2376 - unsigned long mask; 2377 - int need_report = 0; 2378 2207 struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu); 2379 2208 struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */ 2380 2209 ··· 2386 2219 /* Orphan the dead CPU's callbacks, and adopt them if appropriate. */ 2387 2220 rcu_send_cbs_to_orphanage(cpu, rsp, rnp, rdp); 2388 2221 rcu_adopt_orphan_cbs(rsp, flags); 2222 + raw_spin_unlock_irqrestore(&rsp->orphan_lock, flags); 2389 2223 2390 - /* Remove the outgoing CPU from the masks in the rcu_node hierarchy. */ 2391 - mask = rdp->grpmask; /* rnp->grplo is constant. */ 2392 - do { 2393 - raw_spin_lock(&rnp->lock); /* irqs already disabled. */ 2394 - smp_mb__after_unlock_lock(); 2395 - rnp->qsmaskinit &= ~mask; 2396 - if (rnp->qsmaskinit != 0) { 2397 - if (rnp != rdp->mynode) 2398 - raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 2399 - break; 2400 - } 2401 - if (rnp == rdp->mynode) 2402 - need_report = rcu_preempt_offline_tasks(rsp, rnp, rdp); 2403 - else 2404 - raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 2405 - mask = rnp->grpmask; 2406 - rnp = rnp->parent; 2407 - } while (rnp != NULL); 2408 - 2409 - /* 2410 - * We still hold the leaf rcu_node structure lock here, and 2411 - * irqs are still disabled. The reason for this subterfuge is 2412 - * because invoking rcu_report_unblock_qs_rnp() with ->orphan_lock 2413 - * held leads to deadlock. 2414 - */ 2415 - raw_spin_unlock(&rsp->orphan_lock); /* irqs remain disabled. */ 2416 - rnp = rdp->mynode; 2417 - if (need_report & RCU_OFL_TASKS_NORM_GP) 2418 - rcu_report_unblock_qs_rnp(rnp, flags); 2419 - else 2420 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 2421 - if (need_report & RCU_OFL_TASKS_EXP_GP) 2422 - rcu_report_exp_rnp(rsp, rnp, true); 2224 + /* Remove outgoing CPU from mask in the leaf rcu_node structure. */ 2225 + raw_spin_lock_irqsave(&rnp->lock, flags); 2226 + smp_mb__after_unlock_lock(); /* Enforce GP memory-order guarantee. */ 2227 + rnp->qsmaskinit &= ~rdp->grpmask; 2228 + if (rnp->qsmaskinit == 0 && !rcu_preempt_has_tasks(rnp)) 2229 + rcu_cleanup_dead_rnp(rnp); 2230 + rcu_report_qs_rnp(rdp->grpmask, rsp, rnp, flags); /* Rlses rnp->lock. */ 2423 2231 WARN_ONCE(rdp->qlen != 0 || rdp->nxtlist != NULL, 2424 2232 "rcu_cleanup_dead_cpu: Callbacks on offline CPU %d: qlen=%lu, nxtlist=%p\n", 2425 2233 cpu, rdp->qlen, rdp->nxtlist); ··· 2407 2265 #else /* #ifdef CONFIG_HOTPLUG_CPU */ 2408 2266 2409 2267 static void rcu_cleanup_dying_cpu(struct rcu_state *rsp) 2268 + { 2269 + } 2270 + 2271 + static void __maybe_unused rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf) 2410 2272 { 2411 2273 } 2412 2274 ··· 2610 2464 } 2611 2465 raw_spin_unlock_irqrestore(&rnp->lock, flags); 2612 2466 } 2613 - rnp = rcu_get_root(rsp); 2614 - if (rnp->qsmask == 0) { 2615 - raw_spin_lock_irqsave(&rnp->lock, flags); 2616 - smp_mb__after_unlock_lock(); 2617 - rcu_initiate_boost(rnp, flags); /* releases rnp->lock. */ 2618 - } 2619 2467 } 2620 2468 2621 2469 /* ··· 2709 2569 * Schedule RCU callback invocation. If the specified type of RCU 2710 2570 * does not support RCU priority boosting, just do a direct call, 2711 2571 * otherwise wake up the per-CPU kernel kthread. Note that because we 2712 - * are running on the current CPU with interrupts disabled, the 2572 + * are running on the current CPU with softirqs disabled, the 2713 2573 * rcu_cpu_kthread_task cannot disappear out from under us. 2714 2574 */ 2715 2575 static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp) ··· 3249 3109 3250 3110 /* Is the RCU core waiting for a quiescent state from this CPU? */ 3251 3111 if (rcu_scheduler_fully_active && 3252 - rdp->qs_pending && !rdp->passed_quiesce) { 3112 + rdp->qs_pending && !rdp->passed_quiesce && 3113 + rdp->rcu_qs_ctr_snap == __this_cpu_read(rcu_qs_ctr)) { 3253 3114 rdp->n_rp_qs_pending++; 3254 - } else if (rdp->qs_pending && rdp->passed_quiesce) { 3115 + } else if (rdp->qs_pending && 3116 + (rdp->passed_quiesce || 3117 + rdp->rcu_qs_ctr_snap != __this_cpu_read(rcu_qs_ctr))) { 3255 3118 rdp->n_rp_report_qs++; 3256 3119 return 1; 3257 3120 } ··· 3278 3135 } 3279 3136 3280 3137 /* Has a new RCU grace period started? */ 3281 - if (ACCESS_ONCE(rnp->gpnum) != rdp->gpnum) { /* outside lock */ 3138 + if (ACCESS_ONCE(rnp->gpnum) != rdp->gpnum || 3139 + unlikely(ACCESS_ONCE(rdp->gpwrap))) { /* outside lock */ 3282 3140 rdp->n_rp_gp_started++; 3283 3141 return 1; 3284 3142 } ··· 3462 3318 } else { 3463 3319 _rcu_barrier_trace(rsp, "OnlineNoCB", cpu, 3464 3320 rsp->n_barrier_done); 3321 + smp_mb__before_atomic(); 3465 3322 atomic_inc(&rsp->barrier_cpu_count); 3466 3323 __call_rcu(&rdp->barrier_head, 3467 3324 rcu_barrier_callback, rsp, cpu, 0); ··· 3530 3385 /* Set up local state, ensuring consistent view of global state. */ 3531 3386 raw_spin_lock_irqsave(&rnp->lock, flags); 3532 3387 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo); 3533 - init_callback_list(rdp); 3534 - rdp->qlen_lazy = 0; 3535 - ACCESS_ONCE(rdp->qlen) = 0; 3536 3388 rdp->dynticks = &per_cpu(rcu_dynticks, cpu); 3537 3389 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE); 3538 3390 WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1); ··· 3586 3444 rdp->gpnum = rnp->completed; 3587 3445 rdp->completed = rnp->completed; 3588 3446 rdp->passed_quiesce = 0; 3447 + rdp->rcu_qs_ctr_snap = __this_cpu_read(rcu_qs_ctr); 3589 3448 rdp->qs_pending = 0; 3590 3449 trace_rcu_grace_period(rsp->name, rdp->gpnum, TPS("cpuonl")); 3591 3450 } ··· 3678 3535 static int __init rcu_spawn_gp_kthread(void) 3679 3536 { 3680 3537 unsigned long flags; 3538 + int kthread_prio_in = kthread_prio; 3681 3539 struct rcu_node *rnp; 3682 3540 struct rcu_state *rsp; 3541 + struct sched_param sp; 3683 3542 struct task_struct *t; 3543 + 3544 + /* Force priority into range. */ 3545 + if (IS_ENABLED(CONFIG_RCU_BOOST) && kthread_prio < 1) 3546 + kthread_prio = 1; 3547 + else if (kthread_prio < 0) 3548 + kthread_prio = 0; 3549 + else if (kthread_prio > 99) 3550 + kthread_prio = 99; 3551 + if (kthread_prio != kthread_prio_in) 3552 + pr_alert("rcu_spawn_gp_kthread(): Limited prio to %d from %d\n", 3553 + kthread_prio, kthread_prio_in); 3684 3554 3685 3555 rcu_scheduler_fully_active = 1; 3686 3556 for_each_rcu_flavor(rsp) { 3687 - t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name); 3557 + t = kthread_create(rcu_gp_kthread, rsp, "%s", rsp->name); 3688 3558 BUG_ON(IS_ERR(t)); 3689 3559 rnp = rcu_get_root(rsp); 3690 3560 raw_spin_lock_irqsave(&rnp->lock, flags); 3691 3561 rsp->gp_kthread = t; 3562 + if (kthread_prio) { 3563 + sp.sched_priority = kthread_prio; 3564 + sched_setscheduler_nocheck(t, SCHED_FIFO, &sp); 3565 + } 3566 + wake_up_process(t); 3692 3567 raw_spin_unlock_irqrestore(&rnp->lock, flags); 3693 3568 } 3694 3569 rcu_spawn_nocb_kthreads();
+16 -48
kernel/rcu/tree.h
··· 27 27 #include <linux/threads.h> 28 28 #include <linux/cpumask.h> 29 29 #include <linux/seqlock.h> 30 - #include <linux/irq_work.h> 31 30 32 31 /* 33 32 * Define shape of hierarchy based on NR_CPUS, CONFIG_RCU_FANOUT, and ··· 171 172 /* queued on this rcu_node structure that */ 172 173 /* are blocking the current grace period, */ 173 174 /* there can be no such task. */ 174 - struct completion boost_completion; 175 - /* Used to ensure that the rt_mutex used */ 176 - /* to carry out the boosting is fully */ 177 - /* released with no future boostee accesses */ 178 - /* before that rt_mutex is re-initialized. */ 179 175 struct rt_mutex boost_mtx; 180 176 /* Used only for the priority-boosting */ 181 177 /* side effect, not as a lock. */ ··· 251 257 /* in order to detect GP end. */ 252 258 unsigned long gpnum; /* Highest gp number that this CPU */ 253 259 /* is aware of having started. */ 260 + unsigned long rcu_qs_ctr_snap;/* Snapshot of rcu_qs_ctr to check */ 261 + /* for rcu_all_qs() invocations. */ 254 262 bool passed_quiesce; /* User-mode/idle loop etc. */ 255 263 bool qs_pending; /* Core waits for quiesc state. */ 256 264 bool beenonline; /* CPU online at least once. */ 265 + bool gpwrap; /* Possible gpnum/completed wrap. */ 257 266 struct rcu_node *mynode; /* This CPU's leaf of hierarchy */ 258 267 unsigned long grpmask; /* Mask to apply to leaf qsmask. */ 259 268 #ifdef CONFIG_RCU_CPU_STALL_INFO ··· 337 340 #ifdef CONFIG_RCU_NOCB_CPU 338 341 struct rcu_head *nocb_head; /* CBs waiting for kthread. */ 339 342 struct rcu_head **nocb_tail; 340 - atomic_long_t nocb_q_count; /* # CBs waiting for kthread */ 341 - atomic_long_t nocb_q_count_lazy; /* (approximate). */ 343 + atomic_long_t nocb_q_count; /* # CBs waiting for nocb */ 344 + atomic_long_t nocb_q_count_lazy; /* invocation (all stages). */ 342 345 struct rcu_head *nocb_follower_head; /* CBs ready to invoke. */ 343 346 struct rcu_head **nocb_follower_tail; 344 - atomic_long_t nocb_follower_count; /* # CBs ready to invoke. */ 345 - atomic_long_t nocb_follower_count_lazy; /* (approximate). */ 346 - int nocb_p_count; /* # CBs being invoked by kthread */ 347 - int nocb_p_count_lazy; /* (approximate). */ 348 347 wait_queue_head_t nocb_wq; /* For nocb kthreads to sleep on. */ 349 348 struct task_struct *nocb_kthread; 350 349 int nocb_defer_wakeup; /* Defer wakeup of nocb_kthread. */ ··· 349 356 struct rcu_head *nocb_gp_head ____cacheline_internodealigned_in_smp; 350 357 /* CBs waiting for GP. */ 351 358 struct rcu_head **nocb_gp_tail; 352 - long nocb_gp_count; 353 - long nocb_gp_count_lazy; 354 359 bool nocb_leader_sleep; /* Is the nocb leader thread asleep? */ 355 360 struct rcu_data *nocb_next_follower; 356 361 /* Next follower in wakeup chain. */ ··· 479 488 /* due to no GP active. */ 480 489 unsigned long gp_start; /* Time at which GP started, */ 481 490 /* but in jiffies. */ 491 + unsigned long gp_activity; /* Time of last GP kthread */ 492 + /* activity in jiffies. */ 482 493 unsigned long jiffies_stall; /* Time at which to check */ 483 494 /* for CPU stalls. */ 484 495 unsigned long jiffies_resched; /* Time at which to resched */ 485 496 /* a reluctant CPU. */ 497 + unsigned long n_force_qs_gpstart; /* Snapshot of n_force_qs at */ 498 + /* GP start. */ 486 499 unsigned long gp_max; /* Maximum GP duration in */ 487 500 /* jiffies. */ 488 501 const char *name; /* Name of structure. */ ··· 508 513 /* Sequence through rcu_state structures for each RCU flavor. */ 509 514 #define for_each_rcu_flavor(rsp) \ 510 515 list_for_each_entry((rsp), &rcu_struct_flavors, flavors) 511 - 512 - /* Return values for rcu_preempt_offline_tasks(). */ 513 - 514 - #define RCU_OFL_TASKS_NORM_GP 0x1 /* Tasks blocking normal */ 515 - /* GP were moved to root. */ 516 - #define RCU_OFL_TASKS_EXP_GP 0x2 /* Tasks blocking expedited */ 517 - /* GP were moved to root. */ 518 516 519 517 /* 520 518 * RCU implementation internal declarations: ··· 534 546 535 547 /* Forward declarations for rcutree_plugin.h */ 536 548 static void rcu_bootup_announce(void); 537 - long rcu_batches_completed(void); 538 549 static void rcu_preempt_note_context_switch(void); 539 550 static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp); 540 551 #ifdef CONFIG_HOTPLUG_CPU 541 - static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, 542 - unsigned long flags); 552 + static bool rcu_preempt_has_tasks(struct rcu_node *rnp); 543 553 #endif /* #ifdef CONFIG_HOTPLUG_CPU */ 544 554 static void rcu_print_detail_task_stall(struct rcu_state *rsp); 545 555 static int rcu_print_task_stall(struct rcu_node *rnp); 546 556 static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp); 547 - #ifdef CONFIG_HOTPLUG_CPU 548 - static int rcu_preempt_offline_tasks(struct rcu_state *rsp, 549 - struct rcu_node *rnp, 550 - struct rcu_data *rdp); 551 - #endif /* #ifdef CONFIG_HOTPLUG_CPU */ 552 557 static void rcu_preempt_check_callbacks(void); 553 558 void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); 554 - #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PREEMPT_RCU) 555 - static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp, 556 - bool wake); 557 - #endif /* #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PREEMPT_RCU) */ 558 559 static void __init __rcu_init_preempt(void); 559 560 static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags); 560 561 static void rcu_preempt_boost_start_gp(struct rcu_node *rnp); ··· 599 622 #endif /* #ifndef RCU_TREE_NONCORE */ 600 623 601 624 #ifdef CONFIG_RCU_TRACE 625 + /* Read out queue lengths for tracing. */ 626 + static inline void rcu_nocb_q_lengths(struct rcu_data *rdp, long *ql, long *qll) 627 + { 602 628 #ifdef CONFIG_RCU_NOCB_CPU 603 - /* Sum up queue lengths for tracing. */ 604 - static inline void rcu_nocb_q_lengths(struct rcu_data *rdp, long *ql, long *qll) 605 - { 606 - *ql = atomic_long_read(&rdp->nocb_q_count) + 607 - rdp->nocb_p_count + 608 - atomic_long_read(&rdp->nocb_follower_count) + 609 - rdp->nocb_p_count + rdp->nocb_gp_count; 610 - *qll = atomic_long_read(&rdp->nocb_q_count_lazy) + 611 - rdp->nocb_p_count_lazy + 612 - atomic_long_read(&rdp->nocb_follower_count_lazy) + 613 - rdp->nocb_p_count_lazy + rdp->nocb_gp_count_lazy; 614 - } 629 + *ql = atomic_long_read(&rdp->nocb_q_count); 630 + *qll = atomic_long_read(&rdp->nocb_q_count_lazy); 615 631 #else /* #ifdef CONFIG_RCU_NOCB_CPU */ 616 - static inline void rcu_nocb_q_lengths(struct rcu_data *rdp, long *ql, long *qll) 617 - { 618 632 *ql = 0; 619 633 *qll = 0; 620 - } 621 634 #endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */ 635 + } 622 636 #endif /* #ifdef CONFIG_RCU_TRACE */
+72 -199
kernel/rcu/tree_plugin.h
··· 34 34 35 35 #include "../locking/rtmutex_common.h" 36 36 37 - /* rcuc/rcub kthread realtime priority */ 38 - static int kthread_prio = CONFIG_RCU_KTHREAD_PRIO; 39 - module_param(kthread_prio, int, 0644); 40 - 41 37 /* 42 38 * Control variables for per-CPU and per-rcu_node kthreads. These 43 39 * handle all flavors of RCU. ··· 99 103 static struct rcu_state *rcu_state_p = &rcu_preempt_state; 100 104 101 105 static int rcu_preempted_readers_exp(struct rcu_node *rnp); 106 + static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp, 107 + bool wake); 102 108 103 109 /* 104 110 * Tell them what RCU they are running. ··· 110 112 pr_info("Preemptible hierarchical RCU implementation.\n"); 111 113 rcu_bootup_announce_oddness(); 112 114 } 113 - 114 - /* 115 - * Return the number of RCU-preempt batches processed thus far 116 - * for debug and statistics. 117 - */ 118 - static long rcu_batches_completed_preempt(void) 119 - { 120 - return rcu_preempt_state.completed; 121 - } 122 - EXPORT_SYMBOL_GPL(rcu_batches_completed_preempt); 123 - 124 - /* 125 - * Return the number of RCU batches processed thus far for debug & stats. 126 - */ 127 - long rcu_batches_completed(void) 128 - { 129 - return rcu_batches_completed_preempt(); 130 - } 131 - EXPORT_SYMBOL_GPL(rcu_batches_completed); 132 115 133 116 /* 134 117 * Record a preemptible-RCU quiescent state for the specified CPU. Note ··· 286 307 } 287 308 288 309 /* 310 + * Return true if the specified rcu_node structure has tasks that were 311 + * preempted within an RCU read-side critical section. 312 + */ 313 + static bool rcu_preempt_has_tasks(struct rcu_node *rnp) 314 + { 315 + return !list_empty(&rnp->blkd_tasks); 316 + } 317 + 318 + /* 289 319 * Handle special cases during rcu_read_unlock(), such as needing to 290 320 * notify RCU core processing or task having blocked during the RCU 291 321 * read-side critical section. 292 322 */ 293 323 void rcu_read_unlock_special(struct task_struct *t) 294 324 { 295 - int empty; 296 - int empty_exp; 297 - int empty_exp_now; 325 + bool empty; 326 + bool empty_exp; 327 + bool empty_norm; 328 + bool empty_exp_now; 298 329 unsigned long flags; 299 330 struct list_head *np; 300 331 #ifdef CONFIG_RCU_BOOST ··· 356 367 break; 357 368 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 358 369 } 359 - empty = !rcu_preempt_blocked_readers_cgp(rnp); 370 + empty = !rcu_preempt_has_tasks(rnp); 371 + empty_norm = !rcu_preempt_blocked_readers_cgp(rnp); 360 372 empty_exp = !rcu_preempted_readers_exp(rnp); 361 373 smp_mb(); /* ensure expedited fastpath sees end of RCU c-s. */ 362 374 np = rcu_next_node_entry(t, rnp); ··· 377 387 #endif /* #ifdef CONFIG_RCU_BOOST */ 378 388 379 389 /* 390 + * If this was the last task on the list, go see if we 391 + * need to propagate ->qsmaskinit bit clearing up the 392 + * rcu_node tree. 393 + */ 394 + if (!empty && !rcu_preempt_has_tasks(rnp)) 395 + rcu_cleanup_dead_rnp(rnp); 396 + 397 + /* 380 398 * If this was the last task on the current list, and if 381 399 * we aren't waiting on any CPUs, report the quiescent state. 382 400 * Note that rcu_report_unblock_qs_rnp() releases rnp->lock, 383 401 * so we must take a snapshot of the expedited state. 384 402 */ 385 403 empty_exp_now = !rcu_preempted_readers_exp(rnp); 386 - if (!empty && !rcu_preempt_blocked_readers_cgp(rnp)) { 404 + if (!empty_norm && !rcu_preempt_blocked_readers_cgp(rnp)) { 387 405 trace_rcu_quiescent_state_report(TPS("preempt_rcu"), 388 406 rnp->gpnum, 389 407 0, rnp->qsmask, ··· 406 408 407 409 #ifdef CONFIG_RCU_BOOST 408 410 /* Unboost if we were boosted. */ 409 - if (drop_boost_mutex) { 411 + if (drop_boost_mutex) 410 412 rt_mutex_unlock(&rnp->boost_mtx); 411 - complete(&rnp->boost_completion); 412 - } 413 413 #endif /* #ifdef CONFIG_RCU_BOOST */ 414 414 415 415 /* ··· 515 519 static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) 516 520 { 517 521 WARN_ON_ONCE(rcu_preempt_blocked_readers_cgp(rnp)); 518 - if (!list_empty(&rnp->blkd_tasks)) 522 + if (rcu_preempt_has_tasks(rnp)) 519 523 rnp->gp_tasks = rnp->blkd_tasks.next; 520 524 WARN_ON_ONCE(rnp->qsmask); 521 525 } 522 526 523 527 #ifdef CONFIG_HOTPLUG_CPU 524 - 525 - /* 526 - * Handle tasklist migration for case in which all CPUs covered by the 527 - * specified rcu_node have gone offline. Move them up to the root 528 - * rcu_node. The reason for not just moving them to the immediate 529 - * parent is to remove the need for rcu_read_unlock_special() to 530 - * make more than two attempts to acquire the target rcu_node's lock. 531 - * Returns true if there were tasks blocking the current RCU grace 532 - * period. 533 - * 534 - * Returns 1 if there was previously a task blocking the current grace 535 - * period on the specified rcu_node structure. 536 - * 537 - * The caller must hold rnp->lock with irqs disabled. 538 - */ 539 - static int rcu_preempt_offline_tasks(struct rcu_state *rsp, 540 - struct rcu_node *rnp, 541 - struct rcu_data *rdp) 542 - { 543 - struct list_head *lp; 544 - struct list_head *lp_root; 545 - int retval = 0; 546 - struct rcu_node *rnp_root = rcu_get_root(rsp); 547 - struct task_struct *t; 548 - 549 - if (rnp == rnp_root) { 550 - WARN_ONCE(1, "Last CPU thought to be offlined?"); 551 - return 0; /* Shouldn't happen: at least one CPU online. */ 552 - } 553 - 554 - /* If we are on an internal node, complain bitterly. */ 555 - WARN_ON_ONCE(rnp != rdp->mynode); 556 - 557 - /* 558 - * Move tasks up to root rcu_node. Don't try to get fancy for 559 - * this corner-case operation -- just put this node's tasks 560 - * at the head of the root node's list, and update the root node's 561 - * ->gp_tasks and ->exp_tasks pointers to those of this node's, 562 - * if non-NULL. This might result in waiting for more tasks than 563 - * absolutely necessary, but this is a good performance/complexity 564 - * tradeoff. 565 - */ 566 - if (rcu_preempt_blocked_readers_cgp(rnp) && rnp->qsmask == 0) 567 - retval |= RCU_OFL_TASKS_NORM_GP; 568 - if (rcu_preempted_readers_exp(rnp)) 569 - retval |= RCU_OFL_TASKS_EXP_GP; 570 - lp = &rnp->blkd_tasks; 571 - lp_root = &rnp_root->blkd_tasks; 572 - while (!list_empty(lp)) { 573 - t = list_entry(lp->next, typeof(*t), rcu_node_entry); 574 - raw_spin_lock(&rnp_root->lock); /* irqs already disabled */ 575 - smp_mb__after_unlock_lock(); 576 - list_del(&t->rcu_node_entry); 577 - t->rcu_blocked_node = rnp_root; 578 - list_add(&t->rcu_node_entry, lp_root); 579 - if (&t->rcu_node_entry == rnp->gp_tasks) 580 - rnp_root->gp_tasks = rnp->gp_tasks; 581 - if (&t->rcu_node_entry == rnp->exp_tasks) 582 - rnp_root->exp_tasks = rnp->exp_tasks; 583 - #ifdef CONFIG_RCU_BOOST 584 - if (&t->rcu_node_entry == rnp->boost_tasks) 585 - rnp_root->boost_tasks = rnp->boost_tasks; 586 - #endif /* #ifdef CONFIG_RCU_BOOST */ 587 - raw_spin_unlock(&rnp_root->lock); /* irqs still disabled */ 588 - } 589 - 590 - rnp->gp_tasks = NULL; 591 - rnp->exp_tasks = NULL; 592 - #ifdef CONFIG_RCU_BOOST 593 - rnp->boost_tasks = NULL; 594 - /* 595 - * In case root is being boosted and leaf was not. Make sure 596 - * that we boost the tasks blocking the current grace period 597 - * in this case. 598 - */ 599 - raw_spin_lock(&rnp_root->lock); /* irqs already disabled */ 600 - smp_mb__after_unlock_lock(); 601 - if (rnp_root->boost_tasks != NULL && 602 - rnp_root->boost_tasks != rnp_root->gp_tasks && 603 - rnp_root->boost_tasks != rnp_root->exp_tasks) 604 - rnp_root->boost_tasks = rnp_root->gp_tasks; 605 - raw_spin_unlock(&rnp_root->lock); /* irqs still disabled */ 606 - #endif /* #ifdef CONFIG_RCU_BOOST */ 607 - 608 - return retval; 609 - } 610 528 611 529 #endif /* #ifdef CONFIG_HOTPLUG_CPU */ 612 530 ··· 681 771 682 772 raw_spin_lock_irqsave(&rnp->lock, flags); 683 773 smp_mb__after_unlock_lock(); 684 - if (list_empty(&rnp->blkd_tasks)) { 774 + if (!rcu_preempt_has_tasks(rnp)) { 685 775 raw_spin_unlock_irqrestore(&rnp->lock, flags); 686 776 } else { 687 777 rnp->exp_tasks = rnp->blkd_tasks.next; ··· 843 933 } 844 934 845 935 /* 846 - * Return the number of RCU batches processed thus far for debug & stats. 847 - */ 848 - long rcu_batches_completed(void) 849 - { 850 - return rcu_batches_completed_sched(); 851 - } 852 - EXPORT_SYMBOL_GPL(rcu_batches_completed); 853 - 854 - /* 855 936 * Because preemptible RCU does not exist, we never have to check for 856 937 * CPUs being in quiescent states. 857 938 */ ··· 861 960 862 961 #ifdef CONFIG_HOTPLUG_CPU 863 962 864 - /* Because preemptible RCU does not exist, no quieting of tasks. */ 865 - static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, unsigned long flags) 866 - __releases(rnp->lock) 963 + /* 964 + * Because there is no preemptible RCU, there can be no readers blocked. 965 + */ 966 + static bool rcu_preempt_has_tasks(struct rcu_node *rnp) 867 967 { 868 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 968 + return false; 869 969 } 870 970 871 971 #endif /* #ifdef CONFIG_HOTPLUG_CPU */ ··· 898 996 WARN_ON_ONCE(rnp->qsmask); 899 997 } 900 998 901 - #ifdef CONFIG_HOTPLUG_CPU 902 - 903 - /* 904 - * Because preemptible RCU does not exist, it never needs to migrate 905 - * tasks that were blocked within RCU read-side critical sections, and 906 - * such non-existent tasks cannot possibly have been blocking the current 907 - * grace period. 908 - */ 909 - static int rcu_preempt_offline_tasks(struct rcu_state *rsp, 910 - struct rcu_node *rnp, 911 - struct rcu_data *rdp) 912 - { 913 - return 0; 914 - } 915 - 916 - #endif /* #ifdef CONFIG_HOTPLUG_CPU */ 917 - 918 999 /* 919 1000 * Because preemptible RCU does not exist, it never has any callbacks 920 1001 * to check. ··· 915 1030 synchronize_sched_expedited(); 916 1031 } 917 1032 EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); 918 - 919 - #ifdef CONFIG_HOTPLUG_CPU 920 - 921 - /* 922 - * Because preemptible RCU does not exist, there is never any need to 923 - * report on tasks preempted in RCU read-side critical sections during 924 - * expedited RCU grace periods. 925 - */ 926 - static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp, 927 - bool wake) 928 - { 929 - } 930 - 931 - #endif /* #ifdef CONFIG_HOTPLUG_CPU */ 932 1033 933 1034 /* 934 1035 * Because preemptible RCU does not exist, rcu_barrier() is just ··· 951 1080 952 1081 static void rcu_initiate_boost_trace(struct rcu_node *rnp) 953 1082 { 954 - if (list_empty(&rnp->blkd_tasks)) 1083 + if (!rcu_preempt_has_tasks(rnp)) 955 1084 rnp->n_balk_blkd_tasks++; 956 1085 else if (rnp->exp_tasks == NULL && rnp->gp_tasks == NULL) 957 1086 rnp->n_balk_exp_gp_tasks++; ··· 998 1127 struct task_struct *t; 999 1128 struct list_head *tb; 1000 1129 1001 - if (rnp->exp_tasks == NULL && rnp->boost_tasks == NULL) 1130 + if (ACCESS_ONCE(rnp->exp_tasks) == NULL && 1131 + ACCESS_ONCE(rnp->boost_tasks) == NULL) 1002 1132 return 0; /* Nothing left to boost. */ 1003 1133 1004 1134 raw_spin_lock_irqsave(&rnp->lock, flags); ··· 1047 1175 */ 1048 1176 t = container_of(tb, struct task_struct, rcu_node_entry); 1049 1177 rt_mutex_init_proxy_locked(&rnp->boost_mtx, t); 1050 - init_completion(&rnp->boost_completion); 1051 1178 raw_spin_unlock_irqrestore(&rnp->lock, flags); 1052 1179 /* Lock only for side effect: boosts task t's priority. */ 1053 1180 rt_mutex_lock(&rnp->boost_mtx); 1054 1181 rt_mutex_unlock(&rnp->boost_mtx); /* Then keep lockdep happy. */ 1055 - 1056 - /* Wait for boostee to be done w/boost_mtx before reinitializing. */ 1057 - wait_for_completion(&rnp->boost_completion); 1058 1182 1059 1183 return ACCESS_ONCE(rnp->exp_tasks) != NULL || 1060 1184 ACCESS_ONCE(rnp->boost_tasks) != NULL; ··· 1284 1416 for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++, mask >>= 1) 1285 1417 if ((mask & 0x1) && cpu != outgoingcpu) 1286 1418 cpumask_set_cpu(cpu, cm); 1287 - if (cpumask_weight(cm) == 0) { 1419 + if (cpumask_weight(cm) == 0) 1288 1420 cpumask_setall(cm); 1289 - for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++) 1290 - cpumask_clear_cpu(cpu, cm); 1291 - WARN_ON_ONCE(cpumask_weight(cm) == 0); 1292 - } 1293 1421 set_cpus_allowed_ptr(t, cm); 1294 1422 free_cpumask_var(cm); 1295 1423 } ··· 1310 1446 for_each_possible_cpu(cpu) 1311 1447 per_cpu(rcu_cpu_has_work, cpu) = 0; 1312 1448 BUG_ON(smpboot_register_percpu_thread(&rcu_cpu_thread_spec)); 1313 - rnp = rcu_get_root(rcu_state_p); 1314 - (void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp); 1315 - if (NUM_RCU_NODES > 1) { 1316 - rcu_for_each_leaf_node(rcu_state_p, rnp) 1317 - (void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp); 1318 - } 1449 + rcu_for_each_leaf_node(rcu_state_p, rnp) 1450 + (void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp); 1319 1451 } 1320 1452 1321 1453 static void rcu_prepare_kthreads(int cpu) ··· 1465 1605 * completed since we last checked and there are 1466 1606 * callbacks not yet ready to invoke. 1467 1607 */ 1468 - if (rdp->completed != rnp->completed && 1608 + if ((rdp->completed != rnp->completed || 1609 + unlikely(ACCESS_ONCE(rdp->gpwrap))) && 1469 1610 rdp->nxttail[RCU_DONE_TAIL] != rdp->nxttail[RCU_NEXT_TAIL]) 1470 1611 note_gp_changes(rsp, rdp); 1471 1612 ··· 1759 1898 ticks_value = rsp->gpnum - rdp->gpnum; 1760 1899 } 1761 1900 print_cpu_stall_fast_no_hz(fast_no_hz, cpu); 1762 - pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n", 1901 + pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u fqs=%ld %s\n", 1763 1902 cpu, ticks_value, ticks_title, 1764 1903 atomic_read(&rdtp->dynticks) & 0xfff, 1765 1904 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting, 1766 1905 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu), 1906 + ACCESS_ONCE(rsp->n_force_qs) - rsp->n_force_qs_gpstart, 1767 1907 fast_no_hz); 1768 1908 } 1769 1909 ··· 1918 2056 static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu) 1919 2057 { 1920 2058 struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu); 2059 + unsigned long ret; 2060 + #ifdef CONFIG_PROVE_RCU 1921 2061 struct rcu_head *rhp; 2062 + #endif /* #ifdef CONFIG_PROVE_RCU */ 1922 2063 1923 - /* No-CBs CPUs might have callbacks on any of three lists. */ 2064 + /* 2065 + * Check count of all no-CBs callbacks awaiting invocation. 2066 + * There needs to be a barrier before this function is called, 2067 + * but associated with a prior determination that no more 2068 + * callbacks would be posted. In the worst case, the first 2069 + * barrier in _rcu_barrier() suffices (but the caller cannot 2070 + * necessarily rely on this, not a substitute for the caller 2071 + * getting the concurrency design right!). There must also be 2072 + * a barrier between the following load an posting of a callback 2073 + * (if a callback is in fact needed). This is associated with an 2074 + * atomic_inc() in the caller. 2075 + */ 2076 + ret = atomic_long_read(&rdp->nocb_q_count); 2077 + 2078 + #ifdef CONFIG_PROVE_RCU 1924 2079 rhp = ACCESS_ONCE(rdp->nocb_head); 1925 2080 if (!rhp) 1926 2081 rhp = ACCESS_ONCE(rdp->nocb_gp_head); ··· 1951 2072 cpu, rhp->func); 1952 2073 WARN_ON_ONCE(1); 1953 2074 } 2075 + #endif /* #ifdef CONFIG_PROVE_RCU */ 1954 2076 1955 - return !!rhp; 2077 + return !!ret; 1956 2078 } 1957 2079 1958 2080 /* ··· 1975 2095 struct task_struct *t; 1976 2096 1977 2097 /* Enqueue the callback on the nocb list and update counts. */ 2098 + atomic_long_add(rhcount, &rdp->nocb_q_count); 2099 + /* rcu_barrier() relies on ->nocb_q_count add before xchg. */ 1978 2100 old_rhpp = xchg(&rdp->nocb_tail, rhtp); 1979 2101 ACCESS_ONCE(*old_rhpp) = rhp; 1980 - atomic_long_add(rhcount, &rdp->nocb_q_count); 1981 2102 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy); 1982 2103 smp_mb__after_atomic(); /* Store *old_rhpp before _wake test. */ 1983 2104 ··· 2169 2288 /* Move callbacks to wait-for-GP list, which is empty. */ 2170 2289 ACCESS_ONCE(rdp->nocb_head) = NULL; 2171 2290 rdp->nocb_gp_tail = xchg(&rdp->nocb_tail, &rdp->nocb_head); 2172 - rdp->nocb_gp_count = atomic_long_xchg(&rdp->nocb_q_count, 0); 2173 - rdp->nocb_gp_count_lazy = 2174 - atomic_long_xchg(&rdp->nocb_q_count_lazy, 0); 2175 2291 gotcbs = true; 2176 2292 } 2177 2293 ··· 2216 2338 /* Append callbacks to follower's "done" list. */ 2217 2339 tail = xchg(&rdp->nocb_follower_tail, rdp->nocb_gp_tail); 2218 2340 *tail = rdp->nocb_gp_head; 2219 - atomic_long_add(rdp->nocb_gp_count, &rdp->nocb_follower_count); 2220 - atomic_long_add(rdp->nocb_gp_count_lazy, 2221 - &rdp->nocb_follower_count_lazy); 2222 2341 smp_mb__after_atomic(); /* Store *tail before wakeup. */ 2223 2342 if (rdp != my_rdp && tail == &rdp->nocb_follower_head) { 2224 2343 /* ··· 2290 2415 trace_rcu_nocb_wake(rdp->rsp->name, rdp->cpu, "WokeNonEmpty"); 2291 2416 ACCESS_ONCE(rdp->nocb_follower_head) = NULL; 2292 2417 tail = xchg(&rdp->nocb_follower_tail, &rdp->nocb_follower_head); 2293 - c = atomic_long_xchg(&rdp->nocb_follower_count, 0); 2294 - cl = atomic_long_xchg(&rdp->nocb_follower_count_lazy, 0); 2295 - rdp->nocb_p_count += c; 2296 - rdp->nocb_p_count_lazy += cl; 2297 2418 2298 2419 /* Each pass through the following loop invokes a callback. */ 2299 - trace_rcu_batch_start(rdp->rsp->name, cl, c, -1); 2420 + trace_rcu_batch_start(rdp->rsp->name, 2421 + atomic_long_read(&rdp->nocb_q_count_lazy), 2422 + atomic_long_read(&rdp->nocb_q_count), -1); 2300 2423 c = cl = 0; 2301 2424 while (list) { 2302 2425 next = list->next; ··· 2316 2443 list = next; 2317 2444 } 2318 2445 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1); 2319 - ACCESS_ONCE(rdp->nocb_p_count) = rdp->nocb_p_count - c; 2320 - ACCESS_ONCE(rdp->nocb_p_count_lazy) = 2321 - rdp->nocb_p_count_lazy - cl; 2446 + smp_mb__before_atomic(); /* _add after CB invocation. */ 2447 + atomic_long_add(-c, &rdp->nocb_q_count); 2448 + atomic_long_add(-cl, &rdp->nocb_q_count_lazy); 2322 2449 rdp->n_nocbs_invoked += c; 2323 2450 } 2324 2451 return 0;
+6 -2
kernel/rcu/tree_trace.c
··· 46 46 #define RCU_TREE_NONCORE 47 47 #include "tree.h" 48 48 49 + DECLARE_PER_CPU_SHARED_ALIGNED(unsigned long, rcu_qs_ctr); 50 + 49 51 static int r_open(struct inode *inode, struct file *file, 50 52 const struct seq_operations *op) 51 53 { ··· 117 115 118 116 if (!rdp->beenonline) 119 117 return; 120 - seq_printf(m, "%3d%cc=%ld g=%ld pq=%d qp=%d", 118 + seq_printf(m, "%3d%cc=%ld g=%ld pq=%d/%d qp=%d", 121 119 rdp->cpu, 122 120 cpu_is_offline(rdp->cpu) ? '!' : ' ', 123 121 ulong2long(rdp->completed), ulong2long(rdp->gpnum), 124 - rdp->passed_quiesce, rdp->qs_pending); 122 + rdp->passed_quiesce, 123 + rdp->rcu_qs_ctr_snap == per_cpu(rcu_qs_ctr, rdp->cpu), 124 + rdp->qs_pending); 125 125 seq_printf(m, " dt=%d/%llx/%d df=%lu", 126 126 atomic_read(&rdp->dynticks->dynticks), 127 127 rdp->dynticks->dynticks_nesting,
+1 -2
kernel/softirq.c
··· 656 656 * in the task stack here. 657 657 */ 658 658 __do_softirq(); 659 - rcu_note_context_switch(); 660 659 local_irq_enable(); 661 - cond_resched(); 660 + cond_resched_rcu_qs(); 662 661 return; 663 662 } 664 663 local_irq_enable();
+2 -1
lib/Kconfig.debug
··· 1215 1215 tristate "torture tests for RCU" 1216 1216 depends on DEBUG_KERNEL 1217 1217 select TORTURE_TEST 1218 + select SRCU 1218 1219 default n 1219 1220 help 1220 1221 This option provides a kernel module that runs torture tests ··· 1258 1257 config RCU_CPU_STALL_INFO 1259 1258 bool "Print additional diagnostics on RCU CPU stall" 1260 1259 depends on (TREE_RCU || PREEMPT_RCU) && DEBUG_KERNEL 1261 - default n 1260 + default y 1262 1261 help 1263 1262 For each stalled CPU that is aware of the current RCU grace 1264 1263 period, print out additional per-CPU diagnostic information
+1
mm/Kconfig
··· 325 325 326 326 config MMU_NOTIFIER 327 327 bool 328 + select SRCU 328 329 329 330 config KSM 330 331 bool "Enable KSM for page merging"
+1
security/tomoyo/Kconfig
··· 5 5 select SECURITYFS 6 6 select SECURITY_PATH 7 7 select SECURITY_NETWORK 8 + select SRCU 8 9 default n 9 10 help 10 11 This selects TOMOYO Linux, pathname-based access control.
+1 -1
tools/testing/selftests/rcutorture/bin/cpus2use.sh
··· 24 24 25 25 ncpus=`grep '^processor' /proc/cpuinfo | wc -l` 26 26 idlecpus=`mpstat | tail -1 | \ 27 - awk -v ncpus=$ncpus '{ print ncpus * ($7 + $12) / 100 }'` 27 + awk -v ncpus=$ncpus '{ print ncpus * ($7 + $NF) / 100 }'` 28 28 awk -v ncpus=$ncpus -v idlecpus=$idlecpus < /dev/null ' 29 29 BEGIN { 30 30 cpus2use = idlecpus;
+18
tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh
··· 30 30 echo Unreadable results directory: $i 31 31 exit 1 32 32 fi 33 + . tools/testing/selftests/rcutorture/bin/functions.sh 33 34 34 35 configfile=`echo $i | sed -e 's/^.*\///'` 35 36 ngps=`grep ver: $i/console.log 2> /dev/null | tail -1 | sed -e 's/^.* ver: //' -e 's/ .*$//'` ··· 49 48 title="$title ($ngpsps per second)" 50 49 fi 51 50 echo $title 51 + 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}'` 52 + if test -z "$nclosecalls" 53 + then 54 + exit 0 55 + fi 56 + if test "$nclosecalls" -eq 0 57 + then 58 + exit 0 59 + fi 60 + # Compute number of close calls per tenth of an hour 61 + nclosecalls10=`awk -v nclosecalls=$nclosecalls -v dur=$dur 'BEGIN { print int(nclosecalls * 36000 / dur) }' < /dev/null` 62 + if test $nclosecalls10 -gt 5 -a $nclosecalls -gt 1 63 + then 64 + print_bug $nclosecalls "Reader Batch close calls in" $(($dur/60)) minute run: $i 65 + else 66 + print_warning $nclosecalls "Reader Batch close calls in" $(($dur/60)) minute run: $i 67 + fi 52 68 fi
+5 -4
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
··· 8 8 # 9 9 # Usage: kvm-test-1-run.sh config builddir resdir minutes qemu-args boot_args 10 10 # 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. 14 14 # boot_args defaults to value returned by the per_version_boot_params 15 15 # shell function. 16 16 # ··· 138 138 fi 139 139 140 140 # Generate -smp qemu argument. 141 - qemu_args="-nographic $qemu_args" 141 + qemu_args="-enable-kvm -soundhw pcspk -nographic $qemu_args" 142 142 cpu_count=`configNR_CPUS.sh $config_template` 143 143 cpu_count=`configfrag_boot_cpus "$boot_args" "$config_template" "$cpu_count"` 144 144 vcpus=`identify_qemu_vcpus` ··· 168 168 touch $resdir/buildonly 169 169 exit 0 170 170 fi 171 + echo "NOTE: $QEMU either did not run or was interactive" > $builddir/console.log 171 172 echo $QEMU $qemu_args -m 512 -kernel $resdir/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd 172 173 ( $QEMU $qemu_args -m 512 -kernel $resdir/bzImage -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval ) & 173 174 qemu_pid=$!
+13 -7
tools/testing/selftests/rcutorture/bin/parse-build.sh
··· 26 26 # 27 27 # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com> 28 28 29 - T=$1 29 + F=$1 30 30 title=$2 31 + T=/tmp/parse-build.sh.$$ 32 + trap 'rm -rf $T' 0 33 + mkdir $T 31 34 32 35 . functions.sh 33 36 34 - if grep -q CC < $T 37 + if grep -q CC < $F 35 38 then 36 39 : 37 40 else ··· 42 39 exit 1 43 40 fi 44 41 45 - if grep -q "error:" < $T 42 + if grep -q "error:" < $F 46 43 then 47 44 print_bug $title build errors: 48 - grep "error:" < $T 45 + grep "error:" < $F 49 46 exit 2 50 47 fi 51 - exit 0 52 48 53 - if egrep -q "rcu[^/]*\.c.*warning:|rcu.*\.h.*warning:" < $T 49 + grep warning: < $F > $T/warnings 50 + grep "include/linux/*rcu*\.h:" $T/warnings > $T/hwarnings 51 + grep "kernel/rcu/[^/]*:" $T/warnings > $T/cwarnings 52 + cat $T/hwarnings $T/cwarnings > $T/rcuwarnings 53 + if test -s $T/rcuwarnings 54 54 then 55 55 print_warning $title build errors: 56 - egrep "rcu[^/]*\.c.*warning:|rcu.*\.h.*warning:" < $T 56 + cat $T/rcuwarnings 57 57 exit 2 58 58 fi 59 59 exit 0
+1 -1
tools/testing/selftests/rcutorture/bin/parse-console.sh
··· 36 36 then 37 37 print_warning Console output contains nul bytes, old qemu still running? 38 38 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 40 40 if test -s $T 41 41 then 42 42 print_warning Assertion failure in $file $title