Re: [PATCH] [x86, msr]: remove code duplication

Borislav Petkov
2009-07-07T10:38:34Z

On Mon, Jul 06, 2009 at 02:31:36PM -0700, H. Peter Anvin wrote:
> Borislav Petkov wrote:
> > -
> > - smp_call_function_many(mask, __rdmsr_on_cpu, &rv, 1);
> > + smp_call_function_single(this_cpu, msr_func, &rv, 1);
> > + smp_call_function_many(mask, msr_func, &rv, 1);
> > preempt_enable();
>
> Why are you using smp_call_function_single() to execute something *on
> your own CPU*?

Actually, the more important question is why am I executing anything on
my own CPU without first checking if it is in the cpumask _at_ _all_?!
/me ducks behind the sofa.

The right thing to do should be something like the following:

preempt_disable();
this_cpu = raw_smp_processor_id();

if (cpumask_test_cpu(this_cpu, mask)) {
local_irq_disable();
msr_func(&rv);
local_irq_enable();
}

smp_call_function_many(mask, msr_func, &rv, 1);
preempt_enable();

Patch coming up...

--
Regards/Gruss,
Boris.

Operating | Advanced Micro Devices GmbH
System | Karl-Hammerschmidt-Str. 34, 85609 Dornach b. München, Germany
Research | Geschäftsführer: Thomas M. McCoy, Giuliano Meroni
Center | Sitz: Dornach, Gemeinde Aschheim, Landkreis München
(OSRC) | Registergericht München, HRB Nr. 43632