summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAndrew Morton <akpm@digeo.com>2002-10-29 23:31:27 -0800
committerLinus Torvalds <torvalds@penguin.transmeta.com>2002-10-29 23:31:27 -0800
commitc12e16e28b4cf576840cff509caf0c06ff4dc299 (patch)
tree80b02d367e46a5bf4defa6b5f1946d0cdbdcf63b /kernel
parent0c83f291de08552b82d8e7975444198c43074f55 (diff)
[PATCH] percpu: convert RCU
Patch from Dipankar Sarma <dipankar@in.ibm.com> This patch convers RCU per_cpu data to use per_cpu data area and makes it safe for cpu_possible allocation by using CPU notifiers.
Diffstat (limited to 'kernel')
-rw-r--r--kernel/rcupdate.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index 1a149dff7832..91483119714c 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -41,13 +41,14 @@
#include <linux/module.h>
#include <linux/completion.h>
#include <linux/percpu.h>
+#include <linux/notifier.h>
#include <linux/rcupdate.h>
/* Definition for rcupdate control block. */
struct rcu_ctrlblk rcu_ctrlblk =
{ .mutex = SPIN_LOCK_UNLOCKED, .curbatch = 1,
.maxbatch = 1, .rcu_cpu_mask = 0 };
-struct rcu_data rcu_data[NR_CPUS] __cacheline_aligned;
+DEFINE_PER_CPU(struct rcu_data, rcu_data) = { 0L };
/* Fake initialization required by compiler */
static DEFINE_PER_CPU(struct tasklet_struct, rcu_tasklet) = {NULL};
@@ -198,6 +199,33 @@ void rcu_check_callbacks(int cpu, int user)
tasklet_schedule(&RCU_tasklet(cpu));
}
+static void __devinit rcu_online_cpu(int cpu)
+{
+ memset(&per_cpu(rcu_data, cpu), 0, sizeof(struct rcu_data));
+ tasklet_init(&RCU_tasklet(cpu), rcu_process_callbacks, 0UL);
+ INIT_LIST_HEAD(&RCU_nxtlist(cpu));
+ INIT_LIST_HEAD(&RCU_curlist(cpu));
+}
+
+static int __devinit rcu_cpu_notify(struct notifier_block *self,
+ unsigned long action, void *hcpu)
+{
+ long cpu = (long)hcpu;
+ switch (action) {
+ case CPU_UP_PREPARE:
+ rcu_online_cpu(cpu);
+ break;
+ /* Space reserved for CPU_OFFLINE :) */
+ default:
+ break;
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block __devinitdata rcu_nb = {
+ .notifier_call = rcu_cpu_notify,
+};
+
/*
* Initializes rcu mechanism. Assumed to be called early.
* That is before local timer(SMP) or jiffie timer (uniproc) is setup.
@@ -206,16 +234,13 @@ void rcu_check_callbacks(int cpu, int user)
*/
void __init rcu_init(void)
{
- int i;
-
- memset(&rcu_data[0], 0, sizeof(rcu_data));
- for (i = 0; i < NR_CPUS; i++) {
- tasklet_init(&RCU_tasklet(i), rcu_process_callbacks, 0UL);
- INIT_LIST_HEAD(&RCU_nxtlist(i));
- INIT_LIST_HEAD(&RCU_curlist(i));
- }
+ rcu_cpu_notify(&rcu_nb, CPU_UP_PREPARE,
+ (void *)(long)smp_processor_id());
+ /* Register notifier for non-boot CPUs */
+ register_cpu_notifier(&rcu_nb);
}
+
/* Because of FASTCALL declaration of complete, we use this wrapper */
static void wakeme_after_rcu(void *completion)
{