aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/cpu.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2011-10-21 09:17:42 +0200
committerJan Beulich <jbeulich@suse.com>2011-10-21 09:17:42 +0200
commit20307695e5c22a58b4cce35fba5333375da5a7fa (patch)
tree65584141fd42e108c6feca25eec190526cb01eac /xen/common/cpu.c
parenta8a8a52a27513b35d1c6aa2d542074f99849ac3d (diff)
downloadxen-20307695e5c22a58b4cce35fba5333375da5a7fa.tar.gz
xen-20307695e5c22a58b4cce35fba5333375da5a7fa.tar.bz2
xen-20307695e5c22a58b4cce35fba5333375da5a7fa.zip
introduce and use nr_cpu_ids and nr_cpumask_bits
The former is the runtime equivalent of NR_CPUS (and users of NR_CPUS, where necessary, get adjusted accordingly), while the latter is for the sole use of determining the allocation size when dynamically allocating CPU masks (done later in this series). Adjust accessors to use either of the two to bound their bitmap operations - which one gets used depends on whether accessing the bits in the gap between nr_cpu_ids and nr_cpumask_bits is benign but more efficient. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/common/cpu.c')
-rw-r--r--xen/common/cpu.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/xen/common/cpu.c b/xen/common/cpu.c
index 396eb58ad8..c80d923bec 100644
--- a/xen/common/cpu.c
+++ b/xen/common/cpu.c
@@ -6,6 +6,12 @@
#include <xen/sched.h>
#include <xen/stop_machine.h>
+unsigned int __read_mostly nr_cpu_ids = NR_CPUS;
+#ifndef nr_cpumask_bits
+unsigned int __read_mostly nr_cpumask_bits
+ = BITS_TO_LONGS(NR_CPUS) * BITS_PER_LONG;
+#endif
+
/*
* cpu_bit_bitmap[] is a special, "compressed" data structure that
* represents all NR_CPUS bits binary values of 1<<nr.
@@ -80,7 +86,7 @@ int cpu_down(unsigned int cpu)
if ( !cpu_hotplug_begin() )
return -EBUSY;
- if ( (cpu >= NR_CPUS) || (cpu == 0) || !cpu_online(cpu) )
+ if ( (cpu >= nr_cpu_ids) || (cpu == 0) || !cpu_online(cpu) )
{
cpu_hotplug_done();
return -EINVAL;
@@ -122,7 +128,7 @@ int cpu_up(unsigned int cpu)
if ( !cpu_hotplug_begin() )
return -EBUSY;
- if ( (cpu >= NR_CPUS) || cpu_online(cpu) || !cpu_present(cpu) )
+ if ( (cpu >= nr_cpu_ids) || cpu_online(cpu) || !cpu_present(cpu) )
{
cpu_hotplug_done();
return -EINVAL;