Clean up smp_call_function_single() callers
cover Clean up smp_call_function_single() callers
Now that smp_call_function_single() knows how to call a function on the currently running cpu, there is no need to do the elaborate get_cpu()/put_cpu() dance.
PATCH 1/4 Simplify smp_call_function_single() call sequence
smp_call_function_single() now knows how to call the function on the current cpu.
--- arch/i386/kernel/cpu/mtrr/main.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
arch/i386/kernel/cpu/mtrr/main.c +1 -7
@@ -738,13 +738,7 @@ void mtrr_ap_init(void)*/ void mtrr_save_state (void ) { -int cpu =get_cpu (); - -if (cpu ==0 ) -mtrr_save_fixed_ranges (NULL ); -else -smp_call_function_single (0 , mtrr_save_fixed_ranges,NULL ,1 ,1 ); -put_cpu (); +smp_call_function_single (0 , mtrr_save_fixed_ranges,NULL ,1 ,1 ); }static int __init mtrr_init_finialize (void )
Signature · 1 line
1.5.2.4
PATCH 2/4 Simplify smp_call_function_single() call sequence
In reply to Avi Kivitysmp_call_function_single() now knows how to call the function on the current cpu.
--- arch/i386/kernel/cpuid.c | 22 +++------------------- 1 files changed, 3 insertions(+), 19 deletions(-)
arch/i386/kernel/cpuid.c +3 -19
@@ -45,8 +45,6 @@static struct class *cpuid_class; -#ifdef CONFIG_SMP -struct cpuid_command {u32 reg;u32 *data;
@@ -64,25 +62,11 @@ static inline void do_cpuid(int cpu, u32 reg, u32 * data) {struct cpuid_command cmd; -preempt_disable (); -if (cpu ==smp_processor_id ()) { -cpuid (reg, &data[0 ], &data[1 ], &data[2 ], &data[3 ]); - }else { - cmd.reg = reg; - cmd.data = data; + cmd.reg = reg; + cmd.data = data; -smp_call_function_single (cpu, cpuid_smp_cpuid, &cmd,1 ,1 ); - } -preempt_enable (); +smp_call_function_single (cpu, cpuid_smp_cpuid, &cmd,1 ,1 ); } -#else /* ! CONFIG_SMP */ - -static inline void do_cpuid (int cpu,u32 reg,u32 * data) -{ -cpuid (reg, &data[0 ], &data[1 ], &data[2 ], &data[3 ]); -} - -#endif /* ! CONFIG_SMP */ static loff_t cpuid_seek (struct file *file,loff_t offset,int orig) {
Signature · 1 line
1.5.2.4
PATCH 3/4 Simplify smp_call_function_single() call sequence
In reply to Avi Kivitysmp_call_function_single() now knows how to call the function on the current cpu.
--- arch/i386/lib/msr-on-cpu.c | 62 +++++++++++++++---------------------------- 1 files changed, 22 insertions(+), 40 deletions(-)
arch/i386/lib/msr-on-cpu.c +22 -40
@@ -26,27 +26,18 @@ static void __rdmsr_safe_on_cpu(void *info)static int _rdmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 *l,u32 *h,int safe) {int err =0 ; -preempt_disable (); -if (smp_processor_id () == cpu) -if (safe) - err =rdmsr_safe (msr_no, l, h); -else -rdmsr (msr_no, *l, *h); -else { -struct msr_info rv; - - rv.msr_no = msr_no; -if (safe) { -smp_call_function_single (cpu, __rdmsr_safe_on_cpu, - &rv,0 ,1 ); - err = rv.err; - }else { -smp_call_function_single (cpu, __rdmsr_on_cpu, &rv,0 ,1 ); - } - *l = rv.l; - *h = rv.h; +struct msr_info rv; + + rv.msr_no = msr_no; +if (safe) { +smp_call_function_single (cpu, __rdmsr_safe_on_cpu, &rv,0 ,1 ); + err = rv.err; + }else { +smp_call_function_single (cpu, __rdmsr_on_cpu, &rv,0 ,1 ); } -preempt_enable (); + *l = rv.l; + *h = rv.h; +return err; }
@@ -67,27 +58,18 @@ static void __wrmsr_safe_on_cpu(void *info)static int _wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h,int safe) {int err =0 ; -preempt_disable (); -if (smp_processor_id () == cpu) -if (safe) - err =wrmsr_safe (msr_no, l, h); -else -wrmsr (msr_no, l, h); -else { -struct msr_info rv; - - rv.msr_no = msr_no; - rv.l = l; - rv.h = h; -if (safe) { -smp_call_function_single (cpu, __wrmsr_safe_on_cpu, - &rv,0 ,1 ); - err = rv.err; - }else { -smp_call_function_single (cpu, __wrmsr_on_cpu, &rv,0 ,1 ); - } +struct msr_info rv; + + rv.msr_no = msr_no; + rv.l = l; + rv.h = h; +if (safe) { +smp_call_function_single (cpu, __wrmsr_safe_on_cpu, &rv,0 ,1 ); + err = rv.err; + }else { +smp_call_function_single (cpu, __wrmsr_on_cpu, &rv,0 ,1 ); } -preempt_enable (); +return err; }
Signature · 1 line
1.5.2.4
PATCH 4/4 Simplify smp_call_function_single() call sequence
In reply to Avi Kivitysmp_call_function_single() now knows how to call the function on the current cpu.
--- kernel/time/tick-broadcast.c | 17 ++++------------- 1 files changed, 4 insertions(+), 13 deletions(-)
kernel/time/tick-broadcast.c +4 -13
@@ -241,21 +241,12 @@ out:*/ void tick_broadcast_on_off (unsigned long reason,int *oncpu) { -int cpu =get_cpu (); - -if (!cpu_isset (*oncpu, cpu_online_map)) { +if (!cpu_isset (*oncpu, cpu_online_map))printk (KERN_ERR "tick-braodcast: ignoring broadcast for " "offline CPU #%d\n" , *oncpu); - }else { - -if (cpu == *oncpu) -tick_do_broadcast_on_off (&reason); -else -smp_call_function_single (*oncpu, - tick_do_broadcast_on_off, - &reason,1 ,1 ); - } -put_cpu (); +else +smp_call_function_single (*oncpu, tick_do_broadcast_on_off, + &reason,1 ,1 ); }/*
Signature · 1 line
1.5.2.4