[lkml]   [2012]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH] perf/x86: check ucode before disabling PEBS on SandyBridge
    On Fri, 2012-06-08 at 16:36 +0200, Borislav Petkov wrote:
    > 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().

    I was thinking about reload_store(), that seems to only reload ucode for
    a single cpu.

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

    Nah.. it'll probably be the first. But it doesn't matter which cpu does
    it. So the idea was:

    static void intel_snb_verify_work(struct work_struct *work)
    /* do the verify thing.. */

    static DECLARE_DELAYED_WORK(intel_snb_delayed_work, intel_snb_verify_ucode);

    static int intel_snb_ucode_notifier(struct notifier_block *self,
    unsigned long action, void *_uci)
    * Since ucode cannot be down-graded, and no future ucode revision
    * is known to break PEBS again, we're ok with MICROCODE_CAN_UPDATE.

    if (action == MICROCODE_UPDATED)
    schedule_delayed_work(&intel_snb_delayed_work, HZ);

    return NOTIFY_DONE;

    Thus it will queue the delayed work when the work isn't already queued
    for execution. Resulting in the work only happening once a second (at

     \ /
      Last update: 2012-06-08 17:21    [W:0.093 / U:41.744 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site