cpumask: fix CONFIG_CPUMASK_OFFSTACK=y cpu hotunplug crash
Impact: Fix cpu offline when CONFIG_MAXSMP=y
Changeset bc9b83dd1f
"cpumask: convert
c1e_mask in arch/x86/kernel/process.c to cpumask_var_t" contained a
bug: c1e_mask is manipulated even if C1E isn't detected (and hence
not allocated).
This is simply fixed by checking for NULL (which gcc optimizes out
anyway of CONFIG_CPUMASK_OFFSTACK=n, since it knows ce1_mask can never
be NULL).
In addition, fix a leak where select_idle_routine re-allocates
(and re-clears) c1e_mask on every cpu init.
Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Mike Travis <travis@sgi.com>
LKML-Reference: <200903171450.34549.rusty@rustcorp.com.au>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
committed by
Ingo Molnar
parent
082edb7bf4
commit
30e1e6d1af
@@ -733,6 +733,7 @@ static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
|
|||||||
extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
|
extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
|
||||||
|
|
||||||
extern void select_idle_routine(const struct cpuinfo_x86 *c);
|
extern void select_idle_routine(const struct cpuinfo_x86 *c);
|
||||||
|
extern void init_c1e_mask(void);
|
||||||
|
|
||||||
extern unsigned long boot_option_idle_override;
|
extern unsigned long boot_option_idle_override;
|
||||||
extern unsigned long idle_halt;
|
extern unsigned long idle_halt;
|
||||||
|
@@ -812,6 +812,7 @@ static void vgetcpu_set_mode(void)
|
|||||||
void __init identify_boot_cpu(void)
|
void __init identify_boot_cpu(void)
|
||||||
{
|
{
|
||||||
identify_cpu(&boot_cpu_data);
|
identify_cpu(&boot_cpu_data);
|
||||||
|
init_c1e_mask();
|
||||||
#ifdef CONFIG_X86_32
|
#ifdef CONFIG_X86_32
|
||||||
sysenter_setup();
|
sysenter_setup();
|
||||||
enable_sep_cpu();
|
enable_sep_cpu();
|
||||||
|
@@ -479,7 +479,8 @@ static int c1e_detected;
|
|||||||
|
|
||||||
void c1e_remove_cpu(int cpu)
|
void c1e_remove_cpu(int cpu)
|
||||||
{
|
{
|
||||||
cpumask_clear_cpu(cpu, c1e_mask);
|
if (c1e_mask != NULL)
|
||||||
|
cpumask_clear_cpu(cpu, c1e_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -556,13 +557,20 @@ void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
|
|||||||
pm_idle = mwait_idle;
|
pm_idle = mwait_idle;
|
||||||
} else if (check_c1e_idle(c)) {
|
} else if (check_c1e_idle(c)) {
|
||||||
printk(KERN_INFO "using C1E aware idle routine\n");
|
printk(KERN_INFO "using C1E aware idle routine\n");
|
||||||
alloc_cpumask_var(&c1e_mask, GFP_KERNEL);
|
|
||||||
cpumask_clear(c1e_mask);
|
|
||||||
pm_idle = c1e_idle;
|
pm_idle = c1e_idle;
|
||||||
} else
|
} else
|
||||||
pm_idle = default_idle;
|
pm_idle = default_idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __init init_c1e_mask(void)
|
||||||
|
{
|
||||||
|
/* If we're using c1e_idle, we need to allocate c1e_mask. */
|
||||||
|
if (pm_idle == c1e_idle) {
|
||||||
|
alloc_cpumask_var(&c1e_mask, GFP_KERNEL);
|
||||||
|
cpumask_clear(c1e_mask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int __init idle_setup(char *str)
|
static int __init idle_setup(char *str)
|
||||||
{
|
{
|
||||||
if (!str)
|
if (!str)
|
||||||
|
Reference in New Issue
Block a user