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

Peter Zijlstra
2012-06-08T18:52:27Z

On Fri, 2012-06-08 at 20:05 +0200, Borislav Petkov wrote:
> How about this: since the ucode cannot be downgraded and since higher
> ucode versions are supposed to fix current and older problems (otherwise
> ucoders will get an earlfull) you shouldn't be needing to verify the
> ucode version on all CPUs per-CPU, i.e. the O(n^2) overhead.
>
> Rather, simply track which CPUs _haven't_ been updated yet, and once
> this is the empty set, run the verify thing to check ucode version on
> all CPUs.
>
> And this should happen only when we update ucode from version A to
> version B, where B > A.
>
> And unless I'm missing something, this should be O(n) and ucode update
> should happen very seldomly anyway.

Checking a bitmap of n bits for being all zero is O(n), so the total is
still O(n^2). Still, probably faster than the for_each_online_cpu() scan
I do now.