]> err.no Git - linux-2.6/commitdiff
i386: simplify smp_call_function_single() call sequence in msr-on-cpu
authorAvi Kivity <avi@qumranet.com>
Wed, 17 Oct 2007 16:04:38 +0000 (18:04 +0200)
committerThomas Gleixner <tglx@inhelltoy.tec.linutronix.de>
Wed, 17 Oct 2007 18:16:20 +0000 (20:16 +0200)
smp_call_function_single() now knows how to call the function on the
current cpu.

[ tglx: arch/x86 adaptation ]

Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/lib/msr-on-cpu.c

index 7767962f25d34d90f35cb0b7aab64f61b1c454a6..57d043fa893e48f9a2412a479cb01445ab1d1122 100644 (file)
@@ -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;
 }