Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp194506ybm; Wed, 27 May 2020 23:54:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWNDXriLvsEmbJr/7b4Yi1eTJrvYpALoVUjRCu79IekhpGt6uoZNZQgtwHknyuOIwmRuo0 X-Received: by 2002:a05:6402:2c4:: with SMTP id b4mr1605353edx.331.1590648879018; Wed, 27 May 2020 23:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590648879; cv=none; d=google.com; s=arc-20160816; b=CfSkQeHYPZmCzybaoPs9wH66D9zISFenqBApUCr0tumZK0AJmV1ydxMc98ZLDihE0z W+8rZGuGEaGxxiskJIUpVRyIfpyLEOsMSecaCdWtnrfb9uDDZytA7QeLrpYpr3XFmgZJ E1j6LdE/NQUKQRua49G+tMS/SA/LrLQChEOHpSWpaydiLxqqLHTkGCqHSCzdBVf+0Tu5 jkBOq9GI5qGXnrbhgZfbGAfFkR2C/nwv9tuR3DerYkBAUU0VeykedzbdoiZCP16GiAFd +CN6fX1PVv5V7HTsAMysRskDoHBy7t445ZdL/r00f2iSYLxF13Z33qgYciybPQPsx9h4 BFdQ== 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:date; bh=NCI8p6hxSwbcH6W1Ys7CYiegJXUrPj+zsluQq2/a66w=; b=jXPWzpLxGLbITIm/mXv0d07guaQF2xSXnmfHReIwqJRj/MqnVaSVS5AhMIWCrREQjV mfmzTdkzNFZMLdoebuyD2QF93+cy5SzYMnMwQvvRL3zijclniOkmUYz917y+YKLi+W3P rmWFKlu06xZrsWnNv2gppdLY1HZWGeMqRicrg/oVrDEqYKMhVjjKH21un79+3IB2rzbl U3KL0385FILiKfC0p5ggLkXLfeY+LPLC8hB/t/BA6V7cSn5Zsc8h6wJE7qSlxMeiorOv ROk0N5GYKfywDyI+wl9UXoq94oRO4ImSkpUCkH08q6jO9rmyaRx6vVbouFcxsD2+ZKQe 9+/w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t10si3303184ejr.589.2020.05.27.23.54.16; Wed, 27 May 2020 23:54: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725920AbgE1GtF (ORCPT + 99 others); Thu, 28 May 2020 02:49:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbgE1GtE (ORCPT ); Thu, 28 May 2020 02:49:04 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68EB7C05BD1E; Wed, 27 May 2020 23:49:04 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jeCLd-0008AN-Ar; Thu, 28 May 2020 08:49:01 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id C3D491C0051; Thu, 28 May 2020 08:49:00 +0200 (CEST) Date: Thu, 28 May 2020 06:49:00 -0000 From: "tip-bot2 for Stephane Eranian" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86/rapl: Add AMD Fam17h RAPL support Cc: Stephane Eranian , Ingo Molnar , x86 , LKML In-Reply-To: <20200527224659.206129-6-eranian@google.com> References: <20200527224659.206129-6-eranian@google.com> MIME-Version: 1.0 Message-ID: <159064854059.17951.6886415717644163423.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 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/core branch of tip: Commit-ID: 5cde265384cad739b162cf08afba6da8857778bd Gitweb: https://git.kernel.org/tip/5cde265384cad739b162cf08afba6da8857778bd Author: Stephane Eranian AuthorDate: Wed, 27 May 2020 15:46:59 -07:00 Committer: Ingo Molnar CommitterDate: Thu, 28 May 2020 07:58:56 +02:00 perf/x86/rapl: Add AMD Fam17h RAPL support This patch enables AMD Fam17h RAPL support for the Package level metric. The support is as per AMD Fam17h Model31h (Zen2) and model 00-ffh (Zen1) PPR. The same output is available via the energy-pkg pseudo event: $ perf stat -a -I 1000 --per-socket -e power/energy-pkg/ Signed-off-by: Stephane Eranian Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20200527224659.206129-6-eranian@google.com --- arch/x86/events/rapl.c | 18 ++++++++++++++++++ arch/x86/include/asm/msr-index.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index 8d17af4..0f2bf59 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -537,6 +537,16 @@ static struct perf_msr intel_rapl_msrs[] = { [PERF_RAPL_PSYS] = { MSR_PLATFORM_ENERGY_STATUS, &rapl_events_psys_group, test_msr }, }; +/* + * Force to PERF_RAPL_MAX size due to: + * - perf_msr_probe(PERF_RAPL_MAX) + * - want to use same event codes across both architectures + */ +static struct perf_msr amd_rapl_msrs[PERF_RAPL_MAX] = { + [PERF_RAPL_PKG] = { MSR_AMD_PKG_ENERGY_STATUS, &rapl_events_pkg_group, test_msr }, +}; + + static int rapl_cpu_offline(unsigned int cpu) { struct rapl_pmu *pmu = cpu_to_rapl_pmu(cpu); @@ -740,6 +750,13 @@ static struct rapl_model model_skl = { .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, +}; + static const struct x86_cpu_id rapl_model_match[] __initconst = { X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE, &model_snb), X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE_X, &model_snbep), @@ -770,6 +787,7 @@ static const struct x86_cpu_id rapl_model_match[] __initconst = { X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, &model_hsx), X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE_L, &model_skl), X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE, &model_skl), + X86_MATCH_VENDOR_FAM(AMD, 0x17, &model_amd_fam17h), {}, }; MODULE_DEVICE_TABLE(x86cpu, rapl_model_match); diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 12c9684..ef452b8 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -301,6 +301,9 @@ #define MSR_PP1_ENERGY_STATUS 0x00000641 #define MSR_PP1_POLICY 0x00000642 +#define MSR_AMD_PKG_ENERGY_STATUS 0xc001029b +#define MSR_AMD_RAPL_POWER_UNIT 0xc0010299 + /* Config TDP MSRs */ #define MSR_CONFIG_TDP_NOMINAL 0x00000648 #define MSR_CONFIG_TDP_LEVEL_1 0x00000649