Re: [PATCH 14/21] amd64_edac: add msr accessors operating on allcpus

From: H. Peter Anvin
Date: Tue Apr 28 2009 - 14:33:33 EST


Andrew Morton wrote:
>>
>> +/* stolen from msr.c - the calls in msr.c could be exported */
>
> It would be preferable to export the functions from msr.c! We do have a number
> of exported MSR manipulation functions in x86.
>

Even better would be to add these functions to lib/msr.c.

>> +
>> +static void do_rdmsr(int cpu, u32 reg, u32 *eax, u32 *edx)
>> +{
>> + struct msr_command cmd;
>> +
>> + cmd.cpu = raw_smp_processor_id();
>> + cmd.reg = reg;
>> + on_each_cpu(smp_rdmsr, &cmd, 1);
>> + *eax = cmd.data[0];
>> + *edx = cmd.data[1];
>> +}
>
> I'm all confused. We interrupt _all_ CPUs and get each one of them to
> write to cmd.data[0] and cmd.data[1]. So what we end up returning is
> the result which was provided by the last CPU which got there,
> whichever CPU that was.
>
> Am I mising something, or is this all totally screwy?
>

For reads, certainly... the only sane way to do this would be to return
this into a array with per-CPU slots (since it's transient I don't think
we want to use a percpu varaible.)

For writes, what is there is fine, although perhaps less flexible than
it needs to be.

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/