Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp447595pxa; Fri, 14 Aug 2020 08:24:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv2kokeatCE+IK1o+t5fN+31DJlYMmQsUbWRrR+qaCQCOJwOjMnfs/sfHpcxVJ3U4Sqizh X-Received: by 2002:a17:906:3b8d:: with SMTP id u13mr3025649ejf.205.1597418679559; Fri, 14 Aug 2020 08:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597418679; cv=none; d=google.com; s=arc-20160816; b=jj6oX+kCJA0x3D6VJgN77pUb2OLw97sreeBN/vkkVGsvLFDU8bUnottQJ9jkpwa7tq hoxtqa8lIN0+Fris/VEY46yl0PnQx9T9Pqnnw0e1o1KAXtCv8zqLChR589jupW+Lys9Y K7Z+msDASgeDRFpT2boJgON8SNZQuujyiU32XEa+r0ADBxwDibwX1BSyZk2pD3bSuFif vNbiN1XYLZ0RTbcye+7t2xhGwPm62Kkfctgs6xR7epuVVcN+SV7ftaSEYw5lAxNJ/Ij3 j/3vloP/nrLQ95eOooCwgJ13l6CPB+p5vcSFlfHlJwJ+7nbcJ0gUu7jIbIIdI1E0Jv3E S+Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=bdANNQMuUMseVByBrH26u9LG+YAJnlk/Tjr7L7O4PIs=; b=a9csR0dIK+Ttl3jnzqiK4XBINqvqURrROd1MoBR0+0wBIo+dxIU36149tOY57KK+xL eWcFJsnPNQuZV1Q0Se3CW6sPdRJZPhCSn65U3VErOSVd0w8SYDcgLvoqOsMNGX9ar0Q6 ECIlDhy115rjYKwLKTBJqe8V+O/wICqDiWteKAIXFzdQUH2RQ/8u3y+8vFVSplUCHXeR CunmD9CDvWWo3CqUMw9zommV8YiYHySjH+VdrVYEm2Rf/UsOI5TXrc0bxDYrgYfGeV5O kQAzxMELuoedjGxNS4IFc2uYYSNM+YNQ994Jx0SCYD8m+xj6jpU0AHe09h/vwQI9/u+M jlzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=QnAG3gq4; dkim=neutral (no key) header.i=@vger.kernel.org; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l11si5579298edr.73.2020.08.14.08.24.15; Fri, 14 Aug 2020 08:24:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=QnAG3gq4; dkim=neutral (no key) header.i=@vger.kernel.org; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726897AbgHNPXh (ORCPT + 99 others); Fri, 14 Aug 2020 11:23:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbgHNPXf (ORCPT ); Fri, 14 Aug 2020 11:23:35 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A421C061385; Fri, 14 Aug 2020 08:23:35 -0700 (PDT) Date: Fri, 14 Aug 2020 15:23:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1597418610; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bdANNQMuUMseVByBrH26u9LG+YAJnlk/Tjr7L7O4PIs=; b=QnAG3gq4gobyETTNKHTW1dco1DG94ooUMIwM0SzdbQifCVz8X/ldwsf5Mkg8uKnnItB3gn yllx5pQRMrgcw4ebsowT4W8yDkQsDpaNTQr+kxiB7HLOyEs0pmjS1RSjzx+QE2ya1n1mTV pS7MjwgaVhrr4PDsUBqYGe3QyF0ucllBNQPhJ31N2uQHyzPHIH8NILBuZgFLfva++6pxX7 acJunWiUIRO7y/6Tf74lkOoiA9H0P2A3YX91t+iMg7puNQ1aaijVewl+jRhMK+lPHcvn8p etvizoncWPeB9t/loD1k3gL8EnROwLt0sCSYoQ5aE1dAw477y17V6p0coDuynA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1597418610; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bdANNQMuUMseVByBrH26u9LG+YAJnlk/Tjr7L7O4PIs=; b=voOAM7NTl/YqbQ5p1JFNMaXcq/RxVFNzpuoPb1uMAftB/qttKYfcSqBKSukvhNQIxR0Kf/ x+SEl9eOAvDcgIAQ== From: "tip-bot2 for Zhang Rui" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf/x86/rapl: Support multiple RAPL unit quirks Cc: Zhang Rui , Ingo Molnar , Kan Liang , Len Brown , x86 , LKML In-Reply-To: <20200811153149.12242-3-rui.zhang@intel.com> References: <20200811153149.12242-3-rui.zhang@intel.com> MIME-Version: 1.0 Message-ID: <159741860945.3192.12569144568856845688.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/urgent branch of tip: Commit-ID: 74f41adab0f4a61857833e1b6fa8e9ad12c251b6 Gitweb: https://git.kernel.org/tip/74f41adab0f4a61857833e1b6fa8e9ad12c251b6 Author: Zhang Rui AuthorDate: Tue, 11 Aug 2020 23:31:48 +08:00 Committer: Ingo Molnar CommitterDate: Fri, 14 Aug 2020 12:35:12 +02:00 perf/x86/rapl: Support multiple RAPL unit quirks There will be more platforms with different fixed energy units. Enhance the code to support different RAPL unit quirks for different platforms. Signed-off-by: Zhang Rui Signed-off-by: Ingo Molnar Reviewed-by: Kan Liang Reviewed-by: Len Brown Link: https://lore.kernel.org/r/20200811153149.12242-3-rui.zhang@intel.com --- arch/x86/events/rapl.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index e972383..d0002eb 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -130,11 +130,16 @@ struct rapl_pmus { struct rapl_pmu *pmus[]; }; +enum rapl_unit_quirk { + RAPL_UNIT_QUIRK_NONE, + RAPL_UNIT_QUIRK_INTEL_HSW, +}; + struct rapl_model { struct perf_msr *rapl_msrs; unsigned long events; unsigned int msr_power_unit; - bool apply_quirk; + enum rapl_unit_quirk unit_quirk; }; /* 1/2^hw_unit Joule */ @@ -612,14 +617,20 @@ static int rapl_check_hw_unit(struct rapl_model *rm) for (i = 0; i < NR_RAPL_DOMAINS; i++) rapl_hw_unit[i] = (msr_rapl_power_unit_bits >> 8) & 0x1FULL; + switch (rm->unit_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 (rm->apply_quirk) + case RAPL_UNIT_QUIRK_INTEL_HSW: rapl_hw_unit[PERF_RAPL_RAM] = 16; + break; + default: + break; + } + /* * Calculate the timer rate: @@ -698,7 +709,6 @@ static struct rapl_model model_snb = { .events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_PP1), - .apply_quirk = false, .msr_power_unit = MSR_RAPL_POWER_UNIT, .rapl_msrs = intel_rapl_msrs, }; @@ -707,7 +717,6 @@ static struct rapl_model model_snbep = { .events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM), - .apply_quirk = false, .msr_power_unit = MSR_RAPL_POWER_UNIT, .rapl_msrs = intel_rapl_msrs, }; @@ -717,7 +726,6 @@ static struct rapl_model model_hsw = { BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM) | BIT(PERF_RAPL_PP1), - .apply_quirk = false, .msr_power_unit = MSR_RAPL_POWER_UNIT, .rapl_msrs = intel_rapl_msrs, }; @@ -726,7 +734,7 @@ static struct rapl_model model_hsx = { .events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM), - .apply_quirk = true, + .unit_quirk = RAPL_UNIT_QUIRK_INTEL_HSW, .msr_power_unit = MSR_RAPL_POWER_UNIT, .rapl_msrs = intel_rapl_msrs, }; @@ -734,7 +742,7 @@ static struct rapl_model model_hsx = { static struct rapl_model model_knl = { .events = BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM), - .apply_quirk = true, + .unit_quirk = RAPL_UNIT_QUIRK_INTEL_HSW, .msr_power_unit = MSR_RAPL_POWER_UNIT, .rapl_msrs = intel_rapl_msrs, }; @@ -745,14 +753,12 @@ static struct rapl_model model_skl = { BIT(PERF_RAPL_RAM) | BIT(PERF_RAPL_PP1) | BIT(PERF_RAPL_PSYS), - .apply_quirk = false, .msr_power_unit = MSR_RAPL_POWER_UNIT, .rapl_msrs = intel_rapl_msrs, }; static struct rapl_model model_amd_fam17h = { .events = BIT(PERF_RAPL_PKG), - .apply_quirk = false, .msr_power_unit = MSR_AMD_RAPL_POWER_UNIT, .rapl_msrs = amd_rapl_msrs, };