aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rcu/tree.c
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2016-11-02 17:12:05 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2017-01-16 18:47:53 -0500
commit8b2f63ab05eb233b2b396e133889ce3d1d30d944 (patch)
tree34158316a74053a5051a2277d65615dbb41d4e24 /kernel/rcu/tree.c
parent6563de9d6f1336157c9861bcd9864e0b47d65f9d (diff)
rcu: Abstract the dynticks snapshot operation
This commit is the second step towards full abstraction of all accesses to the ->dynticks counter, implementing the previously open-coded atomic add of zero in a new rcu_dynticks_snap() function. This abstraction will ease changes o the ->dynticks counter operation. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'kernel/rcu/tree.c')
-rw-r--r--kernel/rcu/tree.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 14e283c351f6..805d55ee0b2a 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -282,6 +282,17 @@ static DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = {
282}; 282};
283 283
284/* 284/*
285 * Snapshot the ->dynticks counter with full ordering so as to allow
286 * stable comparison of this counter with past and future snapshots.
287 */
288static int rcu_dynticks_snap(struct rcu_dynticks *rdtp)
289{
290 int snap = atomic_add_return(0, &rdtp->dynticks);
291
292 return snap;
293}
294
295/*
285 * Do a double-increment of the ->dynticks counter to emulate a 296 * Do a double-increment of the ->dynticks counter to emulate a
286 * momentary idle-CPU quiescent state. 297 * momentary idle-CPU quiescent state.
287 */ 298 */
@@ -1049,7 +1060,9 @@ void rcu_nmi_exit(void)
1049 */ 1060 */
1050bool notrace __rcu_is_watching(void) 1061bool notrace __rcu_is_watching(void)
1051{ 1062{
1052 return atomic_read(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1; 1063 struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks);
1064
1065 return atomic_read(&rdtp->dynticks) & 0x1;
1053} 1066}
1054 1067
1055/** 1068/**
@@ -1132,7 +1145,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
1132static int dyntick_save_progress_counter(struct rcu_data *rdp, 1145static int dyntick_save_progress_counter(struct rcu_data *rdp,
1133 bool *isidle, unsigned long *maxj) 1146 bool *isidle, unsigned long *maxj)
1134{ 1147{
1135 rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks); 1148 rdp->dynticks_snap = rcu_dynticks_snap(rdp->dynticks);
1136 rcu_sysidle_check_cpu(rdp, isidle, maxj); 1149 rcu_sysidle_check_cpu(rdp, isidle, maxj);
1137 if ((rdp->dynticks_snap & 0x1) == 0) { 1150 if ((rdp->dynticks_snap & 0x1) == 0) {
1138 trace_rcu_fqs(rdp->rsp->name, rdp->gpnum, rdp->cpu, TPS("dti")); 1151 trace_rcu_fqs(rdp->rsp->name, rdp->gpnum, rdp->cpu, TPS("dti"));
@@ -1157,7 +1170,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
1157 int *rcrmp; 1170 int *rcrmp;
1158 unsigned int snap; 1171 unsigned int snap;
1159 1172
1160 curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks); 1173 curr = (unsigned int)rcu_dynticks_snap(rdp->dynticks);
1161 snap = (unsigned int)rdp->dynticks_snap; 1174 snap = (unsigned int)rdp->dynticks_snap;
1162 1175
1163 /* 1176 /*