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

From: Andrew Morton
Date: Tue Apr 28 2009 - 14:26:18 EST


On Tue, 28 Apr 2009 17:06:06 +0200
Borislav Petkov <borislav.petkov@xxxxxxx> wrote:

> From: Doug Thompson <dougthompson@xxxxxxxxxxxx>
>
> Signed-off-by: Doug Thompson <dougthompson@xxxxxxxxxxxx>
> Signed-off-by: Borislav Petkov <borislav.petkov@xxxxxxx>
> ---
> drivers/edac/amd64_edac.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 42 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
> index ac4e265..49c0ce0 100644
> --- a/drivers/edac/amd64_edac.c
> +++ b/drivers/edac/amd64_edac.c
> @@ -3121,4 +3121,46 @@ static struct pci_dev *pci_get_related_function(unsigned int vendor,
> return dev;
> }
>
> +/* 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.

> +struct msr_command {
> + int cpu;
> + int err;
> + u32 reg;
> + u32 data[2];
> +};
> +
> +static void smp_wrmsr(void *cmd_block)
> +{
> + struct msr_command *cmd = cmd_block;
> + wrmsr(cmd->reg, cmd->data[0], cmd->data[1]);
> +}
> +
> +static void smp_rdmsr(void *cmd_block)
> +{
> + struct msr_command *cmd = cmd_block;
> + rdmsr(cmd->reg, cmd->data[0], cmd->data[1]);
> +}
> +
> +static void do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx)
> +{
> + struct msr_command cmd;
> +
> + cmd.cpu = raw_smp_processor_id();
> + cmd.reg = reg;
> + cmd.data[0] = eax;
> + cmd.data[1] = edx;
> + on_each_cpu(smp_wrmsr, &cmd, 1);
> +}
> +
> +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?

--
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/