Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2004-03-08 06:06:03 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-03-08 06:06:03 -0800
commita59d2e4e6977e7b94e003c96a41f07e96cddc340 (patch)
treeb550b7b27639edb04cd7548b58f86fa9905dce90
parent33a7ddaa6883444f328f1aac78b3612c7c9cfe0b (diff)
[PATCH] minor cleanups for hotplug CPUs
Note that without CONFIG_HOTPLUG_CPU, online cpus == possible cpus, so substitutions are a noop. - Changes show_stat to print out stats for every possible cpu, not just online CPUs. - Allocate mem in stat_open on possible, not online_cpus. - Add conventient macros to cpu.h: especially cpu_is_offline() for testing if a cpu is still online. - Add a num_possible_cpus() similar to num_online_cpus(), and define cpu_possible_mask for UP. - Allow printk on down cpus once system is running. - Mask cpumask with possible, not online cpus, for sys_getaffinity().
-rw-r--r--fs/proc/proc_misc.c4
-rw-r--r--include/linux/cpu.h13
-rw-r--r--include/linux/cpumask.h3
-rw-r--r--kernel/printk.c2
-rw-r--r--kernel/sched.c2
5 files changed, 20 insertions, 4 deletions
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index dcb20c541add..328bcd3405cc 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -389,7 +389,7 @@ int show_stat(struct seq_file *p, void *v)
jiffies_to_clock_t(iowait),
jiffies_to_clock_t(irq),
jiffies_to_clock_t(softirq));
- for_each_online_cpu(i) {
+ for_each_cpu(i) {
seq_printf(p, "cpu%d %u %u %u %u %u %u %u\n",
i,
jiffies_to_clock_t(kstat_cpu(i).cpustat.user),
@@ -424,7 +424,7 @@ int show_stat(struct seq_file *p, void *v)
static int stat_open(struct inode *inode, struct file *file)
{
- unsigned size = 4096 * (1 + num_online_cpus() / 32);
+ unsigned size = 4096 * (1 + num_possible_cpus() / 32);
char *buf;
struct seq_file *m;
int res;
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 5ecc291dc138..83a37dc0ec3f 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -21,6 +21,8 @@
#include <linux/sysdev.h>
#include <linux/node.h>
+#include <linux/compiler.h>
+#include <linux/cpumask.h>
#include <asm/semaphore.h>
struct cpu {
@@ -56,9 +58,20 @@ extern struct sysdev_class cpu_sysdev_class;
extern struct semaphore cpucontrol;
#define lock_cpu_hotplug() down(&cpucontrol)
#define unlock_cpu_hotplug() up(&cpucontrol)
+#define lock_cpu_hotplug_interruptible() down_interruptible(&cpucontrol)
+#define hotcpu_notifier(fn, pri) { \
+ static struct notifier_block fn##_nb = { fn, pri }; \
+ register_cpu_notifier(&fn##_nb); \
+}
+#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
#else
#define lock_cpu_hotplug() do { } while (0)
#define unlock_cpu_hotplug() do { } while (0)
+#define lock_cpu_hotplug_interruptible() 0
+#define hotcpu_notifier(fn, pri)
+
+/* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */
+#define cpu_is_offline(cpu) 0
#endif
#endif /* _LINUX_CPU_H_ */
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 5731bdb3c7d8..090c3f2dc6ec 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -12,6 +12,7 @@ extern cpumask_t cpu_online_map;
extern cpumask_t cpu_possible_map;
#define num_online_cpus() cpus_weight(cpu_online_map)
+#define num_possible_cpus() cpus_weight(cpu_possible_map)
#define cpu_online(cpu) cpu_isset(cpu, cpu_online_map)
#define cpu_possible(cpu) cpu_isset(cpu, cpu_possible_map)
@@ -24,7 +25,9 @@ extern cpumask_t cpu_possible_map;
#define for_each_online_cpu(cpu) for_each_cpu_mask(cpu, cpu_online_map)
#else
#define cpu_online_map cpumask_of_cpu(0)
+#define cpu_possible_map cpumask_of_cpu(0)
#define num_online_cpus() 1
+#define num_possible_cpus() 1
#define cpu_online(cpu) ({ BUG_ON((cpu) != 0); 1; })
#define cpu_possible(cpu) ({ BUG_ON((cpu) != 0); 1; })
diff --git a/kernel/printk.c b/kernel/printk.c
index 900c60f98157..a7be1f922f34 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -522,7 +522,7 @@ asmlinkage int printk(const char *fmt, ...)
log_level_unknown = 1;
}
- if (!cpu_online(smp_processor_id())) {
+ if (!cpu_online(smp_processor_id()) && !system_running) {
/*
* Some console drivers may assume that per-cpu resources have
* been allocated. So don't allow them to be called by this
diff --git a/kernel/sched.c b/kernel/sched.c
index 4f6fbe7d0b95..28cd05aba0ec 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2366,7 +2366,7 @@ asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len,
goto out_unlock;
retval = 0;
- cpus_and(mask, p->cpus_allowed, cpu_online_map);
+ cpus_and(mask, p->cpus_allowed, cpu_possible_map);
out_unlock:
read_unlock(&tasklist_lock);