diff options
| author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2018-08-04 00:00:38 -0400 |
|---|---|---|
| committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2018-08-30 19:03:52 -0400 |
| commit | dc5a4f2932f18568bb9d8cdbe2139a8ddbc28bb8 (patch) | |
| tree | 9de19e6c07d81972471a3af0573123149e3e8bc1 /kernel/rcu | |
| parent | 4c5273bf2b5ed9b585e470dda19c09c875a9fbbd (diff) | |
rcu: Switch ->dynticks to rcu_data structure, remove rcu_dynticks
This commit move ->dynticks from the rcu_dynticks structure to the
rcu_data structure, replacing the field of the same name. It also updates
the code to access ->dynticks from the rcu_data structure and to use the
rcu_data structure rather than following to now-gone ->dynticks field
to the now-gone rcu_dynticks structure. While in the area, this commit
also fixes up comments.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/rcu')
| -rw-r--r-- | kernel/rcu/tree.c | 92 | ||||
| -rw-r--r-- | kernel/rcu/tree.h | 35 | ||||
| -rw-r--r-- | kernel/rcu/tree_exp.h | 6 | ||||
| -rw-r--r-- | kernel/rcu/tree_plugin.h | 3 |
4 files changed, 56 insertions, 80 deletions
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index bfa264a6f3fc..32f500fb24d3 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c | |||
| @@ -73,9 +73,20 @@ | |||
| 73 | 73 | ||
| 74 | /* Data structures. */ | 74 | /* Data structures. */ |
| 75 | 75 | ||
| 76 | /* | ||
| 77 | * Steal a bit from the bottom of ->dynticks for idle entry/exit | ||
| 78 | * control. Initially this is for TLB flushing. | ||
| 79 | */ | ||
| 80 | #define RCU_DYNTICK_CTRL_MASK 0x1 | ||
| 81 | #define RCU_DYNTICK_CTRL_CTR (RCU_DYNTICK_CTRL_MASK + 1) | ||
| 82 | #ifndef rcu_eqs_special_exit | ||
| 83 | #define rcu_eqs_special_exit() do { } while (0) | ||
| 84 | #endif | ||
| 85 | |||
| 76 | static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, rcu_data) = { | 86 | static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, rcu_data) = { |
| 77 | .dynticks_nesting = 1, | 87 | .dynticks_nesting = 1, |
| 78 | .dynticks_nmi_nesting = DYNTICK_IRQ_NONIDLE, | 88 | .dynticks_nmi_nesting = DYNTICK_IRQ_NONIDLE, |
| 89 | .dynticks = ATOMIC_INIT(RCU_DYNTICK_CTRL_CTR), | ||
| 79 | }; | 90 | }; |
| 80 | struct rcu_state rcu_state = { | 91 | struct rcu_state rcu_state = { |
| 81 | .level = { &rcu_state.node[0] }, | 92 | .level = { &rcu_state.node[0] }, |
| @@ -203,26 +214,12 @@ void rcu_softirq_qs(void) | |||
| 203 | } | 214 | } |
| 204 | 215 | ||
| 205 | /* | 216 | /* |
| 206 | * Steal a bit from the bottom of ->dynticks for idle entry/exit | ||
| 207 | * control. Initially this is for TLB flushing. | ||
| 208 | */ | ||
| 209 | #define RCU_DYNTICK_CTRL_MASK 0x1 | ||
| 210 | #define RCU_DYNTICK_CTRL_CTR (RCU_DYNTICK_CTRL_MASK + 1) | ||
| 211 | #ifndef rcu_eqs_special_exit | ||
| 212 | #define rcu_eqs_special_exit() do { } while (0) | ||
| 213 | #endif | ||
| 214 | |||
| 215 | static DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = { | ||
| 216 | .dynticks = ATOMIC_INIT(RCU_DYNTICK_CTRL_CTR), | ||
| 217 | }; | ||
| 218 | |||
| 219 | /* | ||
| 220 | * Record entry into an extended quiescent state. This is only to be | 217 | * Record entry into an extended quiescent state. This is only to be |
| 221 | * called when not already in an extended quiescent state. | 218 | * called when not already in an extended quiescent state. |
| 222 | */ | 219 | */ |
| 223 | static void rcu_dynticks_eqs_enter(void) | 220 | static void rcu_dynticks_eqs_enter(void) |
| 224 | { | 221 | { |
| 225 | struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); | 222 | struct rcu_data *rdp = this_cpu_ptr(&rcu_data); |
| 226 | int seq; | 223 | int seq; |
| 227 | 224 | ||
| 228 | /* | 225 | /* |
| @@ -230,7 +227,7 @@ static void rcu_dynticks_eqs_enter(void) | |||
| 230 | * critical sections, and we also must force ordering with the | 227 | * critical sections, and we also must force ordering with the |
| 231 | * next idle sojourn. | 228 | * next idle sojourn. |
| 232 | */ | 229 | */ |
| 233 | seq = atomic_add_return(RCU_DYNTICK_CTRL_CTR, &rdtp->dynticks); | 230 | seq = atomic_add_return(RCU_DYNTICK_CTRL_CTR, &rdp->dynticks); |
| 234 | /* Better be in an extended quiescent state! */ | 231 | /* Better be in an extended quiescent state! */ |
| 235 | WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && | 232 | WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && |
| 236 | (seq & RCU_DYNTICK_CTRL_CTR)); | 233 | (seq & RCU_DYNTICK_CTRL_CTR)); |
| @@ -245,7 +242,7 @@ static void rcu_dynticks_eqs_enter(void) | |||
| 245 | */ | 242 | */ |
| 246 | static void rcu_dynticks_eqs_exit(void) | 243 | static void rcu_dynticks_eqs_exit(void) |
| 247 | { | 244 | { |
| 248 | struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); | 245 | struct rcu_data *rdp = this_cpu_ptr(&rcu_data); |
| 249 | int seq; | 246 | int seq; |
| 250 | 247 | ||
| 251 | /* | 248 | /* |
| @@ -253,11 +250,11 @@ static void rcu_dynticks_eqs_exit(void) | |||
| 253 | * and we also must force ordering with the next RCU read-side | 250 | * and we also must force ordering with the next RCU read-side |
| 254 | * critical section. | 251 | * critical section. |
| 255 | */ | 252 | */ |
| 256 | seq = atomic_add_return(RCU_DYNTICK_CTRL_CTR, &rdtp->dynticks); | 253 | seq = atomic_add_return(RCU_DYNTICK_CTRL_CTR, &rdp->dynticks); |
| 257 | WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && | 254 | WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && |
| 258 | !(seq & RCU_DYNTICK_CTRL_CTR)); | 255 | !(seq & RCU_DYNTICK_CTRL_CTR)); |
| 259 | if (seq & RCU_DYNTICK_CTRL_MASK) { | 256 | if (seq & RCU_DYNTICK_CTRL_MASK) { |
| 260 | atomic_andnot(RCU_DYNTICK_CTRL_MASK, &rdtp->dynticks); | 257 | atomic_andnot(RCU_DYNTICK_CTRL_MASK, &rdp->dynticks); |
| 261 | smp_mb__after_atomic(); /* _exit after clearing mask. */ | 258 | smp_mb__after_atomic(); /* _exit after clearing mask. */ |
| 262 | /* Prefer duplicate flushes to losing a flush. */ | 259 | /* Prefer duplicate flushes to losing a flush. */ |
| 263 | rcu_eqs_special_exit(); | 260 | rcu_eqs_special_exit(); |
| @@ -276,11 +273,11 @@ static void rcu_dynticks_eqs_exit(void) | |||
| 276 | */ | 273 | */ |
| 277 | static void rcu_dynticks_eqs_online(void) | 274 | static void rcu_dynticks_eqs_online(void) |
| 278 | { | 275 | { |
| 279 | struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); | 276 | struct rcu_data *rdp = this_cpu_ptr(&rcu_data); |
| 280 | 277 | ||
| 281 | if (atomic_read(&rdtp->dynticks) & RCU_DYNTICK_CTRL_CTR) | 278 | if (atomic_read(&rdp->dynticks) & RCU_DYNTICK_CTRL_CTR) |
| 282 | return; | 279 | return; |
| 283 | atomic_add(RCU_DYNTICK_CTRL_CTR, &rdtp->dynticks); | 280 | atomic_add(RCU_DYNTICK_CTRL_CTR, &rdp->dynticks); |
| 284 | } | 281 | } |
| 285 | 282 | ||
| 286 | /* | 283 | /* |
| @@ -290,18 +287,18 @@ static void rcu_dynticks_eqs_online(void) | |||
| 290 | */ | 287 | */ |
| 291 | bool rcu_dynticks_curr_cpu_in_eqs(void) | 288 | bool rcu_dynticks_curr_cpu_in_eqs(void) |
| 292 | { | 289 | { |
| 293 | struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); | 290 | struct rcu_data *rdp = this_cpu_ptr(&rcu_data); |
| 294 | 291 | ||
| 295 | return !(atomic_read(&rdtp->dynticks) & RCU_DYNTICK_CTRL_CTR); | 292 | return !(atomic_read(&rdp->dynticks) & RCU_DYNTICK_CTRL_CTR); |
| 296 | } | 293 | } |
| 297 | 294 | ||
| 298 | /* | 295 | /* |
| 299 | * Snapshot the ->dynticks counter with full ordering so as to allow | 296 | * Snapshot the ->dynticks counter with full ordering so as to allow |
| 300 | * stable comparison of this counter with past and future snapshots. | 297 | * stable comparison of this counter with past and future snapshots. |
| 301 | */ | 298 | */ |
| 302 | int rcu_dynticks_snap(struct rcu_dynticks *rdtp) | 299 | int rcu_dynticks_snap(struct rcu_data *rdp) |
| 303 | { | 300 | { |
| 304 | int snap = atomic_add_return(0, &rdtp->dynticks); | 301 | int snap = atomic_add_return(0, &rdp->dynticks); |
| 305 | 302 | ||
| 306 | return snap & ~RCU_DYNTICK_CTRL_MASK; | 303 | return snap & ~RCU_DYNTICK_CTRL_MASK; |
| 307 | } | 304 | } |
| @@ -316,13 +313,13 @@ static bool rcu_dynticks_in_eqs(int snap) | |||
| 316 | } | 313 | } |
| 317 | 314 | ||
| 318 | /* | 315 | /* |
| 319 | * Return true if the CPU corresponding to the specified rcu_dynticks | 316 | * Return true if the CPU corresponding to the specified rcu_data |
| 320 | * structure has spent some time in an extended quiescent state since | 317 | * structure has spent some time in an extended quiescent state since |
| 321 | * rcu_dynticks_snap() returned the specified snapshot. | 318 | * rcu_dynticks_snap() returned the specified snapshot. |
| 322 | */ | 319 | */ |
| 323 | static bool rcu_dynticks_in_eqs_since(struct rcu_dynticks *rdtp, int snap) | 320 | static bool rcu_dynticks_in_eqs_since(struct rcu_data *rdp, int snap) |
| 324 | { | 321 | { |
| 325 | return snap != rcu_dynticks_snap(rdtp); | 322 | return snap != rcu_dynticks_snap(rdp); |
| 326 | } | 323 | } |
| 327 | 324 | ||
| 328 | /* | 325 | /* |
| @@ -336,14 +333,14 @@ bool rcu_eqs_special_set(int cpu) | |||
| 336 | { | 333 | { |
| 337 | int old; | 334 | int old; |
| 338 | int new; | 335 | int new; |
| 339 | struct rcu_dynticks *rdtp = &per_cpu(rcu_dynticks, cpu); | 336 | struct rcu_data *rdp = &per_cpu(rcu_data, cpu); |
| 340 | 337 | ||
| 341 | do { | 338 | do { |
| 342 | old = atomic_read(&rdtp->dynticks); | 339 | old = atomic_read(&rdp->dynticks); |
| 343 | if (old & RCU_DYNTICK_CTRL_CTR) | 340 | if (old & RCU_DYNTICK_CTRL_CTR) |
| 344 | return false; | 341 | return false; |
| 345 | new = old | RCU_DYNTICK_CTRL_MASK; | 342 | new = old | RCU_DYNTICK_CTRL_MASK; |
| 346 | } while (atomic_cmpxchg(&rdtp->dynticks, old, new) != old); | 343 | } while (atomic_cmpxchg(&rdp->dynticks, old, new) != old); |
| 347 | return true; | 344 | return true; |
| 348 | } | 345 | } |
| 349 | 346 | ||
| @@ -360,11 +357,11 @@ bool rcu_eqs_special_set(int cpu) | |||
| 360 | */ | 357 | */ |
| 361 | static void __maybe_unused rcu_momentary_dyntick_idle(void) | 358 | static void __maybe_unused rcu_momentary_dyntick_idle(void) |
| 362 | { | 359 | { |
| 363 | struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); | ||
| 364 | int special; | 360 | int special; |
| 365 | 361 | ||
| 366 | raw_cpu_write(rcu_data.rcu_need_heavy_qs, false); | 362 | raw_cpu_write(rcu_data.rcu_need_heavy_qs, false); |
| 367 | special = atomic_add_return(2 * RCU_DYNTICK_CTRL_CTR, &rdtp->dynticks); | 363 | special = atomic_add_return(2 * RCU_DYNTICK_CTRL_CTR, |
| 364 | &this_cpu_ptr(&rcu_data)->dynticks); | ||
| 368 | /* It is illegal to call this from idle state. */ | 365 | /* It is illegal to call this from idle state. */ |
| 369 | WARN_ON_ONCE(!(special & RCU_DYNTICK_CTRL_CTR)); | ||
