From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754387AbcB2LLj (ORCPT ); Mon, 29 Feb 2016 06:11:39 -0500 Received: from torg.zytor.com ([198.137.202.12]:53864 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753514AbcB2LLf (ORCPT ); Mon, 29 Feb 2016 06:11:35 -0500 Date: Mon, 29 Feb 2016 03:10:28 -0800 From: tip-bot for Thomas Gleixner Message-ID: Cc: torvalds@linux-foundation.org, mingo@kernel.org, eranian@google.com, harish.chegondi@intel.com, acme@redhat.com, jolsa@redhat.com, tglx@linutronix.de, peterz@infradead.org, hpa@zytor.com, andi.kleen@intel.com, vincent.weaver@maine.edu, kan.liang@intel.com, jacob.jun.pan@linux.intel.com, linux-kernel@vger.kernel.org, bp@alien8.de Reply-To: acme@redhat.com, jolsa@redhat.com, torvalds@linux-foundation.org, mingo@kernel.org, eranian@google.com, harish.chegondi@intel.com, kan.liang@intel.com, jacob.jun.pan@linux.intel.com, linux-kernel@vger.kernel.org, bp@alien8.de, tglx@linutronix.de, peterz@infradead.org, hpa@zytor.com, andi.kleen@intel.com, vincent.weaver@maine.edu In-Reply-To: <20160222221012.311639465@linutronix.de> References: <20160222221012.311639465@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf/x86/intel/rapl: Sanitize the quirk handling Git-Commit-ID: b8b3319a471b2df35ae0a8fe94223638468e9ca4 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: b8b3319a471b2df35ae0a8fe94223638468e9ca4 Gitweb: http://git.kernel.org/tip/b8b3319a471b2df35ae0a8fe94223638468e9ca4 Author: Thomas Gleixner AuthorDate: Mon, 22 Feb 2016 22:19:22 +0000 Committer: Ingo Molnar CommitDate: Mon, 29 Feb 2016 09:35:22 +0100 perf/x86/intel/rapl: Sanitize the quirk handling There is no point in having a quirk machinery for a single possible function. Get rid of it and move the quirk to a place where it actually makes sense. Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Cc: Andi Kleen Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: Harish Chegondi Cc: Jacob Pan Cc: Jiri Olsa Cc: Kan Liang Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Vince Weaver Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/20160222221012.311639465@linutronix.de Signed-off-by: Ingo Molnar --- arch/x86/events/intel/rapl.c | 49 +++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c index 98b04d2..976558a 100644 --- a/arch/x86/events/intel/rapl.c +++ b/arch/x86/events/intel/rapl.c @@ -133,7 +133,6 @@ static int rapl_cntr_mask; static DEFINE_PER_CPU(struct rapl_pmu *, rapl_pmu); static DEFINE_PER_CPU(struct rapl_pmu *, rapl_pmu_to_free); -static struct x86_pmu_quirk *rapl_quirks; static inline u64 rapl_read_counter(struct perf_event *event) { u64 raw; @@ -141,15 +140,6 @@ static inline u64 rapl_read_counter(struct perf_event *event) return raw; } -#define rapl_add_quirk(func_) \ -do { \ - static struct x86_pmu_quirk __quirk __initdata = { \ - .func = func_, \ - }; \ - __quirk.next = rapl_quirks; \ - rapl_quirks = &__quirk; \ -} while (0) - static inline u64 rapl_scale(u64 v, int cfg) { if (cfg > NR_RAPL_DOMAINS) { @@ -564,17 +554,6 @@ static void rapl_cpu_init(int cpu) cpumask_set_cpu(cpu, &rapl_cpu_mask); } -static __init void rapl_hsw_server_quirk(void) -{ - /* - * DRAM domain on HSW server has fixed energy unit which can be - * different than the unit from power unit MSR. - * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2 - * of 2. Datasheet, September 2014, Reference Number: 330784-001 " - */ - rapl_hw_unit[RAPL_IDX_RAM_NRG_STAT] = 16; -} - static int rapl_cpu_prepare(int cpu) { struct rapl_pmu *pmu = per_cpu(rapl_pmu, cpu); @@ -672,7 +651,18 @@ static int rapl_cpu_notifier(struct notifier_block *self, return NOTIFY_OK; } -static int rapl_check_hw_unit(void) +static __init void rapl_hsw_server_quirk(void) +{ + /* + * DRAM domain on HSW server has fixed energy unit which can be + * different than the unit from power unit MSR. + * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2 + * of 2. Datasheet, September 2014, Reference Number: 330784-001 " + */ + rapl_hw_unit[RAPL_IDX_RAM_NRG_STAT] = 16; +} + +static int rapl_check_hw_unit(void (*quirk)(void)) { u64 msr_rapl_power_unit_bits; int i; @@ -683,6 +673,9 @@ static int rapl_check_hw_unit(void) for (i = 0; i < NR_RAPL_DOMAINS; i++) rapl_hw_unit[i] = (msr_rapl_power_unit_bits >> 8) & 0x1FULL; + /* Apply cpu model quirk */ + if (quirk) + quirk(); return 0; } @@ -701,9 +694,9 @@ static const struct x86_cpu_id rapl_cpu_match[] = { static int __init rapl_pmu_init(void) { + void (*quirk)(void) = NULL; struct rapl_pmu *pmu; int cpu, ret; - struct x86_pmu_quirk *quirk; int i; /* @@ -720,7 +713,7 @@ static int __init rapl_pmu_init(void) rapl_pmu_events_group.attrs = rapl_events_cln_attr; break; case 63: /* Haswell-Server */ - rapl_add_quirk(rapl_hsw_server_quirk); + quirk = rapl_hsw_server_quirk; rapl_cntr_mask = RAPL_IDX_SRV; rapl_pmu_events_group.attrs = rapl_events_srv_attr; break; @@ -736,7 +729,7 @@ static int __init rapl_pmu_init(void) rapl_pmu_events_group.attrs = rapl_events_srv_attr; break; case 87: /* Knights Landing */ - rapl_add_quirk(rapl_hsw_server_quirk); + quirk = rapl_hsw_server_quirk; rapl_cntr_mask = RAPL_IDX_KNL; rapl_pmu_events_group.attrs = rapl_events_knl_attr; break; @@ -745,14 +738,10 @@ static int __init rapl_pmu_init(void) return -ENODEV; } - ret = rapl_check_hw_unit(); + ret = rapl_check_hw_unit(quirk); if (ret) return ret; - /* run cpu model quirks */ - for (quirk = rapl_quirks; quirk; quirk = quirk->next) - quirk->func(); - cpu_notifier_register_begin(); for_each_online_cpu(cpu) {