2 * (C) 2001 Rusty Russell
3 * This code is licenced under the GPL.
5 #include <linux/proc_fs.h>
7 #include <linux/init.h>
8 #include <linux/notifier.h>
9 #include <linux/sched.h>
10 #include <linux/unistd.h>
11 #include <linux/cpu.h>
12 #include <asm/semaphore.h>
14 /* This protects CPUs going up and down... */
15 DECLARE_MUTEX(cpucontrol
);
17 static struct notifier_block
*cpu_chain
;
19 /* Need to know about CPUs going up/down? */
20 int register_cpu_notifier(struct notifier_block
*nb
)
22 return notifier_chain_register(&cpu_chain
, nb
);
25 void unregister_cpu_notifier(struct notifier_block
*nb
)
27 notifier_chain_unregister(&cpu_chain
,nb
);
30 int __devinit
cpu_up(unsigned int cpu
)
33 void *hcpu
= (void *)(long)cpu
;
35 if ((ret
= down_interruptible(&cpucontrol
)) != 0)
38 if (cpu_online(cpu
)) {
42 ret
= notifier_call_chain(&cpu_chain
, CPU_UP_PREPARE
, hcpu
);
43 if (ret
== NOTIFY_BAD
) {
44 printk("%s: attempt to bring up CPU %u failed\n",
50 /* Arch-specific enabling code. */
57 /* Now call notifier in preparation. */
58 printk("CPU %u IS NOW UP!\n", cpu
);
59 notifier_call_chain(&cpu_chain
, CPU_ONLINE
, hcpu
);
63 notifier_call_chain(&cpu_chain
, CPU_UP_CANCELED
, hcpu
);