Skip to content

Commit

Permalink
[PATCH] cpu hotplug: make [un]register_cpu_notifier init time only
Browse files Browse the repository at this point in the history
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: Chandra Seetharaman <sekharan@us.ibm.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Chandra Seetharaman authored and Linus Torvalds committed Jun 28, 2006
1 parent 054cc8a commit 65edc68
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
8 changes: 5 additions & 3 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,8 @@ int cpufreq_update_policy(unsigned int cpu)
}
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 int cpu = (unsigned long)hcpu;
Expand Down Expand Up @@ -1536,6 +1537,7 @@ static struct notifier_block cpufreq_cpu_notifier =
{
.notifier_call = cpufreq_cpu_callback,
};
#endif /* CONFIG_HOTPLUG_CPU */

/*********************************************************************
* REGISTER / UNREGISTER CPUFREQ DRIVER *
Expand Down Expand Up @@ -1596,7 +1598,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
}

if (!ret) {
register_cpu_notifier(&cpufreq_cpu_notifier);
register_hotcpu_notifier(&cpufreq_cpu_notifier);
dprintk("driver %s up and running\n", driver_data->name);
cpufreq_debug_enable_ratelimit();
}
Expand Down Expand Up @@ -1628,7 +1630,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)
dprintk("unregistering driver %s\n", driver->name);

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);
cpufreq_driver = NULL;
Expand Down
4 changes: 2 additions & 2 deletions drivers/cpufreq/cpufreq_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ __init cpufreq_stats_init(void)
return ret;
}

register_cpu_notifier(&cpufreq_stat_cpu_notifier);
register_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
lock_cpu_hotplug();
for_each_online_cpu(cpu) {
cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_ONLINE,
Expand All @@ -368,7 +368,7 @@ __exit cpufreq_stats_exit(void)
CPUFREQ_POLICY_NOTIFIER);
cpufreq_unregister_notifier(&notifier_trans_block,
CPUFREQ_TRANSITION_NOTIFIER);
unregister_cpu_notifier(&cpufreq_stat_cpu_notifier);
unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
lock_cpu_hotplug();
for_each_online_cpu(cpu) {
cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_DEAD,
Expand Down
6 changes: 6 additions & 0 deletions include/linux/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ struct notifier_block;
#ifdef CONFIG_SMP
/* Need to know about CPUs going up/down? */
extern int register_cpu_notifier(struct notifier_block *nb);
#ifdef CONFIG_HOTPLUG_CPU
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);

int cpu_up(unsigned int cpu);
Expand Down
8 changes: 5 additions & 3 deletions kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/* This protects CPUs going up and down... */
static DEFINE_MUTEX(cpucontrol);

static BLOCKING_NOTIFIER_HEAD(cpu_chain);
static __cpuinitdata BLOCKING_NOTIFIER_HEAD(cpu_chain);

#ifdef CONFIG_HOTPLUG_CPU
static struct task_struct *lock_cpu_hotplug_owner;
Expand Down Expand Up @@ -69,10 +69,13 @@ EXPORT_SYMBOL_GPL(lock_cpu_hotplug_interruptible);
#endif /* CONFIG_HOTPLUG_CPU */

/* 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);
}

#ifdef CONFIG_HOTPLUG_CPU

EXPORT_SYMBOL(register_cpu_notifier);

void unregister_cpu_notifier(struct notifier_block *nb)
Expand All @@ -81,7 +84,6 @@ void unregister_cpu_notifier(struct notifier_block *nb)
}
EXPORT_SYMBOL(unregister_cpu_notifier);

#ifdef CONFIG_HOTPLUG_CPU
static inline void check_for_tasks(int cpu)
{
struct task_struct *p;
Expand Down

0 comments on commit 65edc68

Please sign in to comment.