Commit 65edc68c authored by Chandra Seetharaman's avatar Chandra Seetharaman Committed by Linus Torvalds

[PATCH] cpu hotplug: make [un]register_cpu_notifier init time only

CPUs come online only at init time (unless CONFIG_HOTPLUG_CPU is defined).
So, cpu_notifier functionality need to be available only at init time.

This patch makes register_cpu_notifier() available only at init time, unless
CONFIG_HOTPLUG_CPU is defined.

This patch exports register_cpu_notifier() and unregister_cpu_notifier() only
if CONFIG_HOTPLUG_CPU is defined.
Signed-off-by: default avatarChandra Seetharaman <sekharan@us.ibm.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 054cc8a2
...@@ -1497,7 +1497,8 @@ int cpufreq_update_policy(unsigned int cpu) ...@@ -1497,7 +1497,8 @@ int cpufreq_update_policy(unsigned int cpu)
} }
EXPORT_SYMBOL(cpufreq_update_policy); EXPORT_SYMBOL(cpufreq_update_policy);
static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb, #ifdef CONFIG_HOTPLUG_CPU
static int cpufreq_cpu_callback(struct notifier_block *nfb,
unsigned long action, void *hcpu) unsigned long action, void *hcpu)
{ {
unsigned int cpu = (unsigned long)hcpu; unsigned int cpu = (unsigned long)hcpu;
...@@ -1536,6 +1537,7 @@ static struct notifier_block cpufreq_cpu_notifier = ...@@ -1536,6 +1537,7 @@ static struct notifier_block cpufreq_cpu_notifier =
{ {
.notifier_call = cpufreq_cpu_callback, .notifier_call = cpufreq_cpu_callback,
}; };
#endif /* CONFIG_HOTPLUG_CPU */
/********************************************************************* /*********************************************************************
* REGISTER / UNREGISTER CPUFREQ DRIVER * * REGISTER / UNREGISTER CPUFREQ DRIVER *
...@@ -1596,7 +1598,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) ...@@ -1596,7 +1598,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
} }
if (!ret) { if (!ret) {
register_cpu_notifier(&cpufreq_cpu_notifier); register_hotcpu_notifier(&cpufreq_cpu_notifier);
dprintk("driver %s up and running\n", driver_data->name); dprintk("driver %s up and running\n", driver_data->name);
cpufreq_debug_enable_ratelimit(); cpufreq_debug_enable_ratelimit();
} }
...@@ -1628,7 +1630,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) ...@@ -1628,7 +1630,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)
dprintk("unregistering driver %s\n", driver->name); dprintk("unregistering driver %s\n", driver->name);
sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver); sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver);
unregister_cpu_notifier(&cpufreq_cpu_notifier); unregister_hotcpu_notifier(&cpufreq_cpu_notifier);
spin_lock_irqsave(&cpufreq_driver_lock, flags); spin_lock_irqsave(&cpufreq_driver_lock, flags);
cpufreq_driver = NULL; cpufreq_driver = NULL;
......
...@@ -350,7 +350,7 @@ __init cpufreq_stats_init(void) ...@@ -350,7 +350,7 @@ __init cpufreq_stats_init(void)
return ret; return ret;
} }
register_cpu_notifier(&cpufreq_stat_cpu_notifier); register_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
lock_cpu_hotplug(); lock_cpu_hotplug();
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_ONLINE, cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_ONLINE,
...@@ -368,7 +368,7 @@ __exit cpufreq_stats_exit(void) ...@@ -368,7 +368,7 @@ __exit cpufreq_stats_exit(void)
CPUFREQ_POLICY_NOTIFIER); CPUFREQ_POLICY_NOTIFIER);
cpufreq_unregister_notifier(&notifier_trans_block, cpufreq_unregister_notifier(&notifier_trans_block,
CPUFREQ_TRANSITION_NOTIFIER); CPUFREQ_TRANSITION_NOTIFIER);
unregister_cpu_notifier(&cpufreq_stat_cpu_notifier); unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
lock_cpu_hotplug(); lock_cpu_hotplug();
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_DEAD, cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_DEAD,
......
...@@ -41,7 +41,13 @@ struct notifier_block; ...@@ -41,7 +41,13 @@ struct notifier_block;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
/* Need to know about CPUs going up/down? */ /* Need to know about CPUs going up/down? */
extern int register_cpu_notifier(struct notifier_block *nb); extern int register_cpu_notifier(struct notifier_block *nb);
#ifdef CONFIG_HOTPLUG_CPU
extern void unregister_cpu_notifier(struct notifier_block *nb); extern void unregister_cpu_notifier(struct notifier_block *nb);
#else
static inline void unregister_cpu_notifier(struct notifier_block *nb)
{
}
#endif
extern int current_in_cpu_hotplug(void); extern int current_in_cpu_hotplug(void);
int cpu_up(unsigned int cpu); int cpu_up(unsigned int cpu);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
/* This protects CPUs going up and down... */ /* This protects CPUs going up and down... */
static DEFINE_MUTEX(cpucontrol); static DEFINE_MUTEX(cpucontrol);
static BLOCKING_NOTIFIER_HEAD(cpu_chain); static __cpuinitdata BLOCKING_NOTIFIER_HEAD(cpu_chain);
#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_HOTPLUG_CPU
static struct task_struct *lock_cpu_hotplug_owner; static struct task_struct *lock_cpu_hotplug_owner;
...@@ -69,10 +69,13 @@ EXPORT_SYMBOL_GPL(lock_cpu_hotplug_interruptible); ...@@ -69,10 +69,13 @@ EXPORT_SYMBOL_GPL(lock_cpu_hotplug_interruptible);
#endif /* CONFIG_HOTPLUG_CPU */ #endif /* CONFIG_HOTPLUG_CPU */
/* Need to know about CPUs going up/down? */ /* Need to know about CPUs going up/down? */
int register_cpu_notifier(struct notifier_block *nb) int __cpuinit register_cpu_notifier(struct notifier_block *nb)
{ {
return blocking_notifier_chain_register(&cpu_chain, nb); return blocking_notifier_chain_register(&cpu_chain, nb);
} }
#ifdef CONFIG_HOTPLUG_CPU
EXPORT_SYMBOL(register_cpu_notifier); EXPORT_SYMBOL(register_cpu_notifier);
void unregister_cpu_notifier(struct notifier_block *nb) void unregister_cpu_notifier(struct notifier_block *nb)
...@@ -81,7 +84,6 @@ void unregister_cpu_notifier(struct notifier_block *nb) ...@@ -81,7 +84,6 @@ void unregister_cpu_notifier(struct notifier_block *nb)
} }
EXPORT_SYMBOL(unregister_cpu_notifier); EXPORT_SYMBOL(unregister_cpu_notifier);
#ifdef CONFIG_HOTPLUG_CPU
static inline void check_for_tasks(int cpu) static inline void check_for_tasks(int cpu)
{ {
struct task_struct *p; struct task_struct *p;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment