diff options
Diffstat (limited to 'kernel/rcutree.h')
| -rw-r--r-- | kernel/rcutree.h | 69 |
1 files changed, 58 insertions, 11 deletions
diff --git a/kernel/rcutree.h b/kernel/rcutree.h index 1899023b0962..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)++) |
| @@ -204,11 +237,12 @@ struct rcu_data { | |||
| 204 | #define RCU_GP_IDLE 0 /* No grace period in progress. */ | 237 | #define RCU_GP_IDLE 0 /* No grace period in progress. */ |
| 205 | #define RCU_GP_INIT 1 /* Grace period being initialized. */ | 238 | #define RCU_GP_INIT 1 /* Grace period being initialized. */ |
| 206 | #define RCU_SAVE_DYNTICK 2 /* Need to scan dyntick state. */ | 239 | #define RCU_SAVE_DYNTICK 2 /* Need to scan dyntick state. */ |
| 207 | #define RCU_FORCE_QS 3 /* Need to force quiescent state. */ | 240 | #define RCU_SAVE_COMPLETED 3 /* Need to save rsp->completed. */ |
| 241 | #define RCU_FORCE_QS 4 /* Need to force quiescent state. */ | ||
| 208 | #ifdef CONFIG_NO_HZ | 242 | #ifdef CONFIG_NO_HZ |
| 209 | #define RCU_SIGNAL_INIT RCU_SAVE_DYNTICK | 243 | #define RCU_SIGNAL_INIT RCU_SAVE_DYNTICK |
| 210 | #else /* #ifdef CONFIG_NO_HZ */ | 244 | #else /* #ifdef CONFIG_NO_HZ */ |
| 211 | #define RCU_SIGNAL_INIT RCU_FORCE_QS | 245 | #define RCU_SIGNAL_INIT RCU_SAVE_COMPLETED |
| 212 | #endif /* #else #ifdef CONFIG_NO_HZ */ | 246 | #endif /* #else #ifdef CONFIG_NO_HZ */ |
| 213 | 247 | ||
| 214 | #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 */ |
| @@ -246,7 +280,7 @@ struct rcu_state { | |||
| 246 | long gpnum; /* Current gp number. */ | 280 | long gpnum; /* Current gp number. */ |
| 247 | long completed; /* # of last completed gp. */ | 281 | long completed; /* # of last completed gp. */ |
| 248 | 282 | ||
| 249 | /* End of fields guarded by root rcu_node's lock. */ | 283 | /* End of fields guarded by root rcu_node's lock. */ |
| 250 | 284 | ||
| 251 | spinlock_t onofflock; /* exclude on/offline and */ | 285 | spinlock_t onofflock; /* exclude on/offline and */ |
| 252 | /* starting new GP. Also */ | 286 | /* starting new GP. Also */ |
| @@ -260,6 +294,8 @@ struct rcu_state { | |||
| 260 | long orphan_qlen; /* Number of orphaned cbs. */ | 294 | long orphan_qlen; /* Number of orphaned cbs. */ |
| 261 | spinlock_t fqslock; /* Only one task forcing */ | 295 | spinlock_t fqslock; /* Only one task forcing */ |
| 262 | /* quiescent states. */ | 296 | /* quiescent states. */ |
| 297 | long completed_fqs; /* Value of completed @ snap. */ | ||
| 298 | /* Protected by fqslock. */ | ||
| 263 | unsigned long jiffies_force_qs; /* Time at which to invoke */ | 299 | unsigned long jiffies_force_qs; /* Time at which to invoke */ |
| 264 | /* force_quiescent_state(). */ | 300 | /* force_quiescent_state(). */ |
| 265 | unsigned long n_force_qs; /* Number of calls to */ | 301 | unsigned long n_force_qs; /* Number of calls to */ |
| @@ -274,11 +310,15 @@ struct rcu_state { | |||
| 274 | unsigned long jiffies_stall; /* Time at which to check */ | 310 | unsigned long jiffies_stall; /* Time at which to check */ |
| 275 | /* for CPU stalls. */ | 311 | /* for CPU stalls. */ |
| 276 | #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ | 312 | #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ |
| 277 | #ifdef CONFIG_NO_HZ | ||
| 278 | long dynticks_completed; /* Value of completed @ snap. */ | ||
| 279 | #endif /* #ifdef CONFIG_NO_HZ */ | ||
| 280 | }; | 313 | }; |
| 281 | 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 | |||
| 282 | #ifdef RCU_TREE_NONCORE | 322 | #ifdef RCU_TREE_NONCORE |
| 283 | 323 | ||
| 284 | /* | 324 | /* |
| @@ -298,10 +338,14 @@ DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data); | |||
| 298 | #else /* #ifdef RCU_TREE_NONCORE */ | 338 | #else /* #ifdef RCU_TREE_NONCORE */ |
| 299 | 339 | ||
| 300 | /* Forward declarations for rcutree_plugin.h */ | 340 | /* Forward declarations for rcutree_plugin.h */ |
| 301 | static inline void rcu_bootup_announce(void); | 341 | static void rcu_bootup_announce(void); |
| 302 | long rcu_batches_completed(void); | 342 | long rcu_batches_completed(void); |
| 303 | static void rcu_preempt_note_context_switch(int cpu); | 343 | static void rcu_preempt_note_context_switch(int cpu); |
| 304 | 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 */ | ||
| 305 | #ifdef CONFIG_RCU_CPU_STALL_DETECTOR | 349 | #ifdef CONFIG_RCU_CPU_STALL_DETECTOR |
| 306 | static void rcu_print_task_stall(struct rcu_node *rnp); | 350 | static void rcu_print_task_stall(struct rcu_node *rnp); |
| 307 | #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ | 351 | #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ |
| @@ -315,6 +359,9 @@ static void rcu_preempt_offline_cpu(int cpu); | |||
| 315 | static void rcu_preempt_check_callbacks(int cpu); | 359 | static void rcu_preempt_check_callbacks(int cpu); |
| 316 | static void rcu_preempt_process_callbacks(void); | 360 | static void rcu_preempt_process_callbacks(void); |
| 317 | 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) */ | ||
| 318 | static int rcu_preempt_pending(int cpu); | 365 | static int rcu_preempt_pending(int cpu); |
| 319 | static int rcu_preempt_needs_cpu(int cpu); | 366 | static int rcu_preempt_needs_cpu(int cpu); |
| 320 | static void __cpuinit rcu_preempt_init_percpu_data(int cpu); | 367 | static void __cpuinit rcu_preempt_init_percpu_data(int cpu); |
