Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933570Ab2FHONT (ORCPT ); Fri, 8 Jun 2012 10:13:19 -0400 Received: from casper.infradead.org ([85.118.1.10]:44931 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932655Ab2FHONS (ORCPT ); Fri, 8 Jun 2012 10:13:18 -0400 Subject: Re: [PATCH] perf/x86: check ucode before disabling PEBS on SandyBridge From: Peter Zijlstra To: Stephane Eranian Cc: Ingo Molnar , linux-kernel@vger.kernel.org, andi@firstfloor.org, mingo@elte.hu, ming.m.lin@intel.com, Andreas Herrmann , Borislav Petkov , Dimitri Sivanich , Dmitry Adamushko In-Reply-To: References: <20120607071531.GA4849@quad> <1339064319.23343.13.camel@twins> <1339065932.23343.18.camel@twins> <1339067757.23343.21.camel@twins> <20120608093513.GA22520@gmail.com> <1339149613.23343.52.camel@twins> <1339161972.2507.13.camel@laptop> Content-Type: text/plain; charset="UTF-8" Date: Fri, 08 Jun 2012 16:13:05 +0200 Message-ID: <1339164785.2507.23.camel@laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2702 Lines: 77 On Fri, 2012-06-08 at 16:07 +0200, Stephane Eranian wrote: > > The very worst is that it does per-cpu micro-code updates, not machine > > wide. This results in it being able to have different revisions on > > different cpus. This in turn makes the below O(n^2) :/ > > > But it's not like this is a frequent operation either... Still Dimitri did a patch 938179b4f8cf8 ("x86: Improve Intel microcode loader performance") to improve the performance of it, so apparently they do care some. > > --- > > diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h > > index 4ebe157..1cd2dc5 100644 > > --- a/arch/x86/include/asm/microcode.h > > +++ b/arch/x86/include/asm/microcode.h > > @@ -63,4 +64,15 @@ static inline struct microcode_ops * __init init_amd_microcode(void) > > static inline void __exit exit_amd_microcode(void) {} > > #endif > > > > +extern struct blocking_notifier_head microcode_notifier; > > + > That is a problem because microcode can be compiled as a module. > When I tried compiling your patch I got undefined for this notifier because > I have microcode update as a module... > > > +#define MICROCODE_CAN_UPDATE 0x01 > > +#define MICROCODE_UPDATED 0x02 > > + > > +#define microcode_notifier(fn) \ > > +do { \ > > + static struct notifier_block fn##_nb ={ .notifier_call = fn }; \ > > + blocking_notifier_chain_register(µcode_notifier, &fn##_nb);\ > > +} while (0) > > + > > #endif /* _ASM_X86_MICROCODE_H */ But that's ourside of CONFIG_MICROCODE and... > > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > > index f4b9b80..98b5b5c 100644 > > --- a/arch/x86/kernel/setup.c > > +++ b/arch/x86/kernel/setup.c > > @@ -68,6 +68,7 @@ > > #include > > #include > > #include > > +#include > > > > #include