Commit 9f0e8d04 authored by Mike Travis's avatar Mike Travis Committed by Ingo Molnar

x86: convert cpumask_of_cpu macro to allocated array

  * Here is a simple patch to use an allocated array of cpumasks to
    represent cpumask_of_cpu() instead of constructing one on the stack.
    It's based on the Kconfig option "HAVE_CPUMASK_OF_CPU_MAP" which is
    currently only set for x86_64 SMP.  Otherwise the the existing
    cpumask_of_cpu() is used but has been changed to produce an lvalue
    so a pointer to it can be used.

Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Signed-off-by: default avatarMike Travis <travis@sgi.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 321a8e9d
...@@ -117,6 +117,9 @@ config ARCH_HAS_CPU_RELAX ...@@ -117,6 +117,9 @@ config ARCH_HAS_CPU_RELAX
config HAVE_SETUP_PER_CPU_AREA config HAVE_SETUP_PER_CPU_AREA
def_bool X86_64 || (X86_SMP && !X86_VOYAGER) def_bool X86_64 || (X86_SMP && !X86_VOYAGER)
config HAVE_CPUMASK_OF_CPU_MAP
def_bool X86_64_SMP
config ARCH_HIBERNATION_POSSIBLE config ARCH_HIBERNATION_POSSIBLE
def_bool y def_bool y
depends on !SMP || !X86_VOYAGER depends on !SMP || !X86_VOYAGER
......
...@@ -54,6 +54,24 @@ static void __init setup_per_cpu_maps(void) ...@@ -54,6 +54,24 @@ static void __init setup_per_cpu_maps(void)
#endif #endif
} }
#ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP
cpumask_t *cpumask_of_cpu_map __read_mostly;
EXPORT_SYMBOL(cpumask_of_cpu_map);
/* requires nr_cpu_ids to be initialized */
static void __init setup_cpumask_of_cpu(void)
{
int i;
/* alloc_bootmem zeroes memory */
cpumask_of_cpu_map = alloc_bootmem_low(sizeof(cpumask_t) * nr_cpu_ids);
for (i = 0; i < nr_cpu_ids; i++)
cpu_set(i, cpumask_of_cpu_map[i]);
}
#else
static inline void setup_cpumask_of_cpu(void) { }
#endif
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
/* /*
* Great future not-so-futuristic plan: make i386 and x86_64 do it * Great future not-so-futuristic plan: make i386 and x86_64 do it
...@@ -70,7 +88,7 @@ EXPORT_SYMBOL(__per_cpu_offset); ...@@ -70,7 +88,7 @@ EXPORT_SYMBOL(__per_cpu_offset);
*/ */
void __init setup_per_cpu_areas(void) void __init setup_per_cpu_areas(void)
{ {
int i; int i, highest_cpu = 0;
unsigned long size; unsigned long size;
#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_HOTPLUG_CPU
...@@ -104,10 +122,18 @@ void __init setup_per_cpu_areas(void) ...@@ -104,10 +122,18 @@ void __init setup_per_cpu_areas(void)
__per_cpu_offset[i] = ptr - __per_cpu_start; __per_cpu_offset[i] = ptr - __per_cpu_start;
#endif #endif
memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
highest_cpu = i;
} }
nr_cpu_ids = highest_cpu + 1;
printk(KERN_DEBUG "NR_CPUS: %d, nr_cpu_ids: %d\n", NR_CPUS, nr_cpu_ids);
/* Setup percpu data maps */ /* Setup percpu data maps */
setup_per_cpu_maps(); setup_per_cpu_maps();
/* Setup cpumask_of_cpu map */
setup_cpumask_of_cpu();
} }
#endif #endif
...@@ -222,8 +222,13 @@ int __next_cpu(int n, const cpumask_t *srcp); ...@@ -222,8 +222,13 @@ int __next_cpu(int n, const cpumask_t *srcp);
#define next_cpu(n, src) ({ (void)(src); 1; }) #define next_cpu(n, src) ({ (void)(src); 1; })
#endif #endif
#ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP
extern cpumask_t *cpumask_of_cpu_map;
#define cpumask_of_cpu(cpu) (cpumask_of_cpu_map[cpu])
#else
#define cpumask_of_cpu(cpu) \ #define cpumask_of_cpu(cpu) \
({ \ (*({ \
typeof(_unused_cpumask_arg_) m; \ typeof(_unused_cpumask_arg_) m; \
if (sizeof(m) == sizeof(unsigned long)) { \ if (sizeof(m) == sizeof(unsigned long)) { \
m.bits[0] = 1UL<<(cpu); \ m.bits[0] = 1UL<<(cpu); \
...@@ -231,8 +236,9 @@ int __next_cpu(int n, const cpumask_t *srcp); ...@@ -231,8 +236,9 @@ int __next_cpu(int n, const cpumask_t *srcp);
cpus_clear(m); \ cpus_clear(m); \
cpu_set((cpu), m); \ cpu_set((cpu), m); \
} \ } \
m; \ &m; \
}) }))
#endif
#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS) #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
......
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