From: "Srivatsa S. Bhat" <srivatsa.bhat@linux•vnet.ibm.com>
To: Ingo Molnar <mingo@elte•hu>
Cc: Andi Kleen <ak@linux•intel.com>, Nick Piggin <npiggin@kernel•dk>,
"Paul E. McKenney" <paulmck@linux•vnet.ibm.com>,
Rusty Russell <rusty@rustcorp•com.au>,
linux-kernel <linux-kernel@vger•kernel.org>,
"Rafael J. Wysocki" <rjw@sisk•pl>,
Paul Gortmaker <paul.gortmaker@windriver•com>,
Alexander Viro <viro@zeniv•linux.org.uk>,
KOSAKI Motohiro <kosaki.motohiro@jp•fujitsu.com>,
sparclinux@vger•kernel.org, linux-fsdevel@vger•kernel.org,
Andrew Morton <akpm@linux-foundation•org>,
Arjan van de Ven <arjan.van.de.ven@intel•com>,
ppc-dev <linuxppc-dev@lists•ozlabs.org>,
"David S. Miller" <davem@davemloft•net>,
Peter Zijlstra <a.p.zijlstra@chello•nl>
Subject: [PATCH 2/3] CPU hotplug, arch/powerpc: Fix CPU hotplug callback registration
Date: Thu, 01 Mar 2012 13:46:58 +0530 [thread overview]
Message-ID: <4F4F307A.7040105@linux.vnet.ibm.com> (raw)
In-Reply-To: <4F4F2F7F.5040207@linux.vnet.ibm.com>
Restructure CPU hotplug setup and callback registration in topology_init
so as to be race-free.
---
arch/powerpc/kernel/sysfs.c | 44 +++++++++++++++++++++++++++++++++++--------
arch/powerpc/mm/numa.c | 11 ++++++++---
2 files changed, 44 insertions(+), 11 deletions(-)
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 883e74c..5838b33 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -496,6 +496,38 @@ ssize_t arch_cpu_release(const char *buf, size_t count)
#endif /* CONFIG_HOTPLUG_CPU */
+static void cpu_register_helper(struct cpu *c, int cpu)
+{
+ register_cpu(c, cpu);
+ device_create_file(&c->dev, &dev_attr_physical_id);
+}
+
+static int __cpuinit sysfs_cpu_notify_first_time(struct notifier_block *self,
+ unsigned long action, void *hcpu)
+{
+ unsigned int cpu = (unsigned int)(long)hcpu;
+ struct cpu *c = &per_cpu(cpu_devices, cpu);
+
+ if (action == CPU_ONLINE)
+ if (!c->hotpluggable) /* Avoid duplicate registrations */
+ cpu_register_helper(c, cpu);
+ register_cpu_online(cpu);
+ }
+ return NOTIFY_OK;
+}
+static int __cpuinit sysfs_cpu_notify_setup(void)
+{
+ int cpu;
+
+ /*
+ * We don't race with CPU hotplug because we are called from
+ * the CPU hotplug callback registration function.
+ */
+ for_each_online_cpu(cpu)
+ sysfs_cpu_notify_first_time(NULL, CPU_ONLINE, cpu);
+
+ return 0;
+}
static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
unsigned long action, void *hcpu)
{
@@ -637,7 +669,6 @@ static int __init topology_init(void)
int cpu;
register_nodes();
- register_cpu_notifier(&sysfs_cpu_nb);
for_each_possible_cpu(cpu) {
struct cpu *c = &per_cpu(cpu_devices, cpu);
@@ -652,15 +683,12 @@ static int __init topology_init(void)
if (ppc_md.cpu_die)
c->hotpluggable = 1;
- if (cpu_online(cpu) || c->hotpluggable) {
- register_cpu(c, cpu);
+ if (c->hotpluggable)
+ cpu_register_helper(c, cpu);
+ }
- device_create_file(&c->dev, &dev_attr_physical_id);
- }
+ register_allcpu_notifier(&sysfs_cpu_nb, true, &sysfs_cpu_notify_setup);
- if (cpu_online(cpu))
- register_cpu_online(cpu);
- }
#ifdef CONFIG_PPC64
sysfs_create_dscr_default();
#endif /* CONFIG_PPC64 */
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 3feefc3..e326455 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1014,6 +1014,13 @@ static void __init mark_reserved_regions_for_nid(int nid)
}
}
+static int __cpuinit cpu_numa_callback_setup(void)
+{
+ cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE,
+ (void *)(unsigned long)boot_cpuid);
+ return 0;
+}
+
void __init do_init_bootmem(void)
{
@@ -1088,9 +1095,7 @@ void __init do_init_bootmem(void)
*/
setup_node_to_cpumask_map();
- register_cpu_notifier(&ppc64_numa_nb);
- cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE,
- (void *)(unsigned long)boot_cpuid);
+ register_allcpu_notifier(&ppc64_numa_nb, true, &cpu_numa_callback_setup);
}
void __init paging_init(void)
next prev parent reply other threads:[~2012-03-01 8:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87ehtf3lqh.fsf@rustcorp.com.au>
[not found] ` <20120227155338.7b5110cd.akpm@linux-foundation.org>
[not found] ` <20120228084359.GJ21106@elte.hu>
[not found] ` <20120228132719.f375071a.akpm@linux-foundation.org>
[not found] ` <4F4DBB26.2060907@linux.vnet.ibm.com>
[not found] ` <20120229091732.GA11505@elte.hu>
[not found] ` <4F4E083A.2080304@linux.vnet.ibm.com>
2012-03-01 8:12 ` [PATCH] cpumask: fix lg_lock/br_lock Srivatsa S. Bhat
2012-03-01 8:15 ` [PATCH 1/3] CPU hotplug: Fix issues with callback registration Srivatsa S. Bhat
2012-03-01 8:16 ` Srivatsa S. Bhat [this message]
2012-03-01 8:18 ` [PATCH 3/3] CPU hotplug, arch/sparc: Fix CPU hotplug " Srivatsa S. Bhat
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=4F4F307A.7040105@linux.vnet.ibm.com \
--to=srivatsa.bhat@linux$(echo .)vnet.ibm.com \
--cc=a.p.zijlstra@chello$(echo .)nl \
--cc=ak@linux$(echo .)intel.com \
--cc=akpm@linux-foundation$(echo .)org \
--cc=arjan.van.de.ven@intel$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=kosaki.motohiro@jp$(echo .)fujitsu.com \
--cc=linux-fsdevel@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=mingo@elte$(echo .)hu \
--cc=npiggin@kernel$(echo .)dk \
--cc=paul.gortmaker@windriver$(echo .)com \
--cc=paulmck@linux$(echo .)vnet.ibm.com \
--cc=rjw@sisk$(echo .)pl \
--cc=rusty@rustcorp$(echo .)com.au \
--cc=sparclinux@vger$(echo .)kernel.org \
--cc=viro@zeniv$(echo .)linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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