Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e7d8842

Browse files
paulmckIngo Molnar
authored andcommittedSep 19, 2009
rcu: Apply results of code inspection of kernel/rcutree_plugin.h
o Drop the calls to cpu_quiet() from the online/offline code. These are unnecessary, since force_quiescent_state() will clean up, and removing them simplifies the code a bit. o Add a warning to check that we don't enqueue the same blocked task twice onto the ->blocked_tasks[] lists. o Rework the phase computation in rcu_preempt_note_context_switch() to be more readable, as suggested by Josh Triplett. o Disable irqs to close a race between the scheduling clock interrupt and rcu_preempt_note_context_switch() WRT the ->rcu_read_unlock_special field. o Add comments to rnp->lock acquisition and release within rcu_read_unlock_special() noting that irqs are already disabled. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: laijs@cn.fujitsu.com Cc: dipankar@in.ibm.com Cc: akpm@linux-foundation.org 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 LKML-Reference: <12532926201851-git-send-email-> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 28ecd58 commit e7d8842

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed
 

‎kernel/rcutree.c

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -767,10 +767,10 @@ cpu_quiet_msk(unsigned long mask, struct rcu_state *rsp, struct rcu_node *rnp,
767767

768768
/*
769769
* Record a quiescent state for the specified CPU, which must either be
770-
* the current CPU or an offline CPU. The lastcomp argument is used to
771-
* make sure we are still in the grace period of interest. We don't want
772-
* to end the current grace period based on quiescent states detected in
773-
* an earlier grace period!
770+
* the current CPU. The lastcomp argument is used to make sure we are
771+
* still in the grace period of interest. We don't want to end the current
772+
* grace period based on quiescent states detected in an earlier grace
773+
* period!
774774
*/
775775
static void
776776
cpu_quiet(int cpu, struct rcu_state *rsp, struct rcu_data *rdp, long lastcomp)
@@ -805,7 +805,6 @@ cpu_quiet(int cpu, struct rcu_state *rsp, struct rcu_data *rdp, long lastcomp)
805805
* This GP can't end until cpu checks in, so all of our
806806
* callbacks can be processed during the next GP.
807807
*/
808-
rdp = rsp->rda[smp_processor_id()];
809808
rdp->nxttail[RCU_NEXT_READY_TAIL] = rdp->nxttail[RCU_NEXT_TAIL];
810809

811810
cpu_quiet_msk(mask, rsp, rnp, flags); /* releases rnp->lock */
@@ -881,9 +880,6 @@ static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp)
881880

882881
spin_unlock(&rsp->onofflock); /* irqs remain disabled. */
883882

884-
/* Being offline is a quiescent state, so go record it. */
885-
cpu_quiet(cpu, rsp, rdp, lastcomp);
886-
887883
/*
888884
* Move callbacks from the outgoing CPU to the running CPU.
889885
* Note that the outgoing CPU is now quiscent, so it is now
@@ -1448,20 +1444,7 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptable)
14481444
rnp = rnp->parent;
14491445
} while (rnp != NULL && !(rnp->qsmaskinit & mask));
14501446

1451-
spin_unlock(&rsp->onofflock); /* irqs remain disabled. */
1452-
1453-
/*
1454-
* A new grace period might start here. If so, we will be part of
1455-
* it, and its gpnum will be greater than ours, so we will
1456-
* participate. It is also possible for the gpnum to have been
1457-
* incremented before this function was called, and the bitmasks
1458-
* to not be filled out until now, in which case we will also
1459-
* participate due to our gpnum being behind.
1460-
*/
1461-
1462-
/* Since it is coming online, the CPU is in a quiescent state. */
1463-
cpu_quiet(cpu, rsp, rdp, lastcomp);
1464-
local_irq_restore(flags);
1447+
spin_unlock_irqrestore(&rsp->onofflock, flags);
14651448
}
14661449

14671450
static void __cpuinit rcu_online_cpu(int cpu)

‎kernel/rcutree_plugin.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ static void rcu_preempt_note_context_switch(int cpu)
117117
* on line!
118118
*/
119119
WARN_ON_ONCE((rdp->grpmask & rnp->qsmaskinit) == 0);
120-
phase = !(rnp->qsmask & rdp->grpmask) ^ (rnp->gpnum & 0x1);
120+
WARN_ON_ONCE(!list_empty(&t->rcu_node_entry));
121+
phase = (rnp->gpnum + !(rnp->qsmask & rdp->grpmask)) & 0x1;
121122
list_add(&t->rcu_node_entry, &rnp->blocked_tasks[phase]);
122-
smp_mb(); /* Ensure later ctxt swtch seen after above. */
123123
spin_unlock_irqrestore(&rnp->lock, flags);
124124
}
125125

@@ -133,7 +133,9 @@ static void rcu_preempt_note_context_switch(int cpu)
133133
* means that we continue to block the current grace period.
134134
*/
135135
rcu_preempt_qs(cpu);
136+
local_irq_save(flags);
136137
t->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_NEED_QS;
138+
local_irq_restore(flags);
137139
}
138140

139141
/*
@@ -189,10 +191,10 @@ static void rcu_read_unlock_special(struct task_struct *t)
189191
*/
190192
for (;;) {
191193
rnp = t->rcu_blocked_node;
192-
spin_lock(&rnp->lock);
194+
spin_lock(&rnp->lock); /* irqs already disabled. */
193195
if (rnp == t->rcu_blocked_node)
194196
break;
195-
spin_unlock(&rnp->lock);
197+
spin_unlock(&rnp->lock); /* irqs remain disabled. */
196198
}
197199
empty = list_empty(&rnp->blocked_tasks[rnp->gpnum & 0x1]);
198200
list_del_init(&t->rcu_node_entry);

0 commit comments

Comments
 (0)
Failed to load comments.