aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2009-11-10 16:37:22 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-10 16:48:50 -0500
commitc64ac3ce06558e534aec62b1fadeb0a3f111dac1 (patch)
treefaee8cf2d5cb47aeac4999a1e2163491a8e03734 /kernel
parent4bcfe055030d9e953945def3864f7e6997b27782 (diff)
rcu: Simplify association of quiescent states with grace periods
The rdp->passed_quiesc_completed fields are used to properly associate the recorded quiescent state with a grace period. It is OK to wrongly associate a given quiescent state with a preceding grace period, but it is fatal to associate a given quiescent state with a grace period that begins after the quiescent state occurred. Grace periods are numbered, and the following fields track them: o ->gpnum is the number of the grace period currently in progress, or the number of the last grace period to complete if no grace period is currently in progress. o ->completed is the number of the last grace period to have completed. These two fields are equal if there is no grace period in progress, otherwise ->gpnum is one greater than ->completed. But the rdp->passed_quiesc_completed field compared against ->completed, and if equal, the quiescent state is presumed to count against the current grace period. The earlier code copied rdp->completed to rdp->passed_quiesc_completed, which has been made to work, but is error-prone. In contrast, copying one less than rdp->gpnum is guaranteed safe, because rdp->gpnum is not incremented until after the start of the corresponding grace period. At the end of the grace period, when ->completed has incremented, then any quiescent periods recorded previously will be discarded. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: laijs@cn.fujitsu.com Cc: dipankar@in.ibm.com Cc: mathieu.desnoyers@polymtl.ca Cc: josh@joshtriplett.org Cc: dvhltc@us.ibm.com Cc: niv@us.ibm.com Cc: peterz@infradead.org Cc: rostedt@goodmis.org Cc: Valdis.Kletnieks@vt.edu Cc: dhowells@redhat.com LKML-Reference: <12578890421011-git-send-email-> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/rcutree.c4
-rw-r--r--kernel/rcutree_plugin.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 26fc7807761d..d8024192c73b 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -100,7 +100,7 @@ void rcu_sched_qs(int cpu)
100 struct rcu_data *rdp; 100 struct rcu_data *rdp;
101 101
102 rdp = &per_cpu(rcu_sched_data, cpu); 102 rdp = &per_cpu(rcu_sched_data, cpu);
103 rdp->passed_quiesc_completed = rdp->completed; 103 rdp->passed_quiesc_completed = rdp->gpnum - 1;
104 barrier(); 104 barrier();
105 rdp->passed_quiesc = 1; 105 rdp->passed_quiesc = 1;
106 rcu_preempt_note_context_switch(cpu); 106 rcu_preempt_note_context_switch(cpu);
@@ -111,7 +111,7 @@ void rcu_bh_qs(int cpu)
111 struct rcu_data *rdp; 111 struct rcu_data *rdp;
112 112
113 rdp = &per_cpu(rcu_bh_data, cpu); 113 rdp = &per_cpu(rcu_bh_data, cpu);
114 rdp->passed_quiesc_completed = rdp->completed; 114 rdp->passed_quiesc_completed = rdp->gpnum - 1;
115 barrier(); 115 barrier();
116 rdp->passed_quiesc = 1; 116 rdp->passed_quiesc = 1;
117} 117}
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index c03edf766357..52075da70549 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -67,7 +67,7 @@ EXPORT_SYMBOL_GPL(rcu_batches_completed);
67static void rcu_preempt_qs(int cpu) 67static void rcu_preempt_qs(int cpu)
68{ 68{
69 struct rcu_data *rdp = &per_cpu(rcu_preempt_data, cpu); 69 struct rcu_data *rdp = &per_cpu(rcu_preempt_data, cpu);
70 rdp->passed_quiesc_completed = rdp->completed; 70 rdp->passed_quiesc_completed = rdp->gpnum - 1;
71 barrier(); 71 barrier();
72 rdp->passed_quiesc = 1; 72 rdp->passed_quiesc = 1;
73} 73}