1 /* SPDX-License-Identifier: GPL-2.0+ */ << 2 /* 1 /* 3 * Read-Copy Update mechanism for mutual exclu 2 * Read-Copy Update mechanism for mutual exclusion (tree-based version) 4 * Internal non-public definitions. 3 * Internal non-public definitions. 5 * 4 * >> 5 * This program is free software; you can redistribute it and/or modify >> 6 * it under the terms of the GNU General Public License as published by >> 7 * the Free Software Foundation; either version 2 of the License, or >> 8 * (at your option) any later version. >> 9 * >> 10 * This program is distributed in the hope that it will be useful, >> 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of >> 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> 13 * GNU General Public License for more details. >> 14 * >> 15 * You should have received a copy of the GNU General Public License >> 16 * along with this program; if not, you can access it online at >> 17 * http://www.gnu.org/licenses/gpl-2.0.html. >> 18 * 6 * Copyright IBM Corporation, 2008 19 * Copyright IBM Corporation, 2008 7 * 20 * 8 * Author: Ingo Molnar <mingo@elte.hu> 21 * Author: Ingo Molnar <mingo@elte.hu> 9 * Paul E. McKenney <paulmck@linux.ibm !! 22 * Paul E. McKenney <paulmck@linux.vnet.ibm.com> 10 */ 23 */ 11 24 12 #include <linux/cache.h> 25 #include <linux/cache.h> 13 #include <linux/kthread.h> << 14 #include <linux/spinlock.h> 26 #include <linux/spinlock.h> 15 #include <linux/rtmutex.h> 27 #include <linux/rtmutex.h> 16 #include <linux/threads.h> 28 #include <linux/threads.h> 17 #include <linux/cpumask.h> 29 #include <linux/cpumask.h> 18 #include <linux/seqlock.h> 30 #include <linux/seqlock.h> 19 #include <linux/swait.h> 31 #include <linux/swait.h> >> 32 #include <linux/stop_machine.h> 20 #include <linux/rcu_node_tree.h> 33 #include <linux/rcu_node_tree.h> 21 34 22 #include "rcu_segcblist.h" 35 #include "rcu_segcblist.h" 23 36 24 /* Communicate arguments to a kthread worker h !! 37 /* 25 struct rcu_exp_work { !! 38 * Dynticks per-CPU state. 26 unsigned long rew_s; !! 39 */ 27 struct kthread_work rew_work; !! 40 struct rcu_dynticks { >> 41 long long dynticks_nesting; /* Track irq/process nesting level. */ >> 42 /* Process level is worth LLONG_MAX/2. */ >> 43 int dynticks_nmi_nesting; /* Track NMI nesting level. */ >> 44 atomic_t dynticks; /* Even value for idle, else odd. */ >> 45 bool rcu_need_heavy_qs; /* GP old, need heavy quiescent state. */ >> 46 unsigned long rcu_qs_ctr; /* Light universal quiescent state ctr. */ >> 47 bool rcu_urgent_qs; /* GP old need light quiescent state. */ >> 48 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE >> 49 long long dynticks_idle_nesting; >> 50 /* irq/process nesting level from idle. */ >> 51 atomic_t dynticks_idle; /* Even value for idle, else odd. */ >> 52 /* "Idle" excludes userspace execution. */ >> 53 unsigned long dynticks_idle_jiffies; >> 54 /* End of last non-NMI non-idle period. */ >> 55 #endif /* #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */ >> 56 #ifdef CONFIG_RCU_FAST_NO_HZ >> 57 bool all_lazy; /* Are all CPU's CBs lazy? */ >> 58 unsigned long nonlazy_posted; >> 59 /* # times non-lazy CBs posted to CPU. */ >> 60 unsigned long nonlazy_posted_snap; >> 61 /* idle-period nonlazy_posted snapshot. */ >> 62 unsigned long last_accelerate; >> 63 /* Last jiffy CBs were accelerated. */ >> 64 unsigned long last_advance_all; >> 65 /* Last jiffy CBs were all advanced. */ >> 66 int tick_nohz_enabled_snap; /* Previously seen value from sysfs. */ >> 67 #endif /* #ifdef CONFIG_RCU_FAST_NO_HZ */ 28 }; 68 }; 29 69 30 /* RCU's kthread states for tracing. */ 70 /* RCU's kthread states for tracing. */ 31 #define RCU_KTHREAD_STOPPED 0 71 #define RCU_KTHREAD_STOPPED 0 32 #define RCU_KTHREAD_RUNNING 1 72 #define RCU_KTHREAD_RUNNING 1 33 #define RCU_KTHREAD_WAITING 2 73 #define RCU_KTHREAD_WAITING 2 34 #define RCU_KTHREAD_OFFCPU 3 74 #define RCU_KTHREAD_OFFCPU 3 35 #define RCU_KTHREAD_YIELDING 4 75 #define RCU_KTHREAD_YIELDING 4 36 #define RCU_KTHREAD_MAX 4 76 #define RCU_KTHREAD_MAX 4 37 77 38 /* 78 /* 39 * Definition for node within the RCU grace-pe 79 * Definition for node within the RCU grace-period-detection hierarchy. 40 */ 80 */ 41 struct rcu_node { 81 struct rcu_node { 42 raw_spinlock_t __private lock; /* Roo 82 raw_spinlock_t __private lock; /* Root rcu_node's lock protects */ 43 /* so 83 /* some rcu_state fields as well as */ 44 /* fo 84 /* following. */ 45 unsigned long gp_seq; /* Track rsp-> !! 85 unsigned long gpnum; /* Current grace period for this node. */ 46 unsigned long gp_seq_needed; /* Track !! 86 /* This will either be equal to or one */ 47 unsigned long completedqs; /* All QSes !! 87 /* behind the root rcu_node's gpnum. */ >> 88 unsigned long completed; /* Last GP completed for this node. */ >> 89 /* This will either be equal to or one */ >> 90 /* behind the root rcu_node's gpnum. */ 48 unsigned long qsmask; /* CPUs or gro 91 unsigned long qsmask; /* CPUs or groups that need to switch in */ 49 /* order for 92 /* order for current grace period to proceed.*/ 50 /* In leaf rc 93 /* In leaf rcu_node, each bit corresponds to */ 51 /* an rcu_dat 94 /* an rcu_data structure, otherwise, each */ 52 /* bit corres 95 /* bit corresponds to a child rcu_node */ 53 /* structure. 96 /* structure. */ 54 unsigned long rcu_gp_init_mask; /* Mas << 55 unsigned long qsmaskinit; 97 unsigned long qsmaskinit; 56 /* Per-GP init 98 /* Per-GP initial value for qsmask. */ 57 /* Initialize 99 /* Initialized from ->qsmaskinitnext at the */ 58 /* beginning 100 /* beginning of each grace period. */ 59 unsigned long qsmaskinitnext; 101 unsigned long qsmaskinitnext; >> 102 /* Online CPUs for next grace period. */ 60 unsigned long expmask; /* CPUs or gro 103 unsigned long expmask; /* CPUs or groups that need to check in */ 61 /* to allow t 104 /* to allow the current expedited GP */ 62 /* to complet 105 /* to complete. */ 63 unsigned long expmaskinit; 106 unsigned long expmaskinit; 64 /* Per-GP init 107 /* Per-GP initial values for expmask. */ 65 /* Initialize 108 /* Initialized from ->expmaskinitnext at the */ 66 /* beginning 109 /* beginning of each expedited GP. */ 67 unsigned long expmaskinitnext; 110 unsigned long expmaskinitnext; 68 /* Online CPUs 111 /* Online CPUs for next expedited GP. */ 69 /* Any CPU th 112 /* Any CPU that has ever been online will */ 70 /* have its b 113 /* have its bit set. */ 71 struct kthread_worker *exp_kworker; << 72 /* Workers per << 73 /* initializat << 74 unsigned long cbovldmask; << 75 /* CPUs experi << 76 unsigned long ffmask; /* Fully funct << 77 unsigned long grpmask; /* Mask to app 114 unsigned long grpmask; /* Mask to apply to parent qsmask. */ 78 /* Only one b 115 /* Only one bit will be set in this mask. */ 79 int grplo; /* lowest-numb !! 116 int grplo; /* lowest-numbered CPU or group here. */ 80 int grphi; /* highest-num !! 117 int grphi; /* highest-numbered CPU or group here. */ 81 u8 grpnum; /* group numbe !! 118 u8 grpnum; /* CPU/group number for next level up. */ 82 u8 level; /* root is at 119 u8 level; /* root is at level 0. */ 83 bool wait_blkd_tasks;/* Necessary t 120 bool wait_blkd_tasks;/* Necessary to wait for blocked tasks to */ 84 /* exit RCU r 121 /* exit RCU read-side critical sections */ 85 /* before pro 122 /* before propagating offline up the */ 86 /* rcu_node t 123 /* rcu_node tree? */ 87 struct rcu_node *parent; 124 struct rcu_node *parent; 88 struct list_head blkd_tasks; 125 struct list_head blkd_tasks; 89 /* Tasks block 126 /* Tasks blocked in RCU read-side critical */ 90 /* section. 127 /* section. Tasks are placed at the head */ 91 /* of this li 128 /* of this list and age towards the tail. */ 92 struct list_head *gp_tasks; 129 struct list_head *gp_tasks; 93 /* Pointer to 130 /* Pointer to the first task blocking the */ 94 /* current gr 131 /* current grace period, or NULL if there */ 95 /* is no such 132 /* is no such task. */ 96 struct list_head *exp_tasks; 133 struct list_head *exp_tasks; 97 /* Pointer to 134 /* Pointer to the first task blocking the */ 98 /* current ex 135 /* current expedited grace period, or NULL */ 99 /* if there i 136 /* if there is no such task. If there */ 100 /* is no curr 137 /* is no current expedited grace period, */ 101 /* then there 138 /* then there can cannot be any such task. */ 102 struct list_head *boost_tasks; 139 struct list_head *boost_tasks; 103 /* Pointer to 140 /* Pointer to first task that needs to be */ 104 /* priority b 141 /* priority boosted, or NULL if no priority */ 105 /* boosting i 142 /* boosting is needed for this rcu_node */ 106 /* structure. 143 /* structure. If there are no tasks */ 107 /* queued on 144 /* queued on this rcu_node structure that */ 108 /* are blocki 145 /* are blocking the current grace period, */ 109 /* there can 146 /* there can be no such task. */ 110 struct rt_mutex boost_mtx; 147 struct rt_mutex boost_mtx; 111 /* Used only f 148 /* Used only for the priority-boosting */ 112 /* side effec 149 /* side effect, not as a lock. */ 113 unsigned long boost_time; 150 unsigned long boost_time; 114 /* When to sta 151 /* When to start boosting (jiffies). */ 115 struct mutex kthread_mutex; << 116 /* Exclusion f << 117 /* manipulati << 118 struct task_struct *boost_kthread_task 152 struct task_struct *boost_kthread_task; 119 /* kthread tha 153 /* kthread that takes care of priority */ 120 /* boosting f 154 /* boosting for this rcu_node structure. */ 121 unsigned int boost_kthread_status; 155 unsigned int boost_kthread_status; 122 /* State of bo 156 /* State of boost_kthread_task for tracing. */ 123 unsigned long n_boosts; /* Number of b !! 157 unsigned long n_tasks_boosted; >> 158 /* Total number of tasks boosted. */ >> 159 unsigned long n_exp_boosts; >> 160 /* Number of tasks boosted for expedited GP. */ >> 161 unsigned long n_normal_boosts; >> 162 /* Number of tasks boosted for normal GP. */ >> 163 unsigned long n_balk_blkd_tasks; >> 164 /* Refused to boost: no blocked tasks. */ >> 165 unsigned long n_balk_exp_gp_tasks; >> 166 /* Refused to boost: nothing blocking GP. */ >> 167 unsigned long n_balk_boost_tasks; >> 168 /* Refused to boost: already boosting. */ >> 169 unsigned long n_balk_notblocked; >> 170 /* Refused to boost: RCU RS CS still running. */ >> 171 unsigned long n_balk_notyet; >> 172 /* Refused to boost: not yet time. */ >> 173 unsigned long n_balk_nos; >> 174 /* Refused to boost: not sure why, though. */ >> 175 /* This can happen due to race conditions. */ 124 #ifdef CONFIG_RCU_NOCB_CPU 176 #ifdef CONFIG_RCU_NOCB_CPU 125 struct swait_queue_head nocb_gp_wq[2]; 177 struct swait_queue_head nocb_gp_wq[2]; 126 /* Place for r 178 /* Place for rcu_nocb_kthread() to wait GP. */ 127 #endif /* #ifdef CONFIG_RCU_NOCB_CPU */ 179 #endif /* #ifdef CONFIG_RCU_NOCB_CPU */ >> 180 int need_future_gp[2]; >> 181 /* Counts of upcoming no-CB GP requests. */ 128 raw_spinlock_t fqslock ____cacheline_i 182 raw_spinlock_t fqslock ____cacheline_internodealigned_in_smp; 129 183 130 spinlock_t exp_lock ____cacheline_inte 184 spinlock_t exp_lock ____cacheline_internodealigned_in_smp; 131 unsigned long exp_seq_rq; 185 unsigned long exp_seq_rq; 132 wait_queue_head_t exp_wq[4]; 186 wait_queue_head_t exp_wq[4]; 133 struct rcu_exp_work rew; << 134 bool exp_need_flush; /* Need to flu << 135 raw_spinlock_t exp_poll_lock; << 136 /* Lock and da << 137 unsigned long exp_seq_poll_rq; << 138 struct work_struct exp_poll_wq; << 139 } ____cacheline_internodealigned_in_smp; 187 } ____cacheline_internodealigned_in_smp; 140 188 141 /* 189 /* 142 * Bitmasks in an rcu_node cover the interval 190 * Bitmasks in an rcu_node cover the interval [grplo, grphi] of CPU IDs, and 143 * are indexed relative to this interval rathe 191 * are indexed relative to this interval rather than the global CPU ID space. 144 * This generates the bit for a CPU in node-lo 192 * This generates the bit for a CPU in node-local masks. 145 */ 193 */ 146 #define leaf_node_cpu_bit(rnp, cpu) (BIT((cpu) !! 194 #define leaf_node_cpu_bit(rnp, cpu) (1UL << ((cpu) - (rnp)->grplo)) 147 195 148 /* 196 /* 149 * Union to allow "aggregate OR" operation on 197 * Union to allow "aggregate OR" operation on the need for a quiescent 150 * state by the normal and expedited grace per 198 * state by the normal and expedited grace periods. 151 */ 199 */ 152 union rcu_noqs { 200 union rcu_noqs { 153 struct { 201 struct { 154 u8 norm; 202 u8 norm; 155 u8 exp; 203 u8 exp; 156 } b; /* Bits. */ 204 } b; /* Bits. */ 157 u16 s; /* Set of bits, aggregate OR he 205 u16 s; /* Set of bits, aggregate OR here. */ 158 }; 206 }; 159 207 160 /* !! 208 /* Index values for nxttail array in struct rcu_data. */ 161 * Record the snapshot of the core stats at ha !! 209 #define RCU_DONE_TAIL 0 /* Also RCU_WAIT head. */ 162 * The member gp_seq is used to ensure that al !! 210 #define RCU_WAIT_TAIL 1 /* Also RCU_NEXT_READY head. */ 163 * during the sampling period. The snapshot is !! 211 #define RCU_NEXT_READY_TAIL 2 /* Also RCU_NEXT head. */ 164 * equal to rdp->gp_seq. !! 212 #define RCU_NEXT_TAIL 3 165 */ !! 213 #define RCU_NEXT_SIZE 4 166 struct rcu_snap_record { << 167 unsigned long gp_seq; /* Tra << 168 u64 cputime_irq; /* Acc << 169 u64 cputime_softirq;/* Acc << 170 u64 cputime_system; /* Acc << 171 unsigned long nr_hardirqs; /* Acc << 172 unsigned int nr_softirqs; /* Acc << 173 unsigned long long nr_csw; /* Acc << 174 unsigned long jiffies; /* Tra << 175 }; << 176 214 177 /* Per-CPU data for read-copy update. */ 215 /* Per-CPU data for read-copy update. */ 178 struct rcu_data { 216 struct rcu_data { 179 /* 1) quiescent-state and grace-period 217 /* 1) quiescent-state and grace-period handling : */ 180 unsigned long gp_seq; /* Tra !! 218 unsigned long completed; /* Track rsp->completed gp number */ 181 unsigned long gp_seq_needed; /* Tra !! 219 /* in order to detect GP end. */ >> 220 unsigned long gpnum; /* Highest gp number that this CPU */ >> 221 /* is aware of having started. */ >> 222 unsigned long rcu_qs_ctr_snap;/* Snapshot of rcu_qs_ctr to check */ >> 223 /* for rcu_all_qs() invocations. */ 182 union rcu_noqs cpu_no_qs; /* No 224 union rcu_noqs cpu_no_qs; /* No QSes yet for this CPU. */ 183 bool core_needs_qs; /* Cor !! 225 bool core_needs_qs; /* Core waits for quiesc state. */ 184 bool beenonline; /* CPU 226 bool beenonline; /* CPU online at least once. */ 185 bool gpwrap; /* Pos !! 227 bool gpwrap; /* Possible gpnum/completed wrap. */ 186 bool cpu_started; /* RCU << 187 struct rcu_node *mynode; /* Thi 228 struct rcu_node *mynode; /* This CPU's leaf of hierarchy */ 188 unsigned long grpmask; /* Mas 229 unsigned long grpmask; /* Mask to apply to leaf qsmask. */ 189 unsigned long ticks_this_gp; /* The 230 unsigned long ticks_this_gp; /* The number of scheduling-clock */ 190 /* ti 231 /* ticks this CPU has handled */ 191 /* du 232 /* during and after the last grace */ 192 /* per 233 /* period it is aware of. */ 193 struct irq_work defer_qs_iw; /* Obt << 194 bool defer_qs_iw_pending; /* Sch << 195 struct work_struct strict_work; /* Sch << 196 234 197 /* 2) batch handling */ 235 /* 2) batch handling */ 198 struct rcu_segcblist cblist; /* Seg 236 struct rcu_segcblist cblist; /* Segmented callback list, with */ 199 /* dif 237 /* different callbacks waiting for */ 200 /* dif 238 /* different grace periods. */ 201 long qlen_last_fqs_check; 239 long qlen_last_fqs_check; 202 /* qle 240 /* qlen at last check for QS forcing */ 203 unsigned long n_cbs_invoked; /* # c !! 241 unsigned long n_cbs_invoked; /* count of RCU cbs invoked. */ >> 242 unsigned long n_nocbs_invoked; /* count of no-CBs RCU cbs invoked. */ >> 243 unsigned long n_cbs_orphaned; /* RCU cbs orphaned by dying CPU */ >> 244 unsigned long n_cbs_adopted; /* RCU cbs adopted from dying CPU */ 204 unsigned long n_force_qs_snap; 245 unsigned long n_force_qs_snap; 205 /* did 246 /* did other CPU force QS recently? */ 206 long blimit; /* Upp 247 long blimit; /* Upper limit on a processed batch */ 207 248 208 /* 3) dynticks interface. */ 249 /* 3) dynticks interface. */ 209 int watching_snap; /* Per !! 250 struct rcu_dynticks *dynticks; /* Shared per-CPU dynticks state. */ 210 bool rcu_need_heavy_qs; /* GP !! 251 int dynticks_snap; /* Per-GP tracking for dynticks. */ 211 bool rcu_urgent_qs; /* GP !! 252 212 bool rcu_forced_tick; /* For !! 253 /* 4) reasons this CPU needed to be kicked by force_quiescent_state */ 213 bool rcu_forced_tick_exp; /* . !! 254 unsigned long dynticks_fqs; /* Kicked due to dynticks idle. */ >> 255 unsigned long offline_fqs; /* Kicked due to being offline. */ >> 256 unsigned long cond_resched_completed; >> 257 /* Grace period that needs help */ >> 258 /* from cond_resched(). */ >> 259 >> 260 /* 5) __rcu_pending() statistics. */ >> 261 unsigned long n_rcu_pending; /* rcu_pending() calls since boot. */ >> 262 unsigned long n_rp_core_needs_qs; >> 263 unsigned long n_rp_report_qs; >> 264 unsigned long n_rp_cb_ready; >> 265 unsigned long n_rp_cpu_needs_gp; >> 266 unsigned long n_rp_gp_completed; >> 267 unsigned long n_rp_gp_started; >> 268 unsigned long n_rp_nocb_defer_wakeup; >> 269 unsigned long n_rp_need_nothing; 214 270 215 /* 4) rcu_barrier(), OOM callbacks, an !! 271 /* 6) _rcu_barrier(), OOM callbacks, and expediting. */ 216 unsigned long barrier_seq_snap; /* Sna << 217 struct rcu_head barrier_head; 272 struct rcu_head barrier_head; 218 int exp_watching_snap; /* Dou !! 273 #ifdef CONFIG_RCU_FAST_NO_HZ >> 274 struct rcu_head oom_head; >> 275 #endif /* #ifdef CONFIG_RCU_FAST_NO_HZ */ >> 276 atomic_long_t exp_workdone0; /* # done by workqueue. */ >> 277 atomic_long_t exp_workdone1; /* # done by others #1. */ >> 278 atomic_long_t exp_workdone2; /* # done by others #2. */ >> 279 atomic_long_t exp_workdone3; /* # done by others #3. */ >> 280 int exp_dynticks_snap; /* Double-check need for IPI. */ 219 281 220 /* 5) Callback offloading. */ !! 282 /* 7) Callback offloading. */ 221 #ifdef CONFIG_RCU_NOCB_CPU 283 #ifdef CONFIG_RCU_NOCB_CPU 222 struct swait_queue_head nocb_cb_wq; /* !! 284 struct rcu_head *nocb_head; /* CBs waiting for kthread. */ 223 struct swait_queue_head nocb_state_wq; !! 285 struct rcu_head **nocb_tail; 224 struct task_struct *nocb_gp_kthread; !! 286 atomic_long_t nocb_q_count; /* # CBs waiting for nocb */ 225 raw_spinlock_t nocb_lock; /* Gua !! 287 atomic_long_t nocb_q_count_lazy; /* invocation (all stages). */ >> 288 struct rcu_head *nocb_follower_head; /* CBs ready to invoke. */ >> 289 struct rcu_head **nocb_follower_tail; >> 290 struct swait_queue_head nocb_wq; /* For nocb kthreads to sleep on. */ >> 291 struct task_struct *nocb_kthread; 226 int nocb_defer_wakeup; /* Def 292 int nocb_defer_wakeup; /* Defer wakeup of nocb_kthread. */ 227 struct timer_list nocb_timer; /* Enf << 228 unsigned long nocb_gp_adv_time; /* Las << 229 struct mutex nocb_gp_kthread_mutex; /* << 230 /* << 231 << 232 /* The following fields are used by ca << 233 raw_spinlock_t nocb_bypass_lock ____ca << 234 struct rcu_cblist nocb_bypass; /* Loc << 235 unsigned long nocb_bypass_first; /* Ti << 236 unsigned long nocb_nobypass_last; /* L << 237 int nocb_nobypass_count; /* # - << 238 << 239 /* The following fields are used by GP << 240 raw_spinlock_t nocb_gp_lock ____cachel << 241 u8 nocb_gp_sleep; /* Is << 242 u8 nocb_gp_bypass; /* Fou << 243 u8 nocb_gp_gp; /* GP << 244 unsigned long nocb_gp_seq; /* If << 245 unsigned long nocb_gp_loops; /* # p << 246 struct swait_queue_head nocb_gp_wq; /* << 247 bool nocb_cb_sleep; /* Is << 248 struct task_struct *nocb_cb_kthread; << 249 struct list_head nocb_head_rdp; /* << 250 * Hea << 251 * if << 252 */ << 253 struct list_head nocb_entry_rdp; /* rc << 254 struct rcu_data *nocb_toggling_rdp; /* << 255 << 256 /* The following fields are used by CB << 257 struct rcu_data *nocb_gp_rdp ____cache << 258 /* GP << 259 #endif /* #ifdef CONFIG_RCU_NOCB_CPU */ << 260 293 261 /* 6) RCU priority boosting. */ !! 294 /* The following fields are used by the leader, hence own cacheline. */ 262 struct task_struct *rcu_cpu_kthread_ta !! 295 struct rcu_head *nocb_gp_head ____cacheline_internodealigned_in_smp; 263 /* rcu !! 296 /* CBs waiting for GP. */ 264 unsigned int rcu_cpu_kthread_status; !! 297 struct rcu_head **nocb_gp_tail; 265 char rcu_cpu_has_work; !! 298 bool nocb_leader_sleep; /* Is the nocb leader thread asleep? */ 266 unsigned long rcuc_activity; !! 299 struct rcu_data *nocb_next_follower; >> 300 /* Next follower in wakeup chain. */ >> 301 >> 302 /* The following fields are used by the follower, hence new cachline. */ >> 303 struct rcu_data *nocb_leader ____cacheline_internodealigned_in_smp; >> 304 /* Leader CPU takes GP-end wakeups. */ >> 305 #endif /* #ifdef CONFIG_RCU_NOCB_CPU */ 267 306 268 /* 7) Diagnostic data, including RCU C !! 307 /* 8) RCU CPU stall data. */ 269 unsigned int softirq_snap; /* Sna 308 unsigned int softirq_snap; /* Snapshot of softirq activity. */ 270 /* ->rcu_iw* fields protected by leaf << 271 struct irq_work rcu_iw; /* Che << 272 bool rcu_iw_pending; /* Is << 273 unsigned long rcu_iw_gp_seq; /* ->g << 274 unsigned long rcu_ofl_gp_seq; /* ->g << 275 short rcu_ofl_gp_state; /* ->g << 276 unsigned long rcu_onl_gp_seq; /* ->g << 277 short rcu_onl_gp_state; /* ->g << 278 unsigned long last_fqs_resched; /* Tim << 279 unsigned long last_sched_clock; /* Jif << 280 struct rcu_snap_record snap_record; /* << 281 /* << 282 309 283 long lazy_len; /* Len << 284 int cpu; 310 int cpu; >> 311 struct rcu_state *rsp; 285 }; 312 }; 286 313 287 /* Values for nocb_defer_wakeup field in struc 314 /* Values for nocb_defer_wakeup field in struct rcu_data. */ 288 #define RCU_NOCB_WAKE_NOT 0 !! 315 #define RCU_NOGP_WAKE_NOT 0 289 #define RCU_NOCB_WAKE_BYPASS 1 !! 316 #define RCU_NOGP_WAKE 1 290 #define RCU_NOCB_WAKE_LAZY 2 !! 317 #define RCU_NOGP_WAKE_FORCE 2 291 #define RCU_NOCB_WAKE 3 << 292 #define RCU_NOCB_WAKE_FORCE 4 << 293 318 294 #define RCU_JIFFIES_TILL_FORCE_QS (1 + (HZ > 2 319 #define RCU_JIFFIES_TILL_FORCE_QS (1 + (HZ > 250) + (HZ > 500)) 295 /* For 320 /* For jiffies_till_first_fqs and */ 296 /* an 321 /* and jiffies_till_next_fqs. */ 297 322 298 #define RCU_JIFFIES_FQS_DIV 256 /* Ver 323 #define RCU_JIFFIES_FQS_DIV 256 /* Very large systems need more */ 299 /* de 324 /* delay between bouts of */ 300 /* qu 325 /* quiescent-state forcing. */ 301 326 302 #define RCU_STALL_RAT_DELAY 2 /* All 327 #define RCU_STALL_RAT_DELAY 2 /* Allow other CPUs time to take */ 303 /* at 328 /* at least one scheduling clock */ 304 /* ir 329 /* irq before ratting on them. */ 305 330 306 #define rcu_wait(cond) 331 #define rcu_wait(cond) \ 307 do { 332 do { \ 308 for (;;) { 333 for (;;) { \ 309 set_current_state(TASK_INTERRU 334 set_current_state(TASK_INTERRUPTIBLE); \ 310 if (cond) 335 if (cond) \ 311 break; 336 break; \ 312 schedule(); 337 schedule(); \ 313 } 338 } \ 314 __set_current_state(TASK_RUNNING); 339 __set_current_state(TASK_RUNNING); \ 315 } while (0) 340 } while (0) 316 341 317 /* 342 /* 318 * A max threshold for synchronize_rcu() users << 319 * awaken directly by the rcu_gp_kthread(). Le << 320 * deferred to the main worker. << 321 */ << 322 #define SR_MAX_USERS_WAKE_FROM_GP 5 << 323 #define SR_NORMAL_GP_WAIT_HEAD_MAX 5 << 324 << 325 struct sr_wait_node { << 326 atomic_t inuse; << 327 struct llist_node node; << 328 }; << 329 << 330 /* << 331 * RCU global state, including node hierarchy. 343 * RCU global state, including node hierarchy. This hierarchy is 332 * represented in "heap" form in a dense array 344 * represented in "heap" form in a dense array. The root (first level) 333 * of the hierarchy is in ->node[0] (reference 345 * of the hierarchy is in ->node[0] (referenced by ->level[0]), the second 334 * level in ->node[1] through ->node[m] (->nod 346 * level in ->node[1] through ->node[m] (->node[1] referenced by ->level[1]), 335 * and the third level in ->node[m+1] and foll 347 * and the third level in ->node[m+1] and following (->node[m+1] referenced 336 * by ->level[2]). The number of levels is de 348 * by ->level[2]). The number of levels is determined by the number of 337 * CPUs and by CONFIG_RCU_FANOUT. Small syste 349 * CPUs and by CONFIG_RCU_FANOUT. Small systems will have a "hierarchy" 338 * consisting of a single rcu_node. 350 * consisting of a single rcu_node. 339 */ 351 */ 340 struct rcu_state { 352 struct rcu_state { 341 struct rcu_node node[NUM_RCU_NODES]; 353 struct rcu_node node[NUM_RCU_NODES]; /* Hierarchy. */ 342 struct rcu_node *level[RCU_NUM_LVLS + 354 struct rcu_node *level[RCU_NUM_LVLS + 1]; 343 355 /* Hierarchy levels (+1 to */ 344 356 /* shut bogus gcc warning) */ >> 357 struct rcu_data __percpu *rda; /* pointer of percu rcu_data. */ >> 358 call_rcu_func_t call; /* call_rcu() flavor. */ 345 int ncpus; 359 int ncpus; /* # CPUs seen so far. */ 346 int n_online_cpus; << 347 360 348 /* The following fields are guarded by 361 /* The following fields are guarded by the root rcu_node's lock. */ 349 362 350 unsigned long gp_seq ____cacheline_int !! 363 u8 boost ____cacheline_internodealigned_in_smp; 351 !! 364 /* Subject to priority boost. */ 352 unsigned long gp_max; !! 365 unsigned long gpnum; /* Current gp number. */ 353 !! 366 unsigned long completed; /* # of last completed gp. */ 354 struct task_struct *gp_kthread; 367 struct task_struct *gp_kthread; /* Task for grace periods. */ 355 struct swait_queue_head gp_wq; 368 struct swait_queue_head gp_wq; /* Where GP task waits. */ 356 short gp_flags; 369 short gp_flags; /* Commands for GP task. */ 357 short gp_state; 370 short gp_state; /* GP kthread sleep state. */ 358 unsigned long gp_wake_time; << 359 unsigned long gp_wake_seq; << 360 unsigned long gp_seq_polled; << 361 unsigned long gp_seq_polled_snap; << 362 unsigned long gp_seq_polled_exp_snap; << 363 371 364 /* End of fields guarded by root rcu_n 372 /* End of fields guarded by root rcu_node's lock. */ 365 373 >> 374 raw_spinlock_t orphan_lock ____cacheline_internodealigned_in_smp; >> 375 /* Protect following fields. */ >> 376 struct rcu_cblist orphan_pend; /* Orphaned callbacks that */ >> 377 /* need a grace period. */ >> 378 struct rcu_cblist orphan_done; /* Orphaned callbacks that */ >> 379 /* are ready to invoke. */ >> 380 /* (Contains counts.) */ >> 381 /* End of fields guarded by orphan_lock. */ >> 382 366 struct mutex barrier_mutex; 383 struct mutex barrier_mutex; /* Guards barrier fields. */ 367 atomic_t barrier_cpu_count; 384 atomic_t barrier_cpu_count; /* # CPUs waiting on. */ 368 struct completion barrier_completion; 385 struct completion barrier_completion; /* Wake at barrier end. */ 369 unsigned long barrier_sequence; 386 unsigned long barrier_sequence; /* ++ at start and end of */ 370 !! 387 /* _rcu_barrier(). */ 371 /* End of fields guarded by barrier_mu 388 /* End of fields guarded by barrier_mutex. */ 372 389 373 raw_spinlock_t barrier_lock; << 374 << 375 struct mutex exp_mutex; 390 struct mutex exp_mutex; /* Serialize expedited GP. */ 376 struct mutex exp_wake_mutex; 391 struct mutex exp_wake_mutex; /* Serialize wakeup. */ 377 unsigned long expedited_sequence; 392 unsigned long expedited_sequence; /* Take a ticket. */ 378 atomic_t expedited_need_qs; 393 atomic_t expedited_need_qs; /* # CPUs left to check in. */ 379 struct swait_queue_head expedited_wq; 394 struct swait_queue_head expedited_wq; /* Wait for check-ins. */ 380 int ncpus_snap; 395 int ncpus_snap; /* # CPUs seen last time. */ 381 u8 cbovld; << 382 u8 cbovldnext; << 383 396 384 unsigned long jiffies_force_qs; 397 unsigned long jiffies_force_qs; /* Time at which to invoke */ 385 398 /* force_quiescent_state(). */ 386 unsigned long jiffies_kick_kthreads; 399 unsigned long jiffies_kick_kthreads; /* Time at which to kick */ 387 400 /* kthreads, if configured. */ 388 unsigned long n_force_qs; 401 unsigned long n_force_qs; /* Number of calls to */ 389 402 /* force_quiescent_state(). */ >> 403 unsigned long n_force_qs_lh; /* ~Number of calls leaving */ >> 404 /* due to lock unavailable. */ >> 405 unsigned long n_force_qs_ngp; /* Number of calls leaving */ >> 406 /* due to no GP active. */ 390 unsigned long gp_start; 407 unsigned long gp_start; /* Time at which GP started, */ 391 408 /* but in jiffies. */ 392 unsigned long gp_end; << 393 << 394 unsigned long gp_activity; 409 unsigned long gp_activity; /* Time of last GP kthread */ 395 410 /* activity in jiffies. */ 396 unsigned long gp_req_activity; << 397 << 398 unsigned long jiffies_stall; 411 unsigned long jiffies_stall; /* Time at which to check */ 399 412 /* for CPU stalls. */ 400 int nr_fqs_jiffies_stall; << 401 << 402 << 403 << 404 unsigned long jiffies_resched; 413 unsigned long jiffies_resched; /* Time at which to resched */ 405 414 /* a reluctant CPU. */ 406 unsigned long n_force_qs_gpstart; 415 unsigned long n_force_qs_gpstart; /* Snapshot of n_force_qs at */ 407 416 /* GP start. */ >> 417 unsigned long gp_max; /* Maximum GP duration in */ >> 418 /* jiffies. */ 408 const char *name; 419 const char *name; /* Name of structure. */ 409 char abbr; 420 char abbr; /* Abbreviated name. */ 410 !! 421 struct list_head flavors; /* List of RCU flavors. */ 411 arch_spinlock_t ofl_lock ____cacheline << 412 << 413 << 414 << 415 /* synchronize_rcu() part. */ << 416 struct llist_head srs_next; /* req << 417 struct llist_node *srs_wait_tail; /* w << 418 struct llist_node *srs_done_tail; /* r << 419 struct sr_wait_node srs_wait_nodes[SR_ << 420 struct work_struct srs_cleanup_work; << 421 atomic_t srs_cleanups_pending; /* srs << 422 << 423 #ifdef CONFIG_RCU_NOCB_CPU << 424 struct mutex nocb_mutex; << 425 int nocb_is_setup; << 426 #endif << 427 }; 422 }; 428 423 429 /* Values for rcu_state structure's gp_flags f 424 /* Values for rcu_state structure's gp_flags field. */ 430 #define RCU_GP_FLAG_INIT 0x1 /* Need grace- 425 #define RCU_GP_FLAG_INIT 0x1 /* Need grace-period initialization. */ 431 #define RCU_GP_FLAG_FQS 0x2 /* Need grace- 426 #define RCU_GP_FLAG_FQS 0x2 /* Need grace-period quiescent-state forcing. */ 432 #define RCU_GP_FLAG_OVLD 0x4 /* Experiencin << 433 427 434 /* Values for rcu_state structure's gp_state f 428 /* Values for rcu_state structure's gp_state field. */ 435 #define RCU_GP_IDLE 0 /* Initial sta 429 #define RCU_GP_IDLE 0 /* Initial state and no GP in progress. */ 436 #define RCU_GP_WAIT_GPS 1 /* Wait for gr 430 #define RCU_GP_WAIT_GPS 1 /* Wait for grace-period start. */ 437 #define RCU_GP_DONE_GPS 2 /* Wait done f 431 #define RCU_GP_DONE_GPS 2 /* Wait done for grace-period start. */ 438 #define RCU_GP_ONOFF 3 /* Grace-perio !! 432 #define RCU_GP_WAIT_FQS 3 /* Wait for force-quiescent-state time. */ 439 #define RCU_GP_INIT 4 /* Grace-perio !! 433 #define RCU_GP_DOING_FQS 4 /* Wait done for force-quiescent-state time. */ 440 #define RCU_GP_WAIT_FQS 5 /* Wait for fo !! 434 #define RCU_GP_CLEANUP 5 /* Grace-period cleanup started. */ 441 #define RCU_GP_DOING_FQS 6 /* Wait done f !! 435 #define RCU_GP_CLEANED 6 /* Grace-period cleanup complete. */ 442 #define RCU_GP_CLEANUP 7 /* Grace-perio !! 436 443 #define RCU_GP_CLEANED 8 /* Grace-perio !! 437 #ifndef RCU_TREE_NONCORE >> 438 static const char * const gp_state_names[] = { >> 439 "RCU_GP_IDLE", >> 440 "RCU_GP_WAIT_GPS", >> 441 "RCU_GP_DONE_GPS", >> 442 "RCU_GP_WAIT_FQS", >> 443 "RCU_GP_DOING_FQS", >> 444 "RCU_GP_CLEANUP", >> 445 "RCU_GP_CLEANED", >> 446 }; >> 447 #endif /* #ifndef RCU_TREE_NONCORE */ >> 448 >> 449 extern struct list_head rcu_struct_flavors; >> 450 >> 451 /* Sequence through rcu_state structures for each RCU flavor. */ >> 452 #define for_each_rcu_flavor(rsp) \ >> 453 list_for_each_entry((rsp), &rcu_struct_flavors, flavors) 444 454 445 /* 455 /* 446 * In order to export the rcu_state name to th !! 456 * RCU implementation internal declarations: 447 * needs to be added in the __tracepoint_strin << 448 * This requires defining a separate variable << 449 * that points to the string being used, and t << 450 * the tracing userspace tools to be able to d << 451 * address to the matching string. << 452 */ 457 */ >> 458 extern struct rcu_state rcu_sched_state; >> 459 >> 460 extern struct rcu_state rcu_bh_state; >> 461 453 #ifdef CONFIG_PREEMPT_RCU 462 #ifdef CONFIG_PREEMPT_RCU 454 #define RCU_ABBR 'p' !! 463 extern struct rcu_state rcu_preempt_state; 455 #define RCU_NAME_RAW "rcu_preempt" !! 464 #endif /* #ifdef CONFIG_PREEMPT_RCU */ 456 #else /* #ifdef CONFIG_PREEMPT_RCU */ !! 465 457 #define RCU_ABBR 's' !! 466 int rcu_dynticks_snap(struct rcu_dynticks *rdtp); 458 #define RCU_NAME_RAW "rcu_sched" !! 467 bool rcu_eqs_special_set(int cpu); 459 #endif /* #else #ifdef CONFIG_PREEMPT_RCU */ << 460 #ifndef CONFIG_TRACING << 461 #define RCU_NAME RCU_NAME_RAW << 462 #else /* #ifdef CONFIG_TRACING */ << 463 static char rcu_name[] = RCU_NAME_RAW; << 464 static const char *tp_rcu_varname __used __tra << 465 #define RCU_NAME rcu_name << 466 #endif /* #else #ifdef CONFIG_TRACING */ << 467 468 468 /* Forward declarations for tree_plugin.h */ !! 469 #ifdef CONFIG_RCU_BOOST >> 470 DECLARE_PER_CPU(unsigned int, rcu_cpu_kthread_status); >> 471 DECLARE_PER_CPU(int, rcu_cpu_kthread_cpu); >> 472 DECLARE_PER_CPU(unsigned int, rcu_cpu_kthread_loops); >> 473 DECLARE_PER_CPU(char, rcu_cpu_has_work); >> 474 #endif /* #ifdef CONFIG_RCU_BOOST */ >> 475 >> 476 #ifndef RCU_TREE_NONCORE >> 477 >> 478 /* Forward declarations for rcutree_plugin.h */ 469 static void rcu_bootup_announce(void); 479 static void rcu_bootup_announce(void); 470 static void rcu_qs(void); !! 480 static void rcu_preempt_note_context_switch(void); 471 static int rcu_preempt_blocked_readers_cgp(str 481 static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp); 472 #ifdef CONFIG_HOTPLUG_CPU 482 #ifdef CONFIG_HOTPLUG_CPU 473 static bool rcu_preempt_has_tasks(struct rcu_n 483 static bool rcu_preempt_has_tasks(struct rcu_node *rnp); 474 #endif /* #ifdef CONFIG_HOTPLUG_CPU */ 484 #endif /* #ifdef CONFIG_HOTPLUG_CPU */ >> 485 static void rcu_print_detail_task_stall(struct rcu_state *rsp); >> 486 static int rcu_print_task_stall(struct rcu_node *rnp); 475 static int rcu_print_task_exp_stall(struct rcu 487 static int rcu_print_task_exp_stall(struct rcu_node *rnp); 476 static void rcu_preempt_check_blocked_tasks(st 488 static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp); 477 static void rcu_flavor_sched_clock_irq(int use !! 489 static void rcu_preempt_check_callbacks(void); 478 static void dump_blkd_tasks(struct rcu_node *r !! 490 void call_rcu(struct rcu_head *head, rcu_callback_t func); >> 491 static void __init __rcu_init_preempt(void); 479 static void rcu_initiate_boost(struct rcu_node 492 static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags); 480 static void rcu_preempt_boost_start_gp(struct 493 static void rcu_preempt_boost_start_gp(struct rcu_node *rnp); 481 static bool rcu_is_callbacks_kthread(struct rc !! 494 static void invoke_rcu_callbacks_kthread(void); 482 static void rcu_cpu_kthread_setup(unsigned int !! 495 static bool rcu_is_callbacks_kthread(void); 483 static void rcu_spawn_one_boost_kthread(struct !! 496 #ifdef CONFIG_RCU_BOOST >> 497 static void rcu_preempt_do_callbacks(void); >> 498 static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp, >> 499 struct rcu_node *rnp); >> 500 #endif /* #ifdef CONFIG_RCU_BOOST */ >> 501 static void __init rcu_spawn_boost_kthreads(void); >> 502 static void rcu_prepare_kthreads(int cpu); >> 503 static void rcu_cleanup_after_idle(void); >> 504 static void rcu_prepare_for_idle(void); >> 505 static void rcu_idle_count_callbacks_posted(void); 484 static bool rcu_preempt_has_tasks(struct rcu_n 506 static bool rcu_preempt_has_tasks(struct rcu_node *rnp); 485 static bool rcu_preempt_need_deferred_qs(struc !! 507 static void print_cpu_stall_info_begin(void); >> 508 static void print_cpu_stall_info(struct rcu_state *rsp, int cpu); >> 509 static void print_cpu_stall_info_end(void); 486 static void zero_cpu_stall_ticks(struct rcu_da 510 static void zero_cpu_stall_ticks(struct rcu_data *rdp); >> 511 static void increment_cpu_stall_ticks(void); >> 512 static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu); >> 513 static void rcu_nocb_gp_set(struct rcu_node *rnp, int nrq); 487 static struct swait_queue_head *rcu_nocb_gp_ge 514 static struct swait_queue_head *rcu_nocb_gp_get(struct rcu_node *rnp); 488 static void rcu_nocb_gp_cleanup(struct swait_q 515 static void rcu_nocb_gp_cleanup(struct swait_queue_head *sq); 489 static void rcu_init_one_nocb(struct rcu_node 516 static void rcu_init_one_nocb(struct rcu_node *rnp); 490 static bool wake_nocb_gp(struct rcu_data *rdp, !! 517 static bool __call_rcu_nocb(struct rcu_data *rdp, struct rcu_head *rhp, 491 static bool rcu_nocb_flush_bypass(struct rcu_d !! 518 bool lazy, unsigned long flags); 492 unsigned lon !! 519 static bool rcu_nocb_adopt_orphan_cbs(struct rcu_state *rsp, 493 static void call_rcu_nocb(struct rcu_data *rdp !! 520 struct rcu_data *rdp, 494 rcu_callback_t func, !! 521 unsigned long flags); 495 static void __maybe_unused __call_rcu_nocb_wak !! 522 static int rcu_nocb_need_deferred_wakeup(struct rcu_data *rdp); 496 !! 523 static void do_nocb_deferred_wakeup(struct rcu_data *rdp); 497 static int rcu_nocb_need_deferred_wakeup(struc << 498 static bool do_nocb_deferred_wakeup(struct rcu << 499 static void rcu_boot_init_nocb_percpu_data(str 524 static void rcu_boot_init_nocb_percpu_data(struct rcu_data *rdp); 500 static void rcu_spawn_cpu_nocb_kthread(int cpu !! 525 static void rcu_spawn_all_nocb_kthreads(int cpu); 501 static void show_rcu_nocb_state(struct rcu_dat !! 526 static void __init rcu_spawn_nocb_kthreads(void); 502 static void rcu_nocb_lock(struct rcu_data *rdp !! 527 #ifdef CONFIG_RCU_NOCB_CPU 503 static void rcu_nocb_unlock(struct rcu_data *r !! 528 static void __init rcu_organize_nocb_kthreads(struct rcu_state *rsp); 504 static void rcu_nocb_unlock_irqrestore(struct !! 529 #endif /* #ifdef CONFIG_RCU_NOCB_CPU */ 505 unsigne !! 530 static void __maybe_unused rcu_kick_nohz_cpu(int cpu); 506 static void rcu_lockdep_assert_cblist_protecte !! 531 static bool init_nocb_callback_list(struct rcu_data *rdp); >> 532 static void rcu_sysidle_enter(int irq); >> 533 static void rcu_sysidle_exit(int irq); >> 534 static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle, >> 535 unsigned long *maxj); >> 536 static bool is_sysidle_rcu_state(struct rcu_state *rsp); >> 537 static void rcu_sysidle_report_gp(struct rcu_state *rsp, int isidle, >> 538 unsigned long maxj); >> 539 static void rcu_bind_gp_kthread(void); >> 540 static void rcu_sysidle_init_percpu_data(struct rcu_dynticks *rdtp); >> 541 static bool rcu_nohz_full_cpu(struct rcu_state *rsp); >> 542 static void rcu_dynticks_task_enter(void); >> 543 static void rcu_dynticks_task_exit(void); >> 544 >> 545 #ifdef CONFIG_SRCU >> 546 void srcu_online_cpu(unsigned int cpu); >> 547 void srcu_offline_cpu(unsigned int cpu); >> 548 #else /* #ifdef CONFIG_SRCU */ >> 549 void srcu_online_cpu(unsigned int cpu) { } >> 550 void srcu_offline_cpu(unsigned int cpu) { } >> 551 #endif /* #else #ifdef CONFIG_SRCU */ >> 552 >> 553 #endif /* #ifndef RCU_TREE_NONCORE */ >> 554 >> 555 #ifdef CONFIG_RCU_TRACE >> 556 /* Read out queue lengths for tracing. */ >> 557 static inline void rcu_nocb_q_lengths(struct rcu_data *rdp, long *ql, long *qll) >> 558 { 507 #ifdef CONFIG_RCU_NOCB_CPU 559 #ifdef CONFIG_RCU_NOCB_CPU 508 static void __init rcu_organize_nocb_kthreads( !! 560 *ql = atomic_long_read(&rdp->nocb_q_count); >> 561 *qll = atomic_long_read(&rdp->nocb_q_count_lazy); >> 562 #else /* #ifdef CONFIG_RCU_NOCB_CPU */ >> 563 *ql = 0; >> 564 *qll = 0; >> 565 #endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */ >> 566 } >> 567 #endif /* #ifdef CONFIG_RCU_TRACE */ 509 568 510 /* 569 /* 511 * Disable IRQs before checking offloaded stat !! 570 * Wrappers for the rcu_node::lock acquire and release. 512 * locking is safe against concurrent de-offlo !! 571 * >> 572 * Because the rcu_nodes form a tree, the tree traversal locking will observe >> 573 * different lock values, this in turn means that an UNLOCK of one level >> 574 * followed by a LOCK of another level does not imply a full memory barrier; >> 575 * and most importantly transitivity is lost. >> 576 * >> 577 * In order to restore full ordering between tree levels, augment the regular >> 578 * lock acquire functions with smp_mb__after_unlock_lock(). >> 579 * >> 580 * As ->lock of struct rcu_node is a __private field, therefore one should use >> 581 * these wrappers rather than directly call raw_spin_{lock,unlock}* on ->lock. 513 */ 582 */ 514 #define rcu_nocb_lock_irqsave(rdp, flags) !! 583 static inline void raw_spin_lock_rcu_node(struct rcu_node *rnp) 515 do { !! 584 { 516 local_irq_save(flags); !! 585 raw_spin_lock(&ACCESS_PRIVATE(rnp, lock)); 517 if (rcu_segcblist_is_offloaded(&(rdp)- !! 586 smp_mb__after_unlock_lock(); 518 raw_spin_lock(&(rdp)->nocb_loc !! 587 } 519 } while (0) !! 588 520 #else /* #ifdef CONFIG_RCU_NOCB_CPU */ !! 589 static inline void raw_spin_unlock_rcu_node(struct rcu_node *rnp) 521 #define rcu_nocb_lock_irqsave(rdp, flags) loca !! 590 { 522 #endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */ !! 591 raw_spin_unlock(&ACCESS_PRIVATE(rnp, lock)); >> 592 } >> 593 >> 594 static inline void raw_spin_lock_irq_rcu_node(struct rcu_node *rnp) >> 595 { >> 596 raw_spin_lock_irq(&ACCESS_PRIVATE(rnp, lock)); >> 597 smp_mb__after_unlock_lock(); >> 598 } >> 599 >> 600 static inline void raw_spin_unlock_irq_rcu_node(struct rcu_node *rnp) >> 601 { >> 602 raw_spin_unlock_irq(&ACCESS_PRIVATE(rnp, lock)); >> 603 } 523 604 524 static void rcu_bind_gp_kthread(void); !! 605 #define raw_spin_lock_irqsave_rcu_node(rnp, flags) \ 525 static bool rcu_nohz_full_cpu(void); !! 606 do { \ >> 607 typecheck(unsigned long, flags); \ >> 608 raw_spin_lock_irqsave(&ACCESS_PRIVATE(rnp, lock), flags); \ >> 609 smp_mb__after_unlock_lock(); \ >> 610 } while (0) 526 611 527 /* Forward declarations for tree_stall.h */ !! 612 #define raw_spin_unlock_irqrestore_rcu_node(rnp, flags) \ 528 static void record_gp_stall_check_time(void); !! 613 do { \ 529 static void rcu_iw_handler(struct irq_work *iw !! 614 typecheck(unsigned long, flags); \ 530 static void check_cpu_stall(struct rcu_data *r !! 615 raw_spin_unlock_irqrestore(&ACCESS_PRIVATE(rnp, lock), flags); \ 531 static void rcu_check_gp_start_stall(struct rc !! 616 } while (0) 532 const uns << 533 617 534 /* Forward declarations for tree_exp.h. */ !! 618 static inline bool raw_spin_trylock_rcu_node(struct rcu_node *rnp) 535 static void sync_rcu_do_polled_gp(struct work_ !! 619 { >> 620 bool locked = raw_spin_trylock(&ACCESS_PRIVATE(rnp, lock)); >> 621 >> 622 if (locked) >> 623 smp_mb__after_unlock_lock(); >> 624 return locked; >> 625 } 536 626
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.