lkml.org 
[lkml]   [2009]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 14/21] amd64_edac: add msr accessors operating on all cpus
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.



\
 
 \ /
  Last update: 2009-04-28 20:35    [from the cache]
©2003-2011 Jasper Spaans