Commit d2cec97b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] cpumask: make cpu_present_map real even on non-smp

From: Paul Jackson <pj@sgi.com>

This patch makes cpu_present_map a real map for all configurations, instead of
a constant for non-SMP.  It also moves the definition of cpu_present_map out
of kernel/cpu.c into kernel/sched.c, because cpu.c isn't compiled into non-SMP
kernels.

The pattern is that each of the possible, present and online cpu maps are
actual kernel global cpumask_t variables, for all configurations.  They are
documented in include/linux/cpumask.h.  Some of the UP (NR_CPUS=1) code
cheats, and hardcodes the assumption that the single bit position of these
maps is always set, as an optimization.
Signed-off-by: default avatarPaul Jackson <pj@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8c1ce9d6
...@@ -10,15 +10,12 @@ ...@@ -10,15 +10,12 @@
extern cpumask_t cpu_online_map; extern cpumask_t cpu_online_map;
extern cpumask_t cpu_possible_map; extern cpumask_t cpu_possible_map;
extern cpumask_t cpu_present_map;
#define num_online_cpus() cpus_weight(cpu_online_map) #define num_online_cpus() cpus_weight(cpu_online_map)
#define num_possible_cpus() cpus_weight(cpu_possible_map) #define num_possible_cpus() cpus_weight(cpu_possible_map)
#define num_present_cpus() cpus_weight(cpu_present_map)
#define cpu_online(cpu) cpu_isset(cpu, cpu_online_map) #define cpu_online(cpu) cpu_isset(cpu, cpu_online_map)
#define cpu_possible(cpu) cpu_isset(cpu, cpu_possible_map) #define cpu_possible(cpu) cpu_isset(cpu, cpu_possible_map)
#define cpu_present(cpu) cpu_isset(cpu, cpu_present_map)
#define for_each_cpu_mask(cpu, mask) \ #define for_each_cpu_mask(cpu, mask) \
for (cpu = first_cpu_const(mk_cpumask_const(mask)); \ for (cpu = first_cpu_const(mk_cpumask_const(mask)); \
...@@ -27,26 +24,26 @@ extern cpumask_t cpu_present_map; ...@@ -27,26 +24,26 @@ extern cpumask_t cpu_present_map;
#define for_each_cpu(cpu) for_each_cpu_mask(cpu, cpu_possible_map) #define for_each_cpu(cpu) for_each_cpu_mask(cpu, cpu_possible_map)
#define for_each_online_cpu(cpu) for_each_cpu_mask(cpu, cpu_online_map) #define for_each_online_cpu(cpu) for_each_cpu_mask(cpu, cpu_online_map)
#define for_each_present_cpu(cpu) for_each_cpu_mask(cpu, cpu_present_map)
#else #else
#define cpu_online_map cpumask_of_cpu(0) #define cpu_online_map cpumask_of_cpu(0)
#define cpu_possible_map cpumask_of_cpu(0) #define cpu_possible_map cpumask_of_cpu(0)
#define cpu_present_map cpumask_of_cpu(0)
#define num_online_cpus() 1 #define num_online_cpus() 1
#define num_possible_cpus() 1 #define num_possible_cpus() 1
#define num_present_cpus() 1
#define cpu_online(cpu) ({ BUG_ON((cpu) != 0); 1; }) #define cpu_online(cpu) ({ BUG_ON((cpu) != 0); 1; })
#define cpu_possible(cpu) ({ BUG_ON((cpu) != 0); 1; }) #define cpu_possible(cpu) ({ BUG_ON((cpu) != 0); 1; })
#define cpu_present(cpu) ({ BUG_ON((cpu) != 0); 1; })
#define for_each_cpu_mask(cpu, mask) for (cpu = 0; cpu < 1; cpu++) #define for_each_cpu_mask(cpu, mask) for (cpu = 0; cpu < 1; cpu++)
#define for_each_cpu(cpu) for (cpu = 0; cpu < 1; cpu++) #define for_each_cpu(cpu) for (cpu = 0; cpu < 1; cpu++)
#define for_each_online_cpu(cpu) for (cpu = 0; cpu < 1; cpu++) #define for_each_online_cpu(cpu) for (cpu = 0; cpu < 1; cpu++)
#define for_each_present_cpu(cpu) for (cpu = 0; cpu < 1; cpu++)
#endif #endif
extern cpumask_t cpu_present_map;
#define num_present_cpus() cpus_weight(cpu_present_map)
#define cpu_present(cpu) cpu_isset(cpu, cpu_present_map)
#define for_each_present_cpu(cpu) for_each_cpu_mask(cpu, cpu_present_map)
#define cpumask_scnprintf(buf, buflen, map) \ #define cpumask_scnprintf(buf, buflen, map) \
bitmap_scnprintf(buf, buflen, cpus_addr(map), NR_CPUS) bitmap_scnprintf(buf, buflen, cpus_addr(map), NR_CPUS)
......
...@@ -20,14 +20,6 @@ ...@@ -20,14 +20,6 @@
DECLARE_MUTEX(cpucontrol); DECLARE_MUTEX(cpucontrol);
static struct notifier_block *cpu_chain; static struct notifier_block *cpu_chain;
/*
* Represents all cpu's present in the system
* In systems capable of hotplug, this map could dynamically grow
* as new cpu's are detected in the system via any platform specific
* method, such as ACPI for e.g.
*/
cpumask_t cpu_present_map;
EXPORT_SYMBOL(cpu_present_map);
/* 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 register_cpu_notifier(struct notifier_block *nb)
......
...@@ -2941,6 +2941,16 @@ asmlinkage long sys_sched_setaffinity(pid_t pid, unsigned int len, ...@@ -2941,6 +2941,16 @@ asmlinkage long sys_sched_setaffinity(pid_t pid, unsigned int len,
return retval; return retval;
} }
/*
* Represents all cpu's present in the system
* In systems capable of hotplug, this map could dynamically grow
* as new cpu's are detected in the system via any platform specific
* method, such as ACPI for e.g.
*/
cpumask_t cpu_present_map;
EXPORT_SYMBOL(cpu_present_map);
/** /**
* sys_sched_getaffinity - get the cpu affinity of a process * sys_sched_getaffinity - get the cpu affinity of a process
* @pid: pid of the process * @pid: pid of the process
......
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