From c12e16e28b4cf576840cff509caf0c06ff4dc299 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 29 Oct 2002 23:31:27 -0800 Subject: [PATCH] percpu: convert RCU Patch from Dipankar Sarma 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. --- kernel/rcupdate.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'kernel') 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 #include #include +#include #include /* 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) { -- cgit v1.2.3