From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@elte.hu, laijs@cn.fujitsu.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca,
josh@joshtriplett.org, dvhltc@us.ibm.com, niv@us.ibm.com,
tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org,
Valdis.Kletnieks@vt.edu, dhowells@redhat.com,
eric.dumazet@gmail.com,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH RFC tip/core/rcu 26/30] rcu: simplify the usage of percpu data
Date: Wed, 14 Jul 2010 13:10:00 -0700 [thread overview]
Message-ID: <1279138204-12849-26-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <20100714200945.GA10535@linux.vnet.ibm.com>
From: Lai Jiangshan <laijs@cn.fujitsu.com>
&percpu_data is compatible with allocated percpu data.
And we use it and remove the "->rda[NR_CPUS]" array, saving significant
storage on systems with large numbers of CPUs. This does add an additional
level of indirection and thus an additional cache line referenced, but
because ->rda is not used on the read side, this is OK.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
kernel/rcutree.c | 42 +++++++++++++++---------------------------
kernel/rcutree.h | 2 +-
kernel/rcutree_plugin.h | 4 ++--
3 files changed, 18 insertions(+), 30 deletions(-)
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index d5bc439..5b1c3c2 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -712,7 +712,7 @@ static void
rcu_start_gp(struct rcu_state *rsp, unsigned long flags)
__releases(rcu_get_root(rsp)->lock)
{
- struct rcu_data *rdp = rsp->rda[smp_processor_id()];
+ struct rcu_data *rdp = this_cpu_ptr(rsp->rda);
struct rcu_node *rnp = rcu_get_root(rsp);
if (!cpu_needs_another_gp(rsp, rdp) || rsp->fqs_active) {
@@ -960,7 +960,7 @@ rcu_check_quiescent_state(struct rcu_state *rsp, struct rcu_data *rdp)
static void rcu_send_cbs_to_orphanage(struct rcu_state *rsp)
{
int i;
- struct rcu_data *rdp = rsp->rda[smp_processor_id()];
+ struct rcu_data *rdp = this_cpu_ptr(rsp->rda);
if (rdp->nxtlist == NULL)
return; /* irqs disabled, so comparison is stable. */
@@ -984,7 +984,7 @@ static void rcu_adopt_orphan_cbs(struct rcu_state *rsp)
struct rcu_data *rdp;
raw_spin_lock_irqsave(&rsp->onofflock, flags);
- rdp = rsp->rda[smp_processor_id()];
+ rdp = this_cpu_ptr(rsp->rda);
if (rsp->orphan_cbs_list == NULL) {
raw_spin_unlock_irqrestore(&rsp->onofflock, flags);
return;
@@ -1007,7 +1007,7 @@ static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp)
unsigned long flags;
unsigned long mask;
int need_report = 0;
- struct rcu_data *rdp = rsp->rda[cpu];
+ struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
struct rcu_node *rnp;
/* Exclude any attempts to start a new grace period. */
@@ -1226,7 +1226,8 @@ static void force_qs_rnp(struct rcu_state *rsp, int (*f)(struct rcu_data *))
cpu = rnp->grplo;
bit = 1;
for (; cpu <= rnp->grphi; cpu++, bit <<= 1) {
- if ((rnp->qsmask & bit) != 0 && f(rsp->rda[cpu]))
+ if ((rnp->qsmask & bit) != 0 &&
+ f(per_cpu_ptr(rsp->rda, cpu)))
mask |= bit;
}
if (mask != 0) {
@@ -1402,7 +1403,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
* a quiescent state betweentimes.
*/
local_irq_save(flags);
- rdp = rsp->rda[smp_processor_id()];
+ rdp = this_cpu_ptr(rsp->rda);
rcu_process_gp_end(rsp, rdp);
check_for_new_grace_period(rsp, rdp);
@@ -1701,7 +1702,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
{
unsigned long flags;
int i;
- struct rcu_data *rdp = rsp->rda[cpu];
+ struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
struct rcu_node *rnp = rcu_get_root(rsp);
/* Set up local state, ensuring consistent view of global state. */
@@ -1729,7 +1730,7 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptable)
{
unsigned long flags;
unsigned long mask;
- struct rcu_data *rdp = rsp->rda[cpu];
+ struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
struct rcu_node *rnp = rcu_get_root(rsp);
/* Set up local state, ensuring consistent view of global state. */
@@ -1865,7 +1866,8 @@ static void __init rcu_init_levelspread(struct rcu_state *rsp)
/*
* Helper function for rcu_init() that initializes one rcu_state structure.
*/
-static void __init rcu_init_one(struct rcu_state *rsp)
+static void __init rcu_init_one(struct rcu_state *rsp,
+ struct rcu_data __percpu *rda)
{
static char *buf[] = { "rcu_node_level_0",
"rcu_node_level_1",
@@ -1918,37 +1920,23 @@ static void __init rcu_init_one(struct rcu_state *rsp)
}
}
+ rsp->rda = rda;
rnp = rsp->level[NUM_RCU_LVLS - 1];
for_each_possible_cpu(i) {
while (i > rnp->grphi)
rnp++;
- rsp->rda[i]->mynode = rnp;
+ per_cpu_ptr(rsp->rda, i)->mynode = rnp;
rcu_boot_init_percpu_data(i, rsp);
}
}
-/*
- * Helper macro for __rcu_init() and __rcu_init_preempt(). To be used
- * nowhere else! Assigns leaf node pointers into each CPU's rcu_data
- * structure.
- */
-#define RCU_INIT_FLAVOR(rsp, rcu_data) \
-do { \
- int i; \
- \
- for_each_possible_cpu(i) { \
- (rsp)->rda[i] = &per_cpu(rcu_data, i); \
- } \
- rcu_init_one(rsp); \
-} while (0)
-
void __init rcu_init(void)
{
int cpu;
rcu_bootup_announce();
- RCU_INIT_FLAVOR(&rcu_sched_state, rcu_sched_data);
- RCU_INIT_FLAVOR(&rcu_bh_state, rcu_bh_data);
+ rcu_init_one(&rcu_sched_state, &rcu_sched_data);
+ rcu_init_one(&rcu_bh_state, &rcu_bh_data);
__rcu_init_preempt();
open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
diff --git a/kernel/rcutree.h b/kernel/rcutree.h
index 5d68e17..183ebf4 100644
--- a/kernel/rcutree.h
+++ b/kernel/rcutree.h
@@ -284,7 +284,7 @@ struct rcu_state {
struct rcu_node *level[NUM_RCU_LVLS]; /* Hierarchy levels. */
u32 levelcnt[MAX_RCU_LVLS + 1]; /* # nodes in each level. */
u8 levelspread[NUM_RCU_LVLS]; /* kids/node in each level. */
- struct rcu_data *rda[NR_CPUS]; /* array of rdp pointers. */
+ struct rcu_data __percpu *rda; /* pointer of percu rcu_data. */
/* The following fields are guarded by the root rcu_node's lock. */
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index 0e4f420..9906f85 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -154,7 +154,7 @@ static void rcu_preempt_note_context_switch(int cpu)
(t->rcu_read_unlock_special & RCU_READ_UNLOCK_BLOCKED) == 0) {
/* Possibly blocking in an RCU read-side critical section. */
- rdp = rcu_preempt_state.rda[cpu];
+ rdp = per_cpu_ptr(rcu_preempt_state.rda, cpu);
rnp = rdp->mynode;
raw_spin_lock_irqsave(&rnp->lock, flags);
t->rcu_read_unlock_special |= RCU_READ_UNLOCK_BLOCKED;
@@ -771,7 +771,7 @@ static void rcu_preempt_send_cbs_to_orphanage(void)
*/
static void __init __rcu_init_preempt(void)
{
- RCU_INIT_FLAVOR(&rcu_preempt_state, rcu_preempt_data);
+ rcu_init_one(&rcu_preempt_state, &rcu_preempt_data);
}
/*
--
1.7.0.6
next prev parent reply other threads:[~2010-07-14 20:12 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-14 20:09 [PATCH RFC tip/core/rcu 0/30] RCU commits queued for 2.6.36/7 Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 01/30] net: convert to rcu_dereference_index_check() Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 02/30] rcu: define __rcu address space modifier for sparse Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 03/30] rculist: avoid __rcu annotations Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 04/30] cgroups: " Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 05/30] credentials: rcu annotation Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 06/30] keys: __rcu annotations Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 07/30] nfs: " Paul E. McKenney
2010-07-14 22:07 ` Trond Myklebust
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 08/30] net: __rcu annotations for drivers Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 09/30] perf_event: __rcu annotations Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 10/30] notifiers: " Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 11/30] radix-tree: " Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 12/30] idr: " Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 13/30] input: " Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 14/30] net/netfilter: " Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 15/30] kvm: add " Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 16/30] kernel: " Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 17/30] net: " Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 18/30] kvm: more " Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 19/30] vhost: add " Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 20/30] Update documentation to note the passage of INIT_RCU_HEAD() Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 21/30] Update call_rcu() usage, add synchronize_rcu() Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 22/30] rcu: make CPU stall warning timeout configurable Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 23/30] rcu head remove init Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 24/30] rcu: add shiny new debug assists to Documentation/RCU/checklist.txt Paul E. McKenney
2010-07-14 20:09 ` [PATCH RFC tip/core/rcu 25/30] rcutorture: add random preemption Paul E. McKenney
2010-07-14 20:10 ` Paul E. McKenney [this message]
2010-07-14 20:10 ` [PATCH RFC tip/core/rcu 27/30] rcu: apply ->rda changes to rcutree_trace.c Paul E. McKenney
2010-07-14 21:12 ` Josh Triplett
2010-07-14 21:16 ` Paul E. McKenney
2010-07-14 20:10 ` [PATCH RFC tip/core/rcu 28/30] rcu: rename __do_rcu_dereference_check() to rcu_lockdep_assert() Paul E. McKenney
2010-07-14 20:10 ` [PATCH RFC tip/core/rcu 29/30] rcu: add boot parameter to suppress RCU CPU stall warning messages Paul E. McKenney
2010-07-14 21:16 ` Josh Triplett
2010-07-14 23:30 ` Paul E. McKenney
2010-07-14 20:10 ` [PATCH RFC tip/core/rcu 30/30] rcu: improve kerneldoc for rcu_read_lock(), call_rcu(), and synchronize_rcu() Paul E. McKenney
2010-07-14 21:19 ` [PATCH RFC tip/core/rcu 0/30] RCU commits queued for 2.6.36/7 Josh Triplett
2010-07-14 23:27 ` Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1279138204-12849-26-git-send-email-paulmck@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=Valdis.Kletnieks@vt.edu \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=dvhltc@us.ibm.com \
--cc=eric.dumazet@gmail.com \
--cc=josh@joshtriplett.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=niv@us.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).