Commit c38da569 authored by Rusty Russell's avatar Rusty Russell Committed by Ingo Molnar

x86: cpumask: x86 mmio-mod.c use cpumask_var_t for downed_cpus

Impact: cleanup, reduce memory usage for CONFIG_CPUMASK_OFFSTACK=y

Part of the "getting rid of obsolete cpumask_t" patch:

 1) Use cpumask_var_t: this is a pointer if CONFIG_CPUMASK_OFFSTACK=y
 2) Call alloc_cpumask_var() on first entry into enter_uniprocessor()
 3) Use modern cpumask_* functions.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Cc: Pekka Paalanen <pq@iki.fi>
LKML-Reference: <200903111633.55952.rusty@rustcorp.com.au>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 89bd55d1
...@@ -378,27 +378,34 @@ static void clear_trace_list(void) ...@@ -378,27 +378,34 @@ static void clear_trace_list(void)
} }
#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_HOTPLUG_CPU
static cpumask_t downed_cpus; static cpumask_var_t downed_cpus;
static void enter_uniprocessor(void) static void enter_uniprocessor(void)
{ {
int cpu; int cpu;
int err; int err;
if (downed_cpus == NULL &&
!alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) {
pr_notice(NAME "Failed to allocate mask\n");
goto out;
}
get_online_cpus(); get_online_cpus();
downed_cpus = cpu_online_map; cpumask_copy(downed_cpus, cpu_online_mask);
cpu_clear(first_cpu(cpu_online_map), downed_cpus); cpumask_clear_cpu(cpumask_first(cpu_online_mask), downed_cpus);
if (num_online_cpus() > 1) if (num_online_cpus() > 1)
pr_notice(NAME "Disabling non-boot CPUs...\n"); pr_notice(NAME "Disabling non-boot CPUs...\n");
put_online_cpus(); put_online_cpus();
for_each_cpu_mask(cpu, downed_cpus) { for_each_cpu(cpu, downed_cpus) {
err = cpu_down(cpu); err = cpu_down(cpu);
if (!err) if (!err)
pr_info(NAME "CPU%d is down.\n", cpu); pr_info(NAME "CPU%d is down.\n", cpu);
else else
pr_err(NAME "Error taking CPU%d down: %d\n", cpu, err); pr_err(NAME "Error taking CPU%d down: %d\n", cpu, err);
} }
out:
if (num_online_cpus() > 1) if (num_online_cpus() > 1)
pr_warning(NAME "multiple CPUs still online, " pr_warning(NAME "multiple CPUs still online, "
"may miss events.\n"); "may miss events.\n");
...@@ -411,10 +418,10 @@ static void __ref leave_uniprocessor(void) ...@@ -411,10 +418,10 @@ static void __ref leave_uniprocessor(void)
int cpu; int cpu;
int err; int err;
if (cpus_weight(downed_cpus) == 0) if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
return; return;
pr_notice(NAME "Re-enabling CPUs...\n"); pr_notice(NAME "Re-enabling CPUs...\n");
for_each_cpu_mask(cpu, downed_cpus) { for_each_cpu(cpu, downed_cpus) {
err = cpu_up(cpu); err = cpu_up(cpu);
if (!err) if (!err)
pr_info(NAME "enabled CPU%d.\n", cpu); pr_info(NAME "enabled CPU%d.\n", cpu);
......
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