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

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

Pull RCU updates from Ingo Molnar:
"The main changes in this cycle were:

- Miscellaneous fixes, cleanups, restructuring.

- RCU torture-test updates"

* 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
rcu: Export rcu_gp_is_normal()
rcu: Remove rcu_user_hooks_switch
rcu: Catch up rcu_report_qs_rdp() comment with reality
rcu: Document unique-name limitation for DEFINE_STATIC_SRCU()
rcu: Make rcu/tiny_plugin.h explicitly non-modular
irq: Privatize irq_common_data::state_use_accessors
RCU: Privatize rcu_node::lock
sparse: Add __private to privatize members of structs
rcu: Remove useless rcu_data_p when !PREEMPT_RCU
rcutorture: Correct no-expedite console messages
rcu: Set rdp->gpwrap when CPU is idle
rcu: Stop treating in-kernel CPU-bound workloads as errors
rcu: Update rcu_report_qs_rsp() comment
rcu: Assign false instead of 0 for ->core_needs_qs
rcutorture: Check for self-detected stalls
rcutorture: Don't keep empty console.log.diags files
rcutorture: Add checks for rcutorture writer starvation

+164 -130
+8 -4
include/linux/compiler.h
··· 20 20 # define __pmem __attribute__((noderef, address_space(5))) 21 21 #ifdef CONFIG_SPARSE_RCU_POINTER 22 22 # define __rcu __attribute__((noderef, address_space(4))) 23 - #else 23 + #else /* CONFIG_SPARSE_RCU_POINTER */ 24 24 # define __rcu 25 - #endif 25 + #endif /* CONFIG_SPARSE_RCU_POINTER */ 26 + # define __private __attribute__((noderef)) 26 27 extern void __chk_user_ptr(const volatile void __user *); 27 28 extern void __chk_io_ptr(const volatile void __iomem *); 28 - #else 29 + # define ACCESS_PRIVATE(p, member) (*((typeof((p)->member) __force *) &(p)->member)) 30 + #else /* __CHECKER__ */ 29 31 # define __user 30 32 # define __kernel 31 33 # define __safe ··· 46 44 # define __percpu 47 45 # define __rcu 48 46 # define __pmem 49 - #endif 47 + # define __private 48 + # define ACCESS_PRIVATE(p, member) ((p)->member) 49 + #endif /* __CHECKER__ */ 50 50 51 51 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */ 52 52 #define ___PASTE(a,b) a##b
+4 -2
include/linux/irq.h
··· 137 137 * @msi_desc: MSI descriptor 138 138 */ 139 139 struct irq_common_data { 140 - unsigned int state_use_accessors; 140 + unsigned int __private state_use_accessors; 141 141 #ifdef CONFIG_NUMA 142 142 unsigned int node; 143 143 #endif ··· 208 208 IRQD_FORWARDED_TO_VCPU = (1 << 20), 209 209 }; 210 210 211 - #define __irqd_to_state(d) ((d)->common->state_use_accessors) 211 + #define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors) 212 212 213 213 static inline bool irqd_is_setaffinity_pending(struct irq_data *d) 214 214 { ··· 298 298 { 299 299 __irqd_to_state(d) &= ~IRQD_FORWARDED_TO_VCPU; 300 300 } 301 + 302 + #undef __irqd_to_state 301 303 302 304 static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d) 303 305 {
-2
include/linux/rcupdate.h
··· 360 360 #else 361 361 static inline void rcu_user_enter(void) { } 362 362 static inline void rcu_user_exit(void) { } 363 - static inline void rcu_user_hooks_switch(struct task_struct *prev, 364 - struct task_struct *next) { } 365 363 #endif /* CONFIG_NO_HZ_FULL */ 366 364 367 365 #ifdef CONFIG_RCU_NOCB_CPU
+17 -2
include/linux/srcu.h
··· 99 99 } 100 100 101 101 /* 102 - * define and init a srcu struct at build time. 103 - * dont't call init_srcu_struct() nor cleanup_srcu_struct() on it. 102 + * Define and initialize a srcu struct at build time. 103 + * Do -not- call init_srcu_struct() nor cleanup_srcu_struct() on it. 104 + * 105 + * Note that although DEFINE_STATIC_SRCU() hides the name from other 106 + * files, the per-CPU variable rules nevertheless require that the 107 + * chosen name be globally unique. These rules also prohibit use of 108 + * DEFINE_STATIC_SRCU() within a function. If these rules are too 109 + * restrictive, declare the srcu_struct manually. For example, in 110 + * each file: 111 + * 112 + * static struct srcu_struct my_srcu; 113 + * 114 + * Then, before the first use of each my_srcu, manually initialize it: 115 + * 116 + * init_srcu_struct(&my_srcu); 117 + * 118 + * See include/linux/percpu-defs.h for the rules on per-CPU variables. 104 119 */ 105 120 #define __DEFINE_SRCU(name, is_static) \ 106 121 static DEFINE_PER_CPU(struct srcu_struct_array, name##_srcu_array);\
+4
kernel/irq/internals.h
··· 160 160 __irq_put_desc_unlock(desc, flags, false); 161 161 } 162 162 163 + #define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors) 164 + 163 165 /* 164 166 * Manipulation functions for irq_data.state 165 167 */ ··· 189 187 { 190 188 return __irqd_to_state(d) & mask; 191 189 } 190 + 191 + #undef __irqd_to_state 192 192 193 193 static inline void kstat_incr_irqs_this_cpu(struct irq_desc *desc) 194 194 {
+8 -6
kernel/rcu/rcutorture.c
··· 932 932 int nsynctypes = 0; 933 933 934 934 VERBOSE_TOROUT_STRING("rcu_torture_writer task started"); 935 - pr_alert("%s" TORTURE_FLAG 936 - " Grace periods expedited from boot/sysfs for %s,\n", 937 - torture_type, cur_ops->name); 938 - pr_alert("%s" TORTURE_FLAG 939 - " Testing of dynamic grace-period expediting diabled.\n", 940 - torture_type); 935 + if (!can_expedite) { 936 + pr_alert("%s" TORTURE_FLAG 937 + " Grace periods expedited from boot/sysfs for %s,\n", 938 + torture_type, cur_ops->name); 939 + pr_alert("%s" TORTURE_FLAG 940 + " Disabled dynamic grace-period expediting.\n", 941 + torture_type); 942 + } 941 943 942 944 /* Initialize synctype[] array. If none set, take default. */ 943 945 if (!gp_cond1 && !gp_exp1 && !gp_normal1 && !gp_sync1)
+2 -13
kernel/rcu/tiny_plugin.h
··· 23 23 */ 24 24 25 25 #include <linux/kthread.h> 26 - #include <linux/module.h> 26 + #include <linux/init.h> 27 27 #include <linux/debugfs.h> 28 28 #include <linux/seq_file.h> 29 29 ··· 122 122 debugfs_remove_recursive(rcudir); 123 123 return 1; 124 124 } 125 - 126 - static void __exit rcutiny_trace_cleanup(void) 127 - { 128 - debugfs_remove_recursive(rcudir); 129 - } 130 - 131 - module_init(rcutiny_trace_init); 132 - module_exit(rcutiny_trace_cleanup); 133 - 134 - MODULE_AUTHOR("Paul E. McKenney"); 135 - MODULE_DESCRIPTION("Read-Copy Update tracing for tiny implementation"); 136 - MODULE_LICENSE("GPL"); 125 + device_initcall(rcutiny_trace_init); 137 126 138 127 static void check_cpu_stall(struct rcu_ctrlblk *rcp) 139 128 {
+70 -73
kernel/rcu/tree.c
··· 108 108 RCU_STATE_INITIALIZER(rcu_bh, 'b', call_rcu_bh); 109 109 110 110 static struct rcu_state *const rcu_state_p; 111 - static struct rcu_data __percpu *const rcu_data_p; 112 111 LIST_HEAD(rcu_struct_flavors); 113 112 114 113 /* Dump rcu_node combining tree at boot to verify correct setup. */ ··· 1082 1083 rcu_sysidle_check_cpu(rdp, isidle, maxj); 1083 1084 if ((rdp->dynticks_snap & 0x1) == 0) { 1084 1085 trace_rcu_fqs(rdp->rsp->name, rdp->gpnum, rdp->cpu, TPS("dti")); 1085 - return 1; 1086 - } else { 1087 1086 if (ULONG_CMP_LT(READ_ONCE(rdp->gpnum) + ULONG_MAX / 4, 1088 1087 rdp->mynode->gpnum)) 1089 1088 WRITE_ONCE(rdp->gpwrap, true); 1090 - return 0; 1089 + return 1; 1091 1090 } 1091 + return 0; 1092 1092 } 1093 1093 1094 1094 /* ··· 1171 1173 smp_mb(); /* ->cond_resched_completed before *rcrmp. */ 1172 1174 WRITE_ONCE(*rcrmp, 1173 1175 READ_ONCE(*rcrmp) + rdp->rsp->flavor_mask); 1174 - resched_cpu(rdp->cpu); /* Force CPU into scheduler. */ 1175 - rdp->rsp->jiffies_resched += 5; /* Enable beating. */ 1176 - } else if (ULONG_CMP_GE(jiffies, rdp->rsp->jiffies_resched)) { 1177 - /* Time to beat on that CPU again! */ 1178 - resched_cpu(rdp->cpu); /* Force CPU into scheduler. */ 1179 - rdp->rsp->jiffies_resched += 5; /* Re-enable beating. */ 1180 1176 } 1177 + rdp->rsp->jiffies_resched += 5; /* Re-enable beating. */ 1181 1178 } 1179 + 1180 + /* And if it has been a really long time, kick the CPU as well. */ 1181 + if (ULONG_CMP_GE(jiffies, 1182 + rdp->rsp->gp_start + 2 * jiffies_till_sched_qs) || 1183 + ULONG_CMP_GE(jiffies, rdp->rsp->gp_start + jiffies_till_sched_qs)) 1184 + resched_cpu(rdp->cpu); /* Force CPU into scheduler. */ 1182 1185 1183 1186 return 0; 1184 1187 } ··· 1245 1246 if (rnp->qsmask & (1UL << cpu)) 1246 1247 dump_cpu_task(rnp->grplo + cpu); 1247 1248 } 1248 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1249 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1249 1250 } 1250 1251 } 1251 1252 ··· 1265 1266 raw_spin_lock_irqsave_rcu_node(rnp, flags); 1266 1267 delta = jiffies - READ_ONCE(rsp->jiffies_stall); 1267 1268 if (delta < RCU_STALL_RAT_DELAY || !rcu_gp_in_progress(rsp)) { 1268 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1269 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1269 1270 return; 1270 1271 } 1271 1272 WRITE_ONCE(rsp->jiffies_stall, 1272 1273 jiffies + 3 * rcu_jiffies_till_stall_check() + 3); 1273 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1274 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1274 1275 1275 1276 /* 1276 1277 * OK, time to rat on our buddy... ··· 1291 1292 ndetected++; 1292 1293 } 1293 1294 } 1294 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1295 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1295 1296 } 1296 1297 1297 1298 print_cpu_stall_info_end(); ··· 1356 1357 if (ULONG_CMP_GE(jiffies, READ_ONCE(rsp->jiffies_stall))) 1357 1358 WRITE_ONCE(rsp->jiffies_stall, 1358 1359 jiffies + 3 * rcu_jiffies_till_stall_check() + 3); 1359 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1360 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1360 1361 1361 1362 /* 1362 1363 * Attempt to revive the RCU machinery by forcing a context switch. ··· 1594 1595 } 1595 1596 unlock_out: 1596 1597 if (rnp != rnp_root) 1597 - raw_spin_unlock(&rnp_root->lock); 1598 + raw_spin_unlock_rcu_node(rnp_root); 1598 1599 out: 1599 1600 if (c_out != NULL) 1600 1601 *c_out = c; ··· 1813 1814 return; 1814 1815 } 1815 1816 needwake = __note_gp_changes(rsp, rnp, rdp); 1816 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1817 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1817 1818 if (needwake) 1818 1819 rcu_gp_kthread_wake(rsp); 1819 1820 } ··· 1838 1839 raw_spin_lock_irq_rcu_node(rnp); 1839 1840 if (!READ_ONCE(rsp->gp_flags)) { 1840 1841 /* Spurious wakeup, tell caller to go back to sleep. */ 1841 - raw_spin_unlock_irq(&rnp->lock); 1842 + raw_spin_unlock_irq_rcu_node(rnp); 1842 1843 return false; 1843 1844 } 1844 1845 WRITE_ONCE(rsp->gp_flags, 0); /* Clear all flags: New grace period. */ ··· 1848 1849 * Grace period already in progress, don't start another. 1849 1850 * Not supposed to be able to happen. 1850 1851 */ 1851 - raw_spin_unlock_irq(&rnp->lock); 1852 + raw_spin_unlock_irq_rcu_node(rnp); 1852 1853 return false; 1853 1854 } 1854 1855 ··· 1857 1858 /* Record GP times before starting GP, hence smp_store_release(). */ 1858 1859 smp_store_release(&rsp->gpnum, rsp->gpnum + 1); 1859 1860 trace_rcu_grace_period(rsp->name, rsp->gpnum, TPS("start")); 1860 - raw_spin_unlock_irq(&rnp->lock); 1861 + raw_spin_unlock_irq_rcu_node(rnp); 1861 1862 1862 1863 /* 1863 1864 * Apply per-leaf buffered online and offline operations to the ··· 1871 1872 if (rnp->qsmaskinit == rnp->qsmaskinitnext && 1872 1873 !rnp->wait_blkd_tasks) { 1873 1874 /* Nothing to do on this leaf rcu_node structure. */ 1874 - raw_spin_unlock_irq(&rnp->lock); 1875 + raw_spin_unlock_irq_rcu_node(rnp); 1875 1876 continue; 1876 1877 } 1877 1878 ··· 1905 1906 rcu_cleanup_dead_rnp(rnp); 1906 1907 } 1907 1908 1908 - raw_spin_unlock_irq(&rnp->lock); 1909 + raw_spin_unlock_irq_rcu_node(rnp); 1909 1910 } 1910 1911 1911 1912 /* ··· 1936 1937 trace_rcu_grace_period_init(rsp->name, rnp->gpnum, 1937 1938 rnp->level, rnp->grplo, 1938 1939 rnp->grphi, rnp->qsmask); 1939 - raw_spin_unlock_irq(&rnp->lock); 1940 + raw_spin_unlock_irq_rcu_node(rnp); 1940 1941 cond_resched_rcu_qs(); 1941 1942 WRITE_ONCE(rsp->gp_activity, jiffies); 1942 1943 } ··· 1994 1995 raw_spin_lock_irq_rcu_node(rnp); 1995 1996 WRITE_ONCE(rsp->gp_flags, 1996 1997 READ_ONCE(rsp->gp_flags) & ~RCU_GP_FLAG_FQS); 1997 - raw_spin_unlock_irq(&rnp->lock); 1998 + raw_spin_unlock_irq_rcu_node(rnp); 1998 1999 } 1999 2000 } 2000 2001 ··· 2024 2025 * safe for us to drop the lock in order to mark the grace 2025 2026 * period as completed in all of the rcu_node structures. 2026 2027 */ 2027 - raw_spin_unlock_irq(&rnp->lock); 2028 + raw_spin_unlock_irq_rcu_node(rnp); 2028 2029 2029 2030 /* 2030 2031 * Propagate new ->completed value to rcu_node structures so ··· 2046 2047 /* smp_mb() provided by prior unlock-lock pair. */ 2047 2048 nocb += rcu_future_gp_cleanup(rsp, rnp); 2048 2049 sq = rcu_nocb_gp_get(rnp); 2049 - raw_spin_unlock_irq(&rnp->lock); 2050 + raw_spin_unlock_irq_rcu_node(rnp); 2050 2051 rcu_nocb_gp_cleanup(sq); 2051 2052 cond_resched_rcu_qs(); 2052 2053 WRITE_ONCE(rsp->gp_activity, jiffies); ··· 2069 2070 READ_ONCE(rsp->gpnum), 2070 2071 TPS("newreq")); 2071 2072 } 2072 - raw_spin_unlock_irq(&rnp->lock); 2073 + raw_spin_unlock_irq_rcu_node(rnp); 2073 2074 } 2074 2075 2075 2076 /* ··· 2235 2236 } 2236 2237 2237 2238 /* 2238 - * Report a full set of quiescent states to the specified rcu_state 2239 - * data structure. This involves cleaning up after the prior grace 2240 - * period and letting rcu_start_gp() start up the next grace period 2241 - * if one is needed. Note that the caller must hold rnp->lock, which 2242 - * is released before return. 2239 + * Report a full set of quiescent states to the specified rcu_state data 2240 + * structure. Invoke rcu_gp_kthread_wake() to awaken the grace-period 2241 + * kthread if another grace period is required. Whether we wake 2242 + * the grace-period kthread or it awakens itself for the next round 2243 + * of quiescent-state forcing, that kthread will clean up after the 2244 + * just-completed grace period. Note that the caller must hold rnp->lock, 2245 + * which is released before return. 2243 2246 */ 2244 2247 static void rcu_report_qs_rsp(struct rcu_state *rsp, unsigned long flags) 2245 2248 __releases(rcu_get_root(rsp)->lock) 2246 2249 { 2247 2250 WARN_ON_ONCE(!rcu_gp_in_progress(rsp)); 2248 2251 WRITE_ONCE(rsp->gp_flags, READ_ONCE(rsp->gp_flags) | RCU_GP_FLAG_FQS); 2249 - raw_spin_unlock_irqrestore(&rcu_get_root(rsp)->lock, flags); 2252 + raw_spin_unlock_irqrestore_rcu_node(rcu_get_root(rsp), flags); 2250 2253 swake_up(&rsp->gp_wq); /* Memory barrier implied by swake_up() path. */ 2251 2254 } 2252 2255 ··· 2278 2277 * Our bit has already been cleared, or the 2279 2278 * relevant grace period is already over, so done. 2280 2279 */ 2281 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 2280 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 2282 2281 return; 2283 2282 } 2284 2283 WARN_ON_ONCE(oldmask); /* Any child must be all zeroed! */ ··· 2290 2289 if (rnp->qsmask != 0 || rcu_preempt_blocked_readers_cgp(rnp)) { 2291 2290 2292 2291 /* Other bits still set at this level, so done. */ 2293 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 2292 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 2294 2293 return; 2295 2294 } 2296 2295 mask = rnp->grpmask; ··· 2300 2299 2301 2300 break; 2302 2301 } 2303 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 2302 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 2304 2303 rnp_c = rnp; 2305 2304 rnp = rnp->parent; 2306 2305 raw_spin_lock_irqsave_rcu_node(rnp, flags); ··· 2332 2331 2333 2332 if (rcu_state_p == &rcu_sched_state || rsp != rcu_state_p || 2334 2333 rnp->qsmask != 0 || rcu_preempt_blocked_readers_cgp(rnp)) { 2335 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 2334 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 2336 2335 return; /* Still need more quiescent states! */ 2337 2336 } 2338 2337 ··· 2349 2348 /* Report up the rest of the hierarchy, tracking current ->gpnum. */ 2350 2349 gps = rnp->gpnum; 2351 2350 mask = rnp->grpmask; 2352 - raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 2351 + raw_spin_unlock_rcu_node(rnp); /* irqs remain disabled. */ 2353 2352 raw_spin_lock_rcu_node(rnp_p); /* irqs already disabled. */ 2354 2353 rcu_report_qs_rnp(mask, rsp, rnp_p, gps, flags); 2355 2354 } 2356 2355 2357 2356 /* 2358 2357 * Record a quiescent state for the specified CPU to that CPU's rcu_data 2359 - * structure. This must be either called from the specified CPU, or 2360 - * called when the specified CPU is known to be offline (and when it is 2361 - * also known that no other CPU is concurrently trying to help the offline 2362 - * CPU). The lastcomp argument is used to make sure we are still in the 2363 - * grace period of interest. We don't want to end the current grace period 2364 - * based on quiescent states detected in an earlier grace period! 2358 + * structure. This must be called from the specified CPU. 2365 2359 */ 2366 2360 static void 2367 2361 rcu_report_qs_rdp(int cpu, struct rcu_state *rsp, struct rcu_data *rdp) ··· 2381 2385 */ 2382 2386 rdp->cpu_no_qs.b.norm = true; /* need qs for new gp. */ 2383 2387 rdp->rcu_qs_ctr_snap = __this_cpu_read(rcu_qs_ctr); 2384 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 2388 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 2385 2389 return; 2386 2390 } 2387 2391 mask = rdp->grpmask; 2388 2392 if ((rnp->qsmask & mask) == 0) { 2389 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 2393 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 2390 2394 } else { 2391 - rdp->core_needs_qs = 0; 2395 + rdp->core_needs_qs = false; 2392 2396 2393 2397 /* 2394 2398 * This GP can't end until cpu checks in, so all of our ··· 2597 2601 rnp->qsmaskinit &= ~mask; 2598 2602 rnp->qsmask &= ~mask; 2599 2603 if (rnp->qsmaskinit) { 2600 - raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 2604 + raw_spin_unlock_rcu_node(rnp); 2605 + /* irqs remain disabled. */ 2601 2606 return; 2602 2607 } 2603 - raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 2608 + raw_spin_unlock_rcu_node(rnp); /* irqs remain disabled. */ 2604 2609 } 2605 2610 } 2606 2611 ··· 2624 2627 mask = rdp->grpmask; 2625 2628 raw_spin_lock_irqsave_rcu_node(rnp, flags); /* Enforce GP memory-order guarantee. */ 2626 2629 rnp->qsmaskinitnext &= ~mask; 2627 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 2630 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 2628 2631 } 2629 2632 2630 2633 /* ··· 2858 2861 rcu_report_qs_rnp(mask, rsp, rnp, rnp->gpnum, flags); 2859 2862 } else { 2860 2863 /* Nothing to do here, so just drop the lock. */ 2861 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 2864 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 2862 2865 } 2863 2866 } 2864 2867 } ··· 2894 2897 raw_spin_unlock(&rnp_old->fqslock); 2895 2898 if (READ_ONCE(rsp->gp_flags) & RCU_GP_FLAG_FQS) { 2896 2899 rsp->n_force_qs_lh++; 2897 - raw_spin_unlock_irqrestore(&rnp_old->lock, flags); 2900 + raw_spin_unlock_irqrestore_rcu_node(rnp_old, flags); 2898 2901 return; /* Someone beat us to it. */ 2899 2902 } 2900 2903 WRITE_ONCE(rsp->gp_flags, READ_ONCE(rsp->gp_flags) | RCU_GP_FLAG_FQS); 2901 - raw_spin_unlock_irqrestore(&rnp_old->lock, flags); 2904 + raw_spin_unlock_irqrestore_rcu_node(rnp_old, flags); 2902 2905 swake_up(&rsp->gp_wq); /* Memory barrier implied by swake_up() path. */ 2903 2906 } 2904 2907 ··· 2924 2927 if (cpu_needs_another_gp(rsp, rdp)) { 2925 2928 raw_spin_lock_rcu_node(rcu_get_root(rsp)); /* irqs disabled. */ 2926 2929 needwake = rcu_start_gp(rsp); 2927 - raw_spin_unlock_irqrestore(&rcu_get_root(rsp)->lock, flags); 2930 + raw_spin_unlock_irqrestore_rcu_node(rcu_get_root(rsp), flags); 2928 2931 if (needwake) 2929 2932 rcu_gp_kthread_wake(rsp); 2930 2933 } else { ··· 3015 3018 3016 3019 raw_spin_lock_rcu_node(rnp_root); 3017 3020 needwake = rcu_start_gp(rsp); 3018 - raw_spin_unlock(&rnp_root->lock); 3021 + raw_spin_unlock_rcu_node(rnp_root); 3019 3022 if (needwake) 3020 3023 rcu_gp_kthread_wake(rsp); 3021 3024 } else { ··· 3435 3438 rcu_for_each_leaf_node(rsp, rnp) { 3436 3439 raw_spin_lock_irqsave_rcu_node(rnp, flags); 3437 3440 if (rnp->expmaskinit == rnp->expmaskinitnext) { 3438 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 3441 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 3439 3442 continue; /* No new CPUs, nothing to do. */ 3440 3443 } 3441 3444 3442 3445 /* Update this node's mask, track old value for propagation. */ 3443 3446 oldmask = rnp->expmaskinit; 3444 3447 rnp->expmaskinit = rnp->expmaskinitnext; 3445 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 3448 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 3446 3449 3447 3450 /* If was already nonzero, nothing to propagate. */ 3448 3451 if (oldmask) ··· 3457 3460 if (rnp_up->expmaskinit) 3458 3461 done = true; 3459 3462 rnp_up->expmaskinit |= mask; 3460 - raw_spin_unlock_irqrestore(&rnp_up->lock, flags); 3463 + raw_spin_unlock_irqrestore_rcu_node(rnp_up, flags); 3461 3464 if (done) 3462 3465 break; 3463 3466 mask = rnp_up->grpmask; ··· 3480 3483 raw_spin_lock_irqsave_rcu_node(rnp, flags); 3481 3484 WARN_ON_ONCE(rnp->expmask); 3482 3485 rnp->expmask = rnp->expmaskinit; 3483 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 3486 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 3484 3487 } 3485 3488 } 3486 3489 ··· 3521 3524 if (!rnp->expmask) 3522 3525 rcu_initiate_boost(rnp, flags); 3523 3526 else 3524 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 3527 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 3525 3528 break; 3526 3529 } 3527 3530 if (rnp->parent == NULL) { 3528 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 3531 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 3529 3532 if (wake) { 3530 3533 smp_mb(); /* EGP done before wake_up(). */ 3531 3534 swake_up(&rsp->expedited_wq); ··· 3533 3536 break; 3534 3537 } 3535 3538 mask = rnp->grpmask; 3536 - raw_spin_unlock(&rnp->lock); /* irqs remain disabled */ 3539 + raw_spin_unlock_rcu_node(rnp); /* irqs remain disabled */ 3537 3540 rnp = rnp->parent; 3538 3541 raw_spin_lock_rcu_node(rnp); /* irqs already disabled */ 3539 3542 WARN_ON_ONCE(!(rnp->expmask & mask)); ··· 3568 3571 3569 3572 raw_spin_lock_irqsave_rcu_node(rnp, flags); 3570 3573 if (!(rnp->expmask & mask)) { 3571 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 3574 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 3572 3575 return; 3573 3576 } 3574 3577 rnp->expmask &= ~mask; ··· 3729 3732 */ 3730 3733 if (rcu_preempt_has_tasks(rnp)) 3731 3734 rnp->exp_tasks = rnp->blkd_tasks.next; 3732 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 3735 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 3733 3736 3734 3737 /* IPI the remaining CPUs for expedited quiescent state. */ 3735 3738 mask = 1; ··· 3746 3749 raw_spin_lock_irqsave_rcu_node(rnp, flags); 3747 3750 if (cpu_online(cpu) && 3748 3751 (rnp->expmask & mask)) { 3749 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 3752 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 3750 3753 schedule_timeout_uninterruptible(1); 3751 3754 if (cpu_online(cpu) && 3752 3755 (rnp->expmask & mask)) ··· 3755 3758 } 3756 3759 if (!(rnp->expmask & mask)) 3757 3760 mask_ofl_ipi &= ~mask; 3758 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 3761 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 3759 3762 } 3760 3763 /* Report quiescent states for those that went offline. */ 3761 3764 mask_ofl_test |= mask_ofl_ipi; ··· 4162 4165 return; 4163 4166 raw_spin_lock_rcu_node(rnp); /* Interrupts already disabled. */ 4164 4167 rnp->qsmaskinit |= mask; 4165 - raw_spin_unlock(&rnp->lock); /* Interrupts remain disabled. */ 4168 + raw_spin_unlock_rcu_node(rnp); /* Interrupts remain disabled. */ 4166 4169 } 4167 4170 } 4168 4171 ··· 4186 4189 rdp->rsp = rsp; 4187 4190 mutex_init(&rdp->exp_funnel_mutex); 4188 4191 rcu_boot_init_nocb_percpu_data(rdp); 4189 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 4192 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 4190 4193 } 4191 4194 4192 4195 /* ··· 4214 4217 rcu_sysidle_init_percpu_data(rdp->dynticks); 4215 4218 atomic_set(&rdp->dynticks->dynticks, 4216 4219 (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1); 4217 - raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 4220 + raw_spin_unlock_rcu_node(rnp); /* irqs remain disabled. */ 4218 4221 4219 4222 /* 4220 4223 * Add CPU to leaf rcu_node pending-online bitmask. Any needed ··· 4235 4238 rdp->rcu_qs_ctr_snap = per_cpu(rcu_qs_ctr, cpu); 4236 4239 rdp->core_needs_qs = false; 4237 4240 trace_rcu_grace_period(rsp->name, rdp->gpnum, TPS("cpuonl")); 4238 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 4241 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 4239 4242 } 4240 4243 4241 4244 static void rcu_prepare_cpu(int cpu) ··· 4357 4360 sp.sched_priority = kthread_prio; 4358 4361 sched_setscheduler_nocheck(t, SCHED_FIFO, &sp); 4359 4362 } 4360 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 4363 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 4361 4364 wake_up_process(t); 4362 4365 } 4363 4366 rcu_spawn_nocb_kthreads(); ··· 4448 4451 cpustride *= levelspread[i]; 4449 4452 rnp = rsp->level[i]; 4450 4453 for (j = 0; j < levelcnt[i]; j++, rnp++) { 4451 - raw_spin_lock_init(&rnp->lock); 4452 - lockdep_set_class_and_name(&rnp->lock, 4454 + raw_spin_lock_init(&ACCESS_PRIVATE(rnp, lock)); 4455 + lockdep_set_class_and_name(&ACCESS_PRIVATE(rnp, lock), 4453 4456 &rcu_node_class[i], buf[i]); 4454 4457 raw_spin_lock_init(&rnp->fqslock); 4455 4458 lockdep_set_class_and_name(&rnp->fqslock,
+31 -11
kernel/rcu/tree.h
··· 150 150 * Definition for node within the RCU grace-period-detection hierarchy. 151 151 */ 152 152 struct rcu_node { 153 - raw_spinlock_t lock; /* Root rcu_node's lock protects some */ 154 - /* rcu_state fields as well as following. */ 153 + raw_spinlock_t __private lock; /* Root rcu_node's lock protects */ 154 + /* some rcu_state fields as well as */ 155 + /* following. */ 155 156 unsigned long gpnum; /* Current grace period for this node. */ 156 157 /* This will either be equal to or one */ 157 158 /* behind the root rcu_node's gpnum. */ ··· 683 682 #endif /* #else #ifdef CONFIG_PPC */ 684 683 685 684 /* 686 - * Wrappers for the rcu_node::lock acquire. 685 + * Wrappers for the rcu_node::lock acquire and release. 687 686 * 688 687 * Because the rcu_nodes form a tree, the tree traversal locking will observe 689 688 * different lock values, this in turn means that an UNLOCK of one level ··· 692 691 * 693 692 * In order to restore full ordering between tree levels, augment the regular 694 693 * lock acquire functions with smp_mb__after_unlock_lock(). 694 + * 695 + * As ->lock of struct rcu_node is a __private field, therefore one should use 696 + * these wrappers rather than directly call raw_spin_{lock,unlock}* on ->lock. 695 697 */ 696 698 static inline void raw_spin_lock_rcu_node(struct rcu_node *rnp) 697 699 { 698 - raw_spin_lock(&rnp->lock); 700 + raw_spin_lock(&ACCESS_PRIVATE(rnp, lock)); 699 701 smp_mb__after_unlock_lock(); 702 + } 703 + 704 + static inline void raw_spin_unlock_rcu_node(struct rcu_node *rnp) 705 + { 706 + raw_spin_unlock(&ACCESS_PRIVATE(rnp, lock)); 700 707 } 701 708 702 709 static inline void raw_spin_lock_irq_rcu_node(struct rcu_node *rnp) 703 710 { 704 - raw_spin_lock_irq(&rnp->lock); 711 + raw_spin_lock_irq(&ACCESS_PRIVATE(rnp, lock)); 705 712 smp_mb__after_unlock_lock(); 706 713 } 707 714 708 - #define raw_spin_lock_irqsave_rcu_node(rnp, flags) \ 709 - do { \ 710 - typecheck(unsigned long, flags); \ 711 - raw_spin_lock_irqsave(&(rnp)->lock, flags); \ 712 - smp_mb__after_unlock_lock(); \ 715 + static inline void raw_spin_unlock_irq_rcu_node(struct rcu_node *rnp) 716 + { 717 + raw_spin_unlock_irq(&ACCESS_PRIVATE(rnp, lock)); 718 + } 719 + 720 + #define raw_spin_lock_irqsave_rcu_node(rnp, flags) \ 721 + do { \ 722 + typecheck(unsigned long, flags); \ 723 + raw_spin_lock_irqsave(&ACCESS_PRIVATE(rnp, lock), flags); \ 724 + smp_mb__after_unlock_lock(); \ 725 + } while (0) 726 + 727 + #define raw_spin_unlock_irqrestore_rcu_node(rnp, flags) \ 728 + do { \ 729 + typecheck(unsigned long, flags); \ 730 + raw_spin_unlock_irqrestore(&ACCESS_PRIVATE(rnp, lock), flags); \ 713 731 } while (0) 714 732 715 733 static inline bool raw_spin_trylock_rcu_node(struct rcu_node *rnp) 716 734 { 717 - bool locked = raw_spin_trylock(&rnp->lock); 735 + bool locked = raw_spin_trylock(&ACCESS_PRIVATE(rnp, lock)); 718 736 719 737 if (locked) 720 738 smp_mb__after_unlock_lock();
+13 -14
kernel/rcu/tree_plugin.h
··· 235 235 rnp->gp_tasks = &t->rcu_node_entry; 236 236 if (!rnp->exp_tasks && (blkd_state & RCU_EXP_BLKD)) 237 237 rnp->exp_tasks = &t->rcu_node_entry; 238 - raw_spin_unlock(&rnp->lock); /* rrupts remain disabled. */ 238 + raw_spin_unlock_rcu_node(rnp); /* interrupts remain disabled. */ 239 239 240 240 /* 241 241 * Report the quiescent state for the expedited GP. This expedited ··· 489 489 !!rnp->gp_tasks); 490 490 rcu_report_unblock_qs_rnp(rcu_state_p, rnp, flags); 491 491 } else { 492 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 492 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 493 493 } 494 494 495 495 /* Unboost if we were boosted. */ ··· 518 518 519 519 raw_spin_lock_irqsave_rcu_node(rnp, flags); 520 520 if (!rcu_preempt_blocked_readers_cgp(rnp)) { 521 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 521 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 522 522 return; 523 523 } 524 524 t = list_entry(rnp->gp_tasks->prev, 525 525 struct task_struct, rcu_node_entry); 526 526 list_for_each_entry_continue(t, &rnp->blkd_tasks, rcu_node_entry) 527 527 sched_show_task(t); 528 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 528 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 529 529 } 530 530 531 531 /* ··· 807 807 #else /* #ifdef CONFIG_PREEMPT_RCU */ 808 808 809 809 static struct rcu_state *const rcu_state_p = &rcu_sched_state; 810 - static struct rcu_data __percpu *const rcu_data_p = &rcu_sched_data; 811 810 812 811 /* 813 812 * Tell them what RCU they are running. ··· 990 991 * might exit their RCU read-side critical sections on their own. 991 992 */ 992 993 if (rnp->exp_tasks == NULL && rnp->boost_tasks == NULL) { 993 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 994 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 994 995 return 0; 995 996 } 996 997 ··· 1027 1028 */ 1028 1029 t = container_of(tb, struct task_struct, rcu_node_entry); 1029 1030 rt_mutex_init_proxy_locked(&rnp->boost_mtx, t); 1030 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1031 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1031 1032 /* Lock only for side effect: boosts task t's priority. */ 1032 1033 rt_mutex_lock(&rnp->boost_mtx); 1033 1034 rt_mutex_unlock(&rnp->boost_mtx); /* Then keep lockdep happy. */ ··· 1087 1088 1088 1089 if (!rcu_preempt_blocked_readers_cgp(rnp) && rnp->exp_tasks == NULL) { 1089 1090 rnp->n_balk_exp_gp_tasks++; 1090 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1091 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1091 1092 return; 1092 1093 } 1093 1094 if (rnp->exp_tasks != NULL || ··· 1097 1098 ULONG_CMP_GE(jiffies, rnp->boost_time))) { 1098 1099 if (rnp->exp_tasks == NULL) 1099 1100 rnp->boost_tasks = rnp->gp_tasks; 1100 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1101 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1101 1102 t = rnp->boost_kthread_task; 1102 1103 if (t) 1103 1104 rcu_wake_cond(t, rnp->boost_kthread_status); 1104 1105 } else { 1105 1106 rcu_initiate_boost_trace(rnp); 1106 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1107 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1107 1108 } 1108 1109 } 1109 1110 ··· 1171 1172 return PTR_ERR(t); 1172 1173 raw_spin_lock_irqsave_rcu_node(rnp, flags); 1173 1174 rnp->boost_kthread_task = t; 1174 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1175 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1175 1176 sp.sched_priority = kthread_prio; 1176 1177 sched_setscheduler_nocheck(t, SCHED_FIFO, &sp); 1177 1178 wake_up_process(t); /* get to TASK_INTERRUPTIBLE quickly. */ ··· 1307 1308 static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags) 1308 1309 __releases(rnp->lock) 1309 1310 { 1310 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 1311 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 1311 1312 } 1312 1313 1313 1314 static void invoke_rcu_callbacks_kthread(void) ··· 1558 1559 rnp = rdp->mynode; 1559 1560 raw_spin_lock_rcu_node(rnp); /* irqs already disabled. */ 1560 1561 needwake = rcu_accelerate_cbs(rsp, rnp, rdp); 1561 - raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 1562 + raw_spin_unlock_rcu_node(rnp); /* irqs remain disabled. */ 1562 1563 if (needwake) 1563 1564 rcu_gp_kthread_wake(rsp); 1564 1565 } ··· 2063 2064 2064 2065 raw_spin_lock_irqsave_rcu_node(rnp, flags); 2065 2066 needwake = rcu_start_future_gp(rnp, rdp, &c); 2066 - raw_spin_unlock_irqrestore(&rnp->lock, flags); 2067 + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); 2067 2068 if (needwake) 2068 2069 rcu_gp_kthread_wake(rdp->rsp); 2069 2070
+1
kernel/rcu/update.c
··· 128 128 { 129 129 return READ_ONCE(rcu_normal); 130 130 } 131 + EXPORT_SYMBOL_GPL(rcu_gp_is_normal); 131 132 132 133 static atomic_t rcu_expedited_nesting = 133 134 ATOMIC_INIT(IS_ENABLED(CONFIG_RCU_EXPEDITE_BOOT) ? 1 : 0);
+2 -1
scripts/checkpatch.pl
··· 269 269 __init_refok| 270 270 __kprobes| 271 271 __ref| 272 - __rcu 272 + __rcu| 273 + __private 273 274 }x; 274 275 our $InitAttributePrefix = qr{__(?:mem|cpu|dev|net_|)}; 275 276 our $InitAttributeData = qr{$InitAttributePrefix(?:initdata\b)};
+4 -2
tools/testing/selftests/rcutorture/bin/parse-console.sh
··· 33 33 then 34 34 print_warning Console output contains nul bytes, old qemu still running? 35 35 fi 36 - egrep 'Badness|WARNING:|Warn|BUG|===========|Call Trace:|Oops:|detected stalls on CPUs/tasks:|Stall ended before state dump start' < $file | grep -v 'ODEBUG: ' | grep -v 'Warning: unable to open an initial console' > $1.diags 36 + egrep 'Badness|WARNING:|Warn|BUG|===========|Call Trace:|Oops:|detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state' < $file | grep -v 'ODEBUG: ' | grep -v 'Warning: unable to open an initial console' > $1.diags 37 37 if test -s $1.diags 38 38 then 39 39 print_warning Assertion failure in $file $title ··· 64 64 then 65 65 summary="$summary lockdep: $n_badness" 66 66 fi 67 - n_stalls=`egrep -c 'detected stalls on CPUs/tasks:|Stall ended before state dump start' $1` 67 + n_stalls=`egrep -c 'detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state' $1` 68 68 if test "$n_stalls" -ne 0 69 69 then 70 70 summary="$summary Stalls: $n_stalls" 71 71 fi 72 72 print_warning Summary: $summary 73 + else 74 + rm $1.diags 73 75 fi