From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932787AbcCHRh7 (ORCPT ); Tue, 8 Mar 2016 12:37:59 -0500 Received: from torg.zytor.com ([198.137.202.12]:35400 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754148AbcCHRhu (ORCPT ); Tue, 8 Mar 2016 12:37:50 -0500 Date: Tue, 8 Mar 2016 09:36:39 -0800 From: tip-bot for Borislav Petkov Message-ID: Cc: andi.kleen@intel.com, harish.chegondi@intel.com, tglx@linutronix.de, bp@alien8.de, mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, eranian@google.com, torvalds@linux-foundation.org, acme@redhat.com, jacob.jun.pan@linux.intel.com, bp@suse.de, jolsa@redhat.com, kan.liang@intel.com, hpa@zytor.com, vincent.weaver@maine.edu Reply-To: peterz@infradead.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, andi.kleen@intel.com, tglx@linutronix.de, bp@alien8.de, harish.chegondi@intel.com, mingo@kernel.org, hpa@zytor.com, jolsa@redhat.com, kan.liang@intel.com, vincent.weaver@maine.edu, eranian@google.com, acme@redhat.com, torvalds@linux-foundation.org, jacob.jun.pan@linux.intel.com, bp@suse.de In-Reply-To: <20160308164041.GF16568@pd.tnic> References: <20160308164041.GF16568@pd.tnic> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf/x86/intel/rapl: Simplify quirk handling even more Git-Commit-ID: 7a8698058ae493ae53b1a8a2fa23d2e37000d73e 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: 7a8698058ae493ae53b1a8a2fa23d2e37000d73e Gitweb: http://git.kernel.org/tip/7a8698058ae493ae53b1a8a2fa23d2e37000d73e Author: Borislav Petkov AuthorDate: Tue, 8 Mar 2016 17:40:41 +0100 Committer: Ingo Molnar CommitDate: Tue, 8 Mar 2016 17:49:52 +0100 perf/x86/intel/rapl: Simplify quirk handling even more Drop the quirk() function pointer in favor of a simple boolean which says whether the quirk should be applied or not. Update comment while at it. Signed-off-by: Borislav Petkov Cc: Alexander Shishkin Cc: Andi Kleen Cc: Arnaldo Carvalho de Melo Cc: Harish Chegondi Cc: Jacob Pan Cc: Jiri Olsa Cc: Kan Liang Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Cc: linux-tip-commits@vger.kernel.org Link: http://lkml.kernel.org/r/20160308164041.GF16568@pd.tnic Signed-off-by: Ingo Molnar --- arch/x86/events/intel/rapl.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c index 019e541..b834a3f 100644 --- a/arch/x86/events/intel/rapl.c +++ b/arch/x86/events/intel/rapl.c @@ -592,18 +592,7 @@ static int rapl_cpu_notifier(struct notifier_block *self, return NOTIFY_OK; } -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)) +static int rapl_check_hw_unit(bool apply_quirk) { u64 msr_rapl_power_unit_bits; int i; @@ -614,9 +603,14 @@ static int rapl_check_hw_unit(void (*quirk)(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(); + /* + * DRAM domain on HSW server and KNL has fixed energy unit which can be + * different than the unit from power unit MSR. See + * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2 + * of 2. Datasheet, September 2014, Reference Number: 330784-001 " + */ + if (apply_quirk) + rapl_hw_unit[RAPL_IDX_RAM_NRG_STAT] = 16; /* * Calculate the timer rate: @@ -704,7 +698,7 @@ static const struct x86_cpu_id rapl_cpu_match[] __initconst = { static int __init rapl_pmu_init(void) { - void (*quirk)(void) = NULL; + bool apply_quirk = false; int ret; if (!x86_match_cpu(rapl_cpu_match)) @@ -717,7 +711,7 @@ static int __init rapl_pmu_init(void) rapl_pmu_events_group.attrs = rapl_events_cln_attr; break; case 63: /* Haswell-Server */ - quirk = rapl_hsw_server_quirk; + apply_quirk = true; rapl_cntr_mask = RAPL_IDX_SRV; rapl_pmu_events_group.attrs = rapl_events_srv_attr; break; @@ -733,7 +727,7 @@ static int __init rapl_pmu_init(void) rapl_pmu_events_group.attrs = rapl_events_srv_attr; break; case 87: /* Knights Landing */ - quirk = rapl_hsw_server_quirk; + apply_quirk = true; rapl_cntr_mask = RAPL_IDX_KNL; rapl_pmu_events_group.attrs = rapl_events_knl_attr; break; @@ -741,7 +735,7 @@ static int __init rapl_pmu_init(void) return -ENODEV; } - ret = rapl_check_hw_unit(quirk); + ret = rapl_check_hw_unit(apply_quirk); if (ret) return ret;