x86/kgdb: Replace bool_int_array[NR_CPUS] with bitmap
Subsystems (2)
PATCH 1/1 x86/kgdb: Replace bool_int_array[NR_CPUS] with bitmap
Straigntforward conversion from
int was_in_debug_nmi[NR_CPUS]
to
DECLARE_BITMAP(was_in_debug_nmi, NR_CPUS)
Saves about 2 kbytes in bss for NR_CPUS=512.
--- arch/x86/kernel/kgdb.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
arch/x86/kernel/kgdb.c +8 -5
@@ -511,24 +511,27 @@ single_step_cont(struct pt_regs *regs, struct die_args *args)return NOTIFY_STOP ; } -static int was_in_debug_nmi[NR_CPUS ]; +static DECLARE_BITMAP(was_in_debug_nmi, NR_CPUS);static int kgdb_nmi_handler (unsigned int cmd,struct pt_regs *regs) { +int cpu; +switch (cmd) {case NMI_LOCAL :if (atomic_read (&kgdb_active) !=-1 ) {/* KGDB CPU roundup */ -kgdb_nmicallback (raw_smp_processor_id (), regs); - was_in_debug_nmi[raw_smp_processor_id ()] =1 ; + cpu =raw_smp_processor_id (); +kgdb_nmicallback (cpu, regs); +set_bit (cpu, was_in_debug_nmi);touch_nmi_watchdog ();return NMI_HANDLED ; }break ;case NMI_UNKNOWN : -if (was_in_debug_nmi[raw_smp_processor_id ()]) { - was_in_debug_nmi[raw_smp_processor_id ()] =0 ; + cpu =raw_smp_processor_id (); +if (__test_and_clear_bit (cpu, was_in_debug_nmi)) {return NMI_HANDLED ; }break ;
Signature · 1 line
1.8.1.4
PATCH 1/1 cpufreq: p4-clockmod: Replace bool_int_array[NR_CPUS] with bitmap
Straigntforward conversion from
int has_N44_O17_errata[NR_CPUS]
to
DECLARE_BITMAP(has_N44_O17_errata, NR_CPUS)Saves about 2 kbytes in bss for NR_CPUS=512.
--- drivers/cpufreq/p4-clockmod.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/cpufreq/p4-clockmod.c +4 -4
@@ -49,7 +49,7 @@ enum {#define DC_ENTRIES 8 -static int has_N44_O17_errata[NR_CPUS ]; +static DECLARE_BITMAP(has_N44_O17_errata, NR_CPUS);static unsigned int stock_freq;static struct cpufreq_driver p4clockmod_driver;static unsigned int cpufreq_p4_get (unsigned int cpu);
@@ -66,7 +66,7 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)if (l &0x01 )pr_debug ("CPU#%d currently thermal throttled\n" , cpu); -if (has_N44_O17_errata[cpu] && +if (test_bit (cpu, has_N44_O17_errata) && (newstate ==DC_25PT || newstate ==DC_DFLT )) newstate =DC_38PT ;
@@ -182,7 +182,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)case 0x0f0a :case 0x0f11 :case 0x0f12 : - has_N44_O17_errata[policy->cpu] =1 ; +set_bit (policy->cpu, has_N44_O17_errata);pr_debug ("has errata -- disabling low frequencies\n" ); }
@@ -199,7 +199,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)/* table init */ for (i =1 ; (p4clockmod_table[i].frequency !=CPUFREQ_TABLE_END ); i++) { -if ((i <2 ) && (has_N44_O17_errata[policy->cpu])) +if ((i <2 ) &&test_bit (policy->cpu, has_N44_O17_errata)) p4clockmod_table[i].frequency =CPUFREQ_ENTRY_INVALID ;else p4clockmod_table[i].frequency = (stock_freq * i)/8 ;
Signature · 1 line
1.8.1.4
Re: [PATCH] cpufreq: p4-clockmod: Replace bool_int_array[NR_CPUS] with bitmap
Quoted 58 lines · Denys Vlasenko
Straigntforward conversion from
int has_N44_O17_errata[NR_CPUS] to DECLARE_BITMAP(has_N44_O17_errata, NR_CPUS)Saves about 2 kbytes in bss for NR_CPUS=512.
Signed-off-by Denys Vlasenko <[email protected]>CC Viresh Kumar <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Ingo Molnar <[email protected]>CC Bartosz Golaszewski <[email protected]>CC H. Peter Anvin <[email protected]>CC Benoit Cousson <[email protected]>CC Fenghua Yu <[email protected]>CC Guenter Roeck <[email protected]>CC Jean Delvare <[email protected]>CC Jonathan Corbet <[email protected]>CC Peter Zijlstra <[email protected]>CC Thomas Gleixner <[email protected]>--- drivers/cpufreq/p4-clockmod.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/cpufreq/p4-clockmod.c +3
-3@@ -49,7 +49,7 @@ enum {#define DC_ENTRIES 8 -static int has_N44_O17_errata[NR_CPUS ]; +static DECLARE_BITMAP(has_N44_O17_errata, NR_CPUS);static unsigned int stock_freq;static struct cpufreq_driver p4clockmod_driver;static unsigned int cpufreq_p4_get (unsigned int cpu);@@ -66,7 +66,7 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)if (l &0x01 )pr_debug ("CPU#%d currently thermal throttled\n" , cpu); -if (has_N44_O17_errata[cpu] && +if (test_bit (cpu, has_N44_O17_errata) && (newstate ==DC_25PT || newstate ==DC_DFLT )) newstate =DC_38PT ;@@ -182,7 +182,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)case 0x0f0a :case 0x0f11 :case 0x0f12 : - has_N44_O17_errata[policy->cpu] =1 ; +set_bit (policy->cpu, has_N44_O17_errata);pr_debug ("has errata -- disabling low frequencies\n" ); }
drivers/cpufreq/p4-clockmod.c static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy) · line 205
Quoted 8 lines
drivers/cpufreq/p4-clockmod.c +1
-1@@ -199,7 +199,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)/* table init */ for (i =1 ; (p4clockmod_table[i].frequency !=CPUFREQ_TABLE_END ); i++) { -if ((i <2 ) && (has_N44_O17_errata[policy->cpu])) +if ((i <2 ) &&test_bit (policy->cpu, has_N44_O17_errata)) p4clockmod_table[i].frequency =CPUFREQ_ENTRY_INVALID ;else p4clockmod_table[i].frequency = (stock_freq * i)/8 ;
Signature · 1 line
viresh
Re: [PATCH] cpufreq: p4-clockmod: Replace bool_int_array[NR_CPUS] with bitmap
In reply to Denys VlasenkoHi Denys,
Quoted 58 lines · Denys Vlasenko
Straigntforward conversion from
int has_N44_O17_errata[NR_CPUS] to DECLARE_BITMAP(has_N44_O17_errata, NR_CPUS)Saves about 2 kbytes in bss for NR_CPUS=512.
Signed-off-by Denys Vlasenko <[email protected]>CC Viresh Kumar <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Ingo Molnar <[email protected]>CC Bartosz Golaszewski <[email protected]>CC H. Peter Anvin <[email protected]>CC Benoit Cousson <[email protected]>CC Fenghua Yu <[email protected]>CC Guenter Roeck <[email protected]>CC Jean Delvare <[email protected]>CC Jonathan Corbet <[email protected]>CC Peter Zijlstra <[email protected]>CC Thomas Gleixner <[email protected]>--- drivers/cpufreq/p4-clockmod.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/cpufreq/p4-clockmod.c +3
-3@@ -49,7 +49,7 @@ enum {#define DC_ENTRIES 8 -static int has_N44_O17_errata[NR_CPUS ]; +static DECLARE_BITMAP(has_N44_O17_errata, NR_CPUS);static unsigned int stock_freq;static struct cpufreq_driver p4clockmod_driver;static unsigned int cpufreq_p4_get (unsigned int cpu);@@ -66,7 +66,7 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)if (l &0x01 )pr_debug ("CPU#%d currently thermal throttled\n" , cpu); -if (has_N44_O17_errata[cpu] && +if (test_bit (cpu, has_N44_O17_errata) && (newstate ==DC_25PT || newstate ==DC_DFLT )) newstate =DC_38PT ;@@ -182,7 +182,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)case 0x0f0a :case 0x0f11 :case 0x0f12 : - has_N44_O17_errata[policy->cpu] =1 ; +set_bit (policy->cpu, has_N44_O17_errata);pr_debug ("has errata -- disabling low frequencies\n" ); }
drivers/cpufreq/p4-clockmod.c static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy) · line 205
Quoted 8 lines
drivers/cpufreq/p4-clockmod.c +1
-1@@ -199,7 +199,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)/* table init */ for (i =1 ; (p4clockmod_table[i].frequency !=CPUFREQ_TABLE_END ); i++) { -if ((i <2 ) && (has_N44_O17_errata[policy->cpu])) +if ((i <2 ) &&test_bit (policy->cpu, has_N44_O17_errata)) p4clockmod_table[i].frequency =CPUFREQ_ENTRY_INVALID ;else p4clockmod_table[i].frequency = (stock_freq * i)/8 ;
Looks good, however I think you should #include <linux/bitmap.h> to avoid build failures in the future or on certain architectures.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Re: [PATCH] cpufreq: p4-clockmod: Replace bool_int_array[NR_CPUS] with bitmap
Quoted 2 lines · Jean Delvare
Looks good, however I think you should #include <
linux/bitmap.h> to avoid build failures in the future or on certain architectures.
<linux/cpumask.h> already includes <linux/bitmap.h> on any arch.
p4-clockmod.c builds only on x86 arch, it's Pentium 4 on demand clock modulation/speed scaling module.
Re: [PATCH] cpufreq: p4-clockmod: Replace bool_int_array[NR_CPUS] with bitmap
Quoted 6 lines · Denys Vlasenko
Quoted 2 lines · Jean Delvare
Looks good, however I think you should #include <
linux/bitmap.h> to avoid build failures in the future or on certain architectures.<
linux/cpumask.h> already includes <linux/bitmap.h> on any arch.
Today it does. Tomorrow, who knows.
Quoted 2 lines
p4-clockmod.cbuilds only on x86 arch, it's Pentium 4 on demand clock modulation/speed scaling module.
That is a valid point. My comment was generic, I did not pay attention to the specific driver.
Signature · 2 lines
Jean Delvare SUSE L3 Support
tip-bot for Denys Vlasenko
merge botx86/kgdb: Replace bool_int_array[NR_CPUS] with bitmap
Commit-ID: 0d44975d1e2791f6df2b84b182f49d815ba3c9e0 Gitweb: http://git.kernel.org/tip/0d44975d1e2791f6df2b84b182f49d815ba3c9e0 Author: Denys Vlasenko <[email protected]> AuthorDate: Sat, 26 Sep 2015 14:47:17 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 28 Sep 2015 10:13:31 +0200
x86/kgdb: Replace bool_int_array[NR_CPUS] with bitmap
Straigntforward conversion from:
int was_in_debug_nmi[NR_CPUS]
to:
DECLARE_BITMAP(was_in_debug_nmi, NR_CPUS)
Saves about 2 kbytes in BSS for NR_CPUS=512.
--- arch/x86/kernel/kgdb.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
arch/x86/kernel/kgdb.c +11 -6
@@ -511,26 +511,31 @@ single_step_cont(struct pt_regs *regs, struct die_args *args)return NOTIFY_STOP ; } -static int was_in_debug_nmi[NR_CPUS ]; +static DECLARE_BITMAP(was_in_debug_nmi, NR_CPUS);static int kgdb_nmi_handler (unsigned int cmd,struct pt_regs *regs) { +int cpu; +switch (cmd) {case NMI_LOCAL :if (atomic_read (&kgdb_active) !=-1 ) {/* KGDB CPU roundup */ -kgdb_nmicallback (raw_smp_processor_id (), regs); - was_in_debug_nmi[raw_smp_processor_id ()] =1 ; + cpu =raw_smp_processor_id (); +kgdb_nmicallback (cpu, regs); +set_bit (cpu, was_in_debug_nmi);touch_nmi_watchdog (); +return NMI_HANDLED ; }break ;case NMI_UNKNOWN : -if (was_in_debug_nmi[raw_smp_processor_id ()]) { - was_in_debug_nmi[raw_smp_processor_id ()] =0 ; + cpu =raw_smp_processor_id (); + +if (__test_and_clear_bit (cpu, was_in_debug_nmi))return NMI_HANDLED ; - } +break ;default :/* do nothing */