aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rcu/tree.c
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2018-04-18 11:11:39 -0700
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2018-05-15 10:29:18 -0700
commitc91a8675b9cc697c725b6d97fcc7f157f4a989d0 (patch)
tree335a7e265dda2c90ad19b8240b65be694fab0a0e /kernel/rcu/tree.c
parentrcu: Make rcu_start_future_gp()'s grace-period check more precise (diff)
downloadlinux-dev-c91a8675b9cc697c725b6d97fcc7f157f4a989d0.tar.xz
linux-dev-c91a8675b9cc697c725b6d97fcc7f157f4a989d0.zip
rcu: Add accessor macros for the ->need_future_gp[] array
Accessors for the ->need_future_gp[] array are currently open-coded, which makes them difficult to change. To improve maintainability, this commit adds need_future_gp_mask() to compute the indexing mask from the array size, need_future_gp_element() to access the element corresponding to the specified grace-period number, and need_any_future_gp() to determine if any future grace period is needed. This commit also applies need_future_gp_element() to existing open-coded single-element accesses. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Tested-by: Nicholas Piggin <npiggin@gmail.com>
Diffstat (limited to 'kernel/rcu/tree.c')
-rw-r--r--kernel/rcu/tree.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 4bbba17422cd..79fb99951a0c 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -718,11 +718,9 @@ static struct rcu_node *rcu_get_root(struct rcu_state *rsp)
static int rcu_future_needs_gp(struct rcu_state *rsp)
{
struct rcu_node *rnp = rcu_get_root(rsp);
- int idx = (READ_ONCE(rnp->completed) + 1) & 0x1;
- int *fp = &rnp->need_future_gp[idx];
lockdep_assert_irqs_disabled();
- return READ_ONCE(*fp);
+ return READ_ONCE(need_future_gp_element(rnp, rnp->completed));
}
/*
@@ -1699,7 +1697,7 @@ rcu_start_future_gp(struct rcu_node *rnp, struct rcu_data *rdp,
*/
c = rcu_cbs_completed(rdp->rsp, rnp);
trace_rcu_future_gp(rnp, rdp, c, TPS("Startleaf"));
- if (rnp->need_future_gp[c & 0x1]) {
+ if (need_future_gp_element(rnp, c)) {
trace_rcu_future_gp(rnp, rdp, c, TPS("Prestartleaf"));
goto out;
}
@@ -1711,7 +1709,7 @@ rcu_start_future_gp(struct rcu_node *rnp, struct rcu_data *rdp,
* current grace period, we don't need to explicitly start one.
*/
if (rnp->gpnum != rnp->completed) {
- rnp->need_future_gp[c & 0x1]++;
+ need_future_gp_element(rnp, c)++;
trace_rcu_future_gp(rnp, rdp, c, TPS("Startedleaf"));
goto out;
}
@@ -1737,13 +1735,13 @@ rcu_start_future_gp(struct rcu_node *rnp, struct rcu_data *rdp,
* If the needed for the required grace period is already
* recorded, trace and leave.
*/
- if (rnp_root->need_future_gp[c & 0x1]) {
+ if (need_future_gp_element(rnp_root, c)) {
trace_rcu_future_gp(rnp, rdp, c, TPS("Prestartedroot"));
goto unlock_out;
}
/* Record the need for the future grace period. */
- rnp_root->need_future_gp[c & 0x1]++;
+ need_future_gp_element(rnp_root, c)++;
/* If a grace period is not already in progress, start one. */
if (rnp_root->gpnum != rnp_root->completed) {
@@ -1771,8 +1769,8 @@ static int rcu_future_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp)
int needmore;
struct rcu_data *rdp = this_cpu_ptr(rsp->rda);
- rnp->need_future_gp[c & 0x1] = 0;
- needmore = rnp->need_future_gp[(c + 1) & 0x1];
+ need_future_gp_element(rnp, c) = 0;
+ needmore = need_future_gp_element(rnp, c + 1);
trace_rcu_future_gp(rnp, rdp, c,
needmore ? TPS("CleanupMore") : TPS("Cleanup"));
return needmore;