Re: [PATCH] perf/x86: check ucode before disabling PEBS onSandyBridge

From: Borislav Petkov
Date: Fri Jun 08 2012 - 10:36:26 EST


On Fri, Jun 08, 2012 at 04:20:50PM +0200, Peter Zijlstra wrote:
> On Fri, 2012-06-08 at 16:15 +0200, Borislav Petkov wrote:
> > have a variable which gets initialized to the number of all CPUs and
> > each time ->apply_microcode() finishes by returning 0, we decrement it
> > once.
>
> >
> > Hmm, I'm probably missing some obscure case.
>
> Since its all per-cpu sysfs muck, userspace could update a random
> subsets of cpus.. leaving us hanging.

I'm afraid I don't understand - when you modprobe microcode.ko,
it goes and loads /lib/firmware/amd-ucode/microcode_amd.bin (in
the AMD case) on each CPU when the driver gets regged through
subsys_interface_register().

It calls ->add_dev() on each CPU - this should be guaranteed because it
uses the cpu_subsys from drivers/base/cpu.c which onlines all CPUs, I'd
assume.

So, I'd say that once subsys_interface_register() returns, we have
updated ucode on all CPUs, if successful...

We probably could run the notifier at that moment, before we do
put_online_cpus().

> The 'bestestet' idea I came up with is doing the verify thing I have
> from a delayed work -- say 1 second into the future. That way, when
> there's lots of cpus they all try and enqueue the one work, which at
> the end executes only once, provided the entire update scan took less
> than the second.

You're saying, you want the last CPU that gets to update its microcode
gets to also run the delayed work...? Probably, I'd assume ucode update
on a single CPU takes less than a second IIUC.

--
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551

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