diff options
Diffstat (limited to 'kernel/rcutree.h')
-rw-r--r-- | kernel/rcutree.h | 84 |
1 files changed, 68 insertions, 16 deletions
diff --git a/kernel/rcutree.h b/kernel/rcutree.h index b40ac5706040..d2a0046f63b2 100644 --- a/kernel/rcutree.h +++ b/kernel/rcutree.h | |||
@@ -34,10 +34,11 @@ | |||
34 | * In practice, this has not been tested, so there is probably some | 34 | * In practice, this has not been tested, so there is probably some |
35 | * bug somewhere. | 35 | * bug somewhere. |
36 | */ | 36 | */ |
37 | #define MAX_RCU_LVLS 3 | 37 | #define MAX_RCU_LVLS 4 |
38 | #define RCU_FANOUT (CONFIG_RCU_FANOUT) | 38 | #define RCU_FANOUT (CONFIG_RCU_FANOUT) |
39 | #define RCU_FANOUT_SQ (RCU_FANOUT * RCU_FANOUT) | 39 | #define RCU_FANOUT_SQ (RCU_FANOUT * RCU_FANOUT) |
40 | #define RCU_FANOUT_CUBE (RCU_FANOUT_SQ * RCU_FANOUT) | 40 | #define RCU_FANOUT_CUBE (RCU_FANOUT_SQ * RCU_FANOUT) |
41 | #define RCU_FANOUT_FOURTH (RCU_FANOUT_CUBE * RCU_FANOUT) | ||
41 | 42 | ||
42 | #if NR_CPUS <= RCU_FANOUT | 43 | #if NR_CPUS <= RCU_FANOUT |
43 | # define NUM_RCU_LVLS 1 | 44 | # define NUM_RCU_LVLS 1 |
@@ -45,23 +46,33 @@ | |||
45 | # define NUM_RCU_LVL_1 (NR_CPUS) | 46 | # define NUM_RCU_LVL_1 (NR_CPUS) |
46 | # define NUM_RCU_LVL_2 0 | 47 | # define NUM_RCU_LVL_2 0 |
47 | # define NUM_RCU_LVL_3 0 | 48 | # define NUM_RCU_LVL_3 0 |
49 | # define NUM_RCU_LVL_4 0 | ||
48 | #elif NR_CPUS <= RCU_FANOUT_SQ | 50 | #elif NR_CPUS <= RCU_FANOUT_SQ |
49 | # define NUM_RCU_LVLS 2 | 51 | # define NUM_RCU_LVLS 2 |
50 | # define NUM_RCU_LVL_0 1 | 52 | # define NUM_RCU_LVL_0 1 |
51 | # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT) | 53 | # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT) |
52 | # define NUM_RCU_LVL_2 (NR_CPUS) | 54 | # define NUM_RCU_LVL_2 (NR_CPUS) |
53 | # define NUM_RCU_LVL_3 0 | 55 | # define NUM_RCU_LVL_3 0 |
56 | # define NUM_RCU_LVL_4 0 | ||
54 | #elif NR_CPUS <= RCU_FANOUT_CUBE | 57 | #elif NR_CPUS <= RCU_FANOUT_CUBE |
55 | # define NUM_RCU_LVLS 3 | 58 | # define NUM_RCU_LVLS 3 |
56 | # define NUM_RCU_LVL_0 1 | 59 | # define NUM_RCU_LVL_0 1 |
57 | # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_SQ) | 60 | # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_SQ) |
58 | # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT) | 61 | # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT) |
59 | # define NUM_RCU_LVL_3 NR_CPUS | 62 | # define NUM_RCU_LVL_3 NR_CPUS |
63 | # define NUM_RCU_LVL_4 0 | ||
64 | #elif NR_CPUS <= RCU_FANOUT_FOURTH | ||
65 | # define NUM_RCU_LVLS 4 | ||
66 | # define NUM_RCU_LVL_0 1 | ||
67 | # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_CUBE) | ||
68 | # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_SQ) | ||
69 | # define NUM_RCU_LVL_3 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT) | ||
70 | # define NUM_RCU_LVL_4 NR_CPUS | ||
60 | #else | 71 | #else |
61 | # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" | 72 | # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" |
62 | #endif /* #if (NR_CPUS) <= RCU_FANOUT */ | 73 | #endif /* #if (NR_CPUS) <= RCU_FANOUT */ |
63 | 74 | ||
64 | #define RCU_SUM (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3) | 75 | #define RCU_SUM (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3 + NUM_RCU_LVL_4) |
65 | #define NUM_RCU_NODES (RCU_SUM - NR_CPUS) | 76 | #define NUM_RCU_NODES (RCU_SUM - NR_CPUS) |
66 | 77 | ||
67 | /* | 78 | /* |
@@ -84,14 +95,21 @@ struct rcu_node { | |||
84 | long gpnum; /* Current grace period for this node. */ | 95 | long gpnum; /* Current grace period for this node. */ |
85 | /* This will either be equal to or one */ | 96 | /* This will either be equal to or one */ |
86 | /* behind the root rcu_node's gpnum. */ | 97 | /* behind the root rcu_node's gpnum. */ |
98 | long completed; /* Last grace period completed for this node. */ | ||
99 | /* This will either be equal to or one */ | ||
100 | /* behind the root rcu_node's gpnum. */ | ||
87 | unsigned long qsmask; /* CPUs or groups that need to switch in */ | 101 | unsigned long qsmask; /* CPUs or groups that need to switch in */ |
88 | /* order for current grace period to proceed.*/ | 102 | /* order for current grace period to proceed.*/ |
89 | /* In leaf rcu_node, each bit corresponds to */ | 103 | /* In leaf rcu_node, each bit corresponds to */ |
90 | /* an rcu_data structure, otherwise, each */ | 104 | /* an rcu_data structure, otherwise, each */ |
91 | /* bit corresponds to a child rcu_node */ | 105 | /* bit corresponds to a child rcu_node */ |
92 | /* structure. */ | 106 | /* structure. */ |
107 | unsigned long expmask; /* Groups that have ->blocked_tasks[] */ | ||
108 | /* elements that need to drain to allow the */ | ||
109 | /* current expedited grace period to */ | ||
110 | /* complete (only for TREE_PREEMPT_RCU). */ | ||
93 | unsigned long qsmaskinit; | 111 | unsigned long qsmaskinit; |
94 | /* Per-GP initialization for qsmask. */ | 112 | /* Per-GP initial value for qsmask & expmask. */ |
95 | unsigned long grpmask; /* Mask to apply to parent qsmask. */ | 113 | unsigned long grpmask; /* Mask to apply to parent qsmask. */ |
96 | /* Only one bit will be set in this mask. */ | 114 | /* Only one bit will be set in this mask. */ |
97 | int grplo; /* lowest-numbered CPU or group here. */ | 115 | int grplo; /* lowest-numbered CPU or group here. */ |
@@ -99,7 +117,7 @@ struct rcu_node { | |||
99 | u8 grpnum; /* CPU/group number for next level up. */ | 117 | u8 grpnum; /* CPU/group number for next level up. */ |
100 | u8 level; /* root is at level 0. */ | 118 | u8 level; /* root is at level 0. */ |
101 | struct rcu_node *parent; | 119 | struct rcu_node *parent; |
102 | struct list_head blocked_tasks[2]; | 120 | struct list_head blocked_tasks[4]; |
103 | /* Tasks blocked in RCU read-side critsect. */ | 121 | /* Tasks blocked in RCU read-side critsect. */ |
104 | /* Grace period number (->gpnum) x blocked */ | 122 | /* Grace period number (->gpnum) x blocked */ |
105 | /* by tasks on the (x & 0x1) element of the */ | 123 | /* by tasks on the (x & 0x1) element of the */ |
@@ -114,6 +132,21 @@ struct rcu_node { | |||
114 | for ((rnp) = &(rsp)->node[0]; \ | 132 | for ((rnp) = &(rsp)->node[0]; \ |
115 | (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) | 133 | (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) |
116 | 134 | ||
135 | /* | ||
136 | * Do a breadth-first scan of the non-leaf rcu_node structures for the | ||
137 | * specified rcu_state structure. Note that if there is a singleton | ||
138 | * rcu_node tree with but one rcu_node structure, this loop is a no-op. | ||
139 | */ | ||
140 | #define rcu_for_each_nonleaf_node_breadth_first(rsp, rnp) \ | ||
141 | for ((rnp) = &(rsp)->node[0]; \ | ||
142 | (rnp) < (rsp)->level[NUM_RCU_LVLS - 1]; (rnp)++) | ||
143 | |||
144 | /* | ||
145 | * Scan the leaves of the rcu_node hierarchy for the specified rcu_state | ||
146 | * structure. Note that if there is a singleton rcu_node tree with but | ||
147 | * one rcu_node structure, this loop -will- visit the rcu_node structure. | ||
148 | * It is still a leaf node, even if it is also the root node. | ||
149 | */ | ||
117 | #define rcu_for_each_leaf_node(rsp, rnp) \ | 150 | #define rcu_for_each_leaf_node(rsp, rnp) \ |
118 | for ((rnp) = (rsp)->level[NUM_RCU_LVLS - 1]; \ | 151 | for ((rnp) = (rsp)->level[NUM_RCU_LVLS - 1]; \ |
119 | (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) | 152 | (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) |
@@ -167,6 +200,10 @@ struct rcu_data { | |||
167 | struct rcu_head *nxtlist; | 200 | struct rcu_head *nxtlist; |
168 | struct rcu_head **nxttail[RCU_NEXT_SIZE]; | 201 | struct rcu_head **nxttail[RCU_NEXT_SIZE]; |
169 | long qlen; /* # of queued callbacks */ | 202 | long qlen; /* # of queued callbacks */ |
203 | long qlen_last_fqs_check; | ||
204 | /* qlen at last check for QS forcing */ | ||
205 | unsigned long n_force_qs_snap; | ||
206 | /* did other CPU force QS recently? */ | ||
170 | long blimit; /* Upper limit on a processed batch */ | 207 | long blimit; /* Upper limit on a processed batch */ |
171 | 208 | ||
172 | #ifdef CONFIG_NO_HZ | 209 | #ifdef CONFIG_NO_HZ |
@@ -197,13 +234,15 @@ struct rcu_data { | |||
197 | }; | 234 | }; |
198 | 235 | ||
199 | /* Values for signaled field in struct rcu_state. */ | 236 | /* Values for signaled field in struct rcu_state. */ |
200 | #define RCU_GP_INIT 0 /* Grace period being initialized. */ | 237 | #define RCU_GP_IDLE 0 /* No grace period in progress. */ |
201 | #define RCU_SAVE_DYNTICK 1 /* Need to scan dyntick state. */ | 238 | #define RCU_GP_INIT 1 /* Grace period being initialized. */ |
202 | #define RCU_FORCE_QS 2 /* Need to force quiescent state. */ | 239 | #define RCU_SAVE_DYNTICK 2 /* Need to scan dyntick state. */ |
240 | #define RCU_SAVE_COMPLETED 3 /* Need to save rsp->completed. */ | ||
241 | #define RCU_FORCE_QS 4 /* Need to force quiescent state. */ | ||
203 | #ifdef CONFIG_NO_HZ | 242 | #ifdef CONFIG_NO_HZ |
204 | #define RCU_SIGNAL_INIT RCU_SAVE_DYNTICK | 243 | #define RCU_SIGNAL_INIT RCU_SAVE_DYNTICK |
205 | #else /* #ifdef CONFIG_NO_HZ */ | 244 | #else /* #ifdef CONFIG_NO_HZ */ |
206 | #define RCU_SIGNAL_INIT RCU_FORCE_QS | 245 | #define RCU_SIGNAL_INIT RCU_SAVE_COMPLETED |
207 | #endif /* #else #ifdef CONFIG_NO_HZ */ | 246 | #endif /* #else #ifdef CONFIG_NO_HZ */ |
208 | 247 | ||
209 | #define RCU_JIFFIES_TILL_FORCE_QS 3 /* for rsp->jiffies_force_qs */ | 248 | #define RCU_JIFFIES_TILL_FORCE_QS 3 /* for rsp->jiffies_force_qs */ |
@@ -241,7 +280,7 @@ struct rcu_state { | |||
241 | long gpnum; /* Current gp number. */ | 280 | long gpnum; /* Current gp number. */ |
242 | long completed; /* # of last completed gp. */ | 281 | long completed; /* # of last completed gp. */ |
243 | 282 | ||
244 | /* End of fields guarded by root rcu_node's lock. */ | 283 | /* End of fields guarded by root rcu_node's lock. */ |
245 | 284 | ||
246 | spinlock_t onofflock; /* exclude on/offline and */ | 285 | spinlock_t onofflock; /* exclude on/offline and */ |
247 | /* starting new GP. Also */ | 286 | /* starting new GP. Also */ |
@@ -255,6 +294,8 @@ struct rcu_state { | |||
255 | long orphan_qlen; /* Number of orphaned cbs. */ | 294 | long orphan_qlen; /* Number of orphaned cbs. */ |
256 | spinlock_t fqslock; /* Only one task forcing */ | 295 | spinlock_t fqslock; /* Only one task forcing */ |
257 | /* quiescent states. */ | 296 | /* quiescent states. */ |
297 | long completed_fqs; /* Value of completed @ snap. */ | ||
298 | /* Protected by fqslock. */ | ||
258 | unsigned long jiffies_force_qs; /* Time at which to invoke */ | 299 | unsigned long jiffies_force_qs; /* Time at which to invoke */ |
259 | /* force_quiescent_state(). */ | 300 | /* force_quiescent_state(). */ |
260 | unsigned long n_force_qs; /* Number of calls to */ | 301 | unsigned long n_force_qs; /* Number of calls to */ |
@@ -269,11 +310,15 @@ struct rcu_state { | |||
269 | unsigned long jiffies_stall; /* Time at which to check */ | 310 | unsigned long jiffies_stall; /* Time at which to check */ |
270 | /* for CPU stalls. */ | 311 | /* for CPU stalls. */ |
271 | #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ | 312 | #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ |
272 | #ifdef CONFIG_NO_HZ | ||
273 | long dynticks_completed; /* Value of completed @ snap. */ | ||
274 | #endif /* #ifdef CONFIG_NO_HZ */ | ||
275 | }; | 313 | }; |
276 | 314 | ||
315 | /* Return values for rcu_preempt_offline_tasks(). */ | ||
316 | |||
317 | #define RCU_OFL_TASKS_NORM_GP 0x1 /* Tasks blocking normal */ | ||
318 | /* GP were moved to root. */ | ||
319 | #define RCU_OFL_TASKS_EXP_GP 0x2 /* Tasks blocking expedited */ | ||
320 | /* GP were moved to root. */ | ||
321 | |||
277 | #ifdef RCU_TREE_NONCORE | 322 | #ifdef RCU_TREE_NONCORE |
278 | 323 | ||
279 | /* | 324 | /* |
@@ -293,23 +338,30 @@ DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data); | |||
293 | #else /* #ifdef RCU_TREE_NONCORE */ | 338 | #else /* #ifdef RCU_TREE_NONCORE */ |
294 | 339 | ||
295 | /* Forward declarations for rcutree_plugin.h */ | 340 | /* Forward declarations for rcutree_plugin.h */ |
296 | static inline void rcu_bootup_announce(void); | 341 | static void rcu_bootup_announce(void); |
297 | long rcu_batches_completed(void); | 342 | long rcu_batches_completed(void); |
298 | static void rcu_preempt_note_context_switch(int cpu); | 343 | static void rcu_preempt_note_context_switch(int cpu); |
299 | static int rcu_preempted_readers(struct rcu_node *rnp); | 344 | static int rcu_preempted_readers(struct rcu_node *rnp); |
345 | #ifdef CONFIG_HOTPLUG_CPU | ||
346 | static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, | ||
347 | unsigned long flags); | ||
348 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | ||
300 | #ifdef CONFIG_RCU_CPU_STALL_DETECTOR | 349 | #ifdef CONFIG_RCU_CPU_STALL_DETECTOR |
301 | static void rcu_print_task_stall(struct rcu_node *rnp); | 350 | static void rcu_print_task_stall(struct rcu_node *rnp); |
302 | #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ | 351 | #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ |
303 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp); | 352 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp); |
304 | #ifdef CONFIG_HOTPLUG_CPU | 353 | #ifdef CONFIG_HOTPLUG_CPU |
305 | static void rcu_preempt_offline_tasks(struct rcu_state *rsp, | 354 | static int rcu_preempt_offline_tasks(struct rcu_state *rsp, |
306 | struct rcu_node *rnp, | 355 | struct rcu_node *rnp, |
307 | struct rcu_data *rdp); | 356 | struct rcu_data *rdp); |
308 | static void rcu_preempt_offline_cpu(int cpu); | 357 | static void rcu_preempt_offline_cpu(int cpu); |
309 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | 358 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
310 | static void rcu_preempt_check_callbacks(int cpu); | 359 | static void rcu_preempt_check_callbacks(int cpu); |
311 | static void rcu_preempt_process_callbacks(void); | 360 | static void rcu_preempt_process_callbacks(void); |
312 | void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); | 361 | void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); |
362 | #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_TREE_PREEMPT_RCU) | ||
363 | static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp); | ||
364 | #endif /* #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_TREE_PREEMPT_RCU) */ | ||
313 | static int rcu_preempt_pending(int cpu); | 365 | static int rcu_preempt_pending(int cpu); |
314 | static int rcu_preempt_needs_cpu(int cpu); | 366 | static int rcu_preempt_needs_cpu(int cpu); |
315 | static void __cpuinit rcu_preempt_init_percpu_data(int cpu); | 367 | static void __cpuinit rcu_preempt_init_percpu_data(int cpu); |