cpumask: x86 mmio-mod.c use cpumask_var_t for downed_cpus.
Subsystems (3)
PATCH 1/1 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.
To: Pekka Paalanen <[email protected]>
--- arch/x86/mm/mmio-mod.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
arch/x86/mm/mmio-mod.c +13 -6
@@ -378,27 +378,34 @@ static void clear_trace_list(void) }#ifdef CONFIG_HOTPLUG_CPU -static cpumask_t downed_cpus; +static cpumask_var_t downed_cpus;static void enter_uniprocessor (void ) {int cpu;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 (); - downed_cpus = cpu_online_map; -cpu_clear (first_cpu (cpu_online_map), downed_cpus); +cpumask_copy (downed_cpus, cpu_online_mask); +cpumask_clear_cpu (cpumask_first (cpu_online_mask), downed_cpus);if (num_online_cpus () >1 )pr_notice (NAME "Disabling non-boot CPUs...\n" );put_online_cpus (); -for_each_cpu_mask (cpu, downed_cpus) { +for_each_cpu (cpu, downed_cpus) { err =cpu_down (cpu);if (!err)pr_info (NAME "CPU%d is down.\n" , cpu);else pr_err (NAME "Error taking CPU%d down: %d\n" , cpu, err); } +out:if (num_online_cpus () >1 )pr_warning (NAME "multiple CPUs still online, " "may miss events.\n" );
@@ -411,10 +418,10 @@ static void __ref leave_uniprocessor(voiint cpu;int err; -if (cpus_weight (downed_cpus) ==0 ) +if (downed_cpus ==NULL ||cpumask_weight (downed_cpus) ==0 )return ;pr_notice (NAME "Re-enabling CPUs...\n" ); -for_each_cpu_mask (cpu, downed_cpus) { +for_each_cpu (cpu, downed_cpus) { err =cpu_up (cpu);if (!err)pr_info (NAME "enabled CPU%d.\n" , cpu);
[tip:cpus4096] x86: cpumask: x86 mmio-mod.c use cpumask_var_t for downed_cpus
Commit-ID: f5c14fe200f4315b305ae44e5633cbe62070aaea Gitweb: http://git.kernel.org/tip/f5c14fe200f4315b305ae44e5633cbe62070aaea Author: "Rusty Russell" <[email protected]> AuthorDate: Wed, 11 Mar 2009 16:33:55 +1030 Commit: Ingo Molnar <[email protected]> CommitDate: Wed, 11 Mar 2009 11:19:47 +0100
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.
LKML-Reference: <[email protected]>
--- arch/x86/mm/mmio-mod.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
arch/x86/mm/mmio-mod.c +13 -6
@@ -378,27 +378,34 @@ static void clear_trace_list(void) }#ifdef CONFIG_HOTPLUG_CPU -static cpumask_t downed_cpus; +static cpumask_var_t downed_cpus;static void enter_uniprocessor (void ) {int cpu;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 (); - downed_cpus = cpu_online_map; -cpu_clear (first_cpu (cpu_online_map), downed_cpus); +cpumask_copy (downed_cpus, cpu_online_mask); +cpumask_clear_cpu (cpumask_first (cpu_online_mask), downed_cpus);if (num_online_cpus () >1 )pr_notice (NAME "Disabling non-boot CPUs...\n" );put_online_cpus (); -for_each_cpu_mask (cpu, downed_cpus) { +for_each_cpu (cpu, downed_cpus) { err =cpu_down (cpu);if (!err)pr_info (NAME "CPU%d is down.\n" , cpu);else pr_err (NAME "Error taking CPU%d down: %d\n" , cpu, err); } +out:if (num_online_cpus () >1 )pr_warning (NAME "multiple CPUs still online, " "may miss events.\n" );
@@ -411,10 +418,10 @@ static void __ref leave_uniprocessor(void)int cpu;int err; -if (cpus_weight (downed_cpus) ==0 ) +if (downed_cpus ==NULL ||cpumask_weight (downed_cpus) ==0 )return ;pr_notice (NAME "Re-enabling CPUs...\n" ); -for_each_cpu_mask (cpu, downed_cpus) { +for_each_cpu (cpu, downed_cpus) { err =cpu_up (cpu);if (!err)pr_info (NAME "enabled CPU%d.\n" , cpu);
Pekka Paalanen
Acked-byRe: [tip:cpus4096] x86: cpumask: x86 mmio-mod.c use cpumask_var_t for downed_cpus
Quoted 13 lines · On Wed, 11 Mar 2009 11:13:59 GMT Rusty Russell <[email protected]> wrote:
Commit-ID: f5c14fe200f4315b305ae44e5633cbe62070aaea Gitweb: http://git.kernel.org/tip/f5c14fe200f4315b305ae44e5633cbe62070aaea Author: "Rusty Russell" <[email protected]> AuthorDate: Wed, 11 Mar 2009 16:33:55 +1030 Commit: Ingo Molnar <[email protected]> CommitDate: Wed, 11 Mar 2009 11:19:47 +0100x86: cpumask: x86
mmio-mod.cusecpumask_var_tfordowned_cpusImpact: cleanup, reduce memory usage for
CONFIG_CPUMASK_OFFSTACK=yPart of the "getting rid of obsolete
cpumask_t" patch:
Quoted 8 lines
1) Use
cpumask_var_t: this is a pointer ifCONFIG_CPUMASK_OFFSTACK=y
2) Callalloc_cpumask_var()on first entry intoenter_uniprocessor()
3) Use modern cpumask_* functions.Signed-off-by Rusty Russell <[email protected]>Cc Pekka Paalanen <[email protected]>LKML-Reference: <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
Quoted 63 lines
--- arch/x86/mm/mmio-mod.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)arch/x86/mm/mmio-mod.c +13
-6@@ -378,27 +378,34 @@ static void clear_trace_list(void) }#ifdef CONFIG_HOTPLUG_CPU -static cpumask_t downed_cpus; +static cpumask_var_t downed_cpus;static void enter_uniprocessor (void ) {int cpu;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 (); - downed_cpus = cpu_online_map; -cpu_clear (first_cpu (cpu_online_map), downed_cpus); +cpumask_copy (downed_cpus, cpu_online_mask); +cpumask_clear_cpu (cpumask_first (cpu_online_mask), downed_cpus);if (num_online_cpus () >1 )pr_notice (NAME "Disabling non-boot CPUs...\n" );put_online_cpus (); -for_each_cpu_mask (cpu, downed_cpus) { +for_each_cpu (cpu, downed_cpus) { err =cpu_down (cpu);if (!err)pr_info (NAME "CPU%d is down.\n" , cpu);else pr_err (NAME "Error taking CPU%d down: %d\n" , cpu, err); } +out:if (num_online_cpus () >1 )pr_warning (NAME "multiple CPUs still online, " "may miss events.\n" );@@ -411,10 +418,10 @@ static void __ref leave_uniprocessor(void)int cpu;int err; -if (cpus_weight (downed_cpus) ==0 ) +if (downed_cpus ==NULL ||cpumask_weight (downed_cpus) ==0 )return ;pr_notice (NAME "Re-enabling CPUs...\n" ); -for_each_cpu_mask (cpu, downed_cpus) { +for_each_cpu (cpu, downed_cpus) { err =cpu_up (cpu);if (!err)pr_info (NAME "enabled CPU%d.\n" , cpu);
Signature · 2 lines
Pekka Paalanen http://www.iki.fi/pq/
[tip:cpus4096] x86: cpumask: x86 mmio-mod.c use cpumask_var_t for downed_cpus
In reply to Rusty RussellCommit-ID: c38da5692e3a4d5d303c04cbf7e526f1eb761076 Gitweb: http://git.kernel.org/tip/c38da5692e3a4d5d303c04cbf7e526f1eb761076 Author: Rusty Russell <[email protected]> AuthorDate: Wed, 11 Mar 2009 16:33:55 +1030 Commit: Ingo Molnar <[email protected]> CommitDate: Wed, 18 Mar 2009 13:51:51 +0100
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.
LKML-Reference: <[email protected]>
--- arch/x86/mm/mmio-mod.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
arch/x86/mm/mmio-mod.c +13 -6
@@ -378,27 +378,34 @@ static void clear_trace_list(void) }#ifdef CONFIG_HOTPLUG_CPU -static cpumask_t downed_cpus; +static cpumask_var_t downed_cpus;static void enter_uniprocessor (void ) {int cpu;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 (); - downed_cpus = cpu_online_map; -cpu_clear (first_cpu (cpu_online_map), downed_cpus); +cpumask_copy (downed_cpus, cpu_online_mask); +cpumask_clear_cpu (cpumask_first (cpu_online_mask), downed_cpus);if (num_online_cpus () >1 )pr_notice (NAME "Disabling non-boot CPUs...\n" );put_online_cpus (); -for_each_cpu_mask (cpu, downed_cpus) { +for_each_cpu (cpu, downed_cpus) { err =cpu_down (cpu);if (!err)pr_info (NAME "CPU%d is down.\n" , cpu);else pr_err (NAME "Error taking CPU%d down: %d\n" , cpu, err); } +out:if (num_online_cpus () >1 )pr_warning (NAME "multiple CPUs still online, " "may miss events.\n" );
@@ -411,10 +418,10 @@ static void __ref leave_uniprocessor(void)int cpu;int err; -if (cpus_weight (downed_cpus) ==0 ) +if (downed_cpus ==NULL ||cpumask_weight (downed_cpus) ==0 )return ;pr_notice (NAME "Re-enabling CPUs...\n" ); -for_each_cpu_mask (cpu, downed_cpus) { +for_each_cpu (cpu, downed_cpus) { err =cpu_up (cpu);if (!err)pr_info (NAME "enabled CPU%d.\n" , cpu);