mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chen Yu <yu.c.chen@intel.com>
To: youling257 <youling257@gmail.com>, Kurt Garloff <kurt@garloff.de>,
	Bingsong Si <owen.si@ucloud.cn>,
	"Artem S . Tashkinov" <aros@gmx.com>
Cc: Terry Bowman <terry.bowman@amd.com>,
	Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>,
	Calvin Walton <calvin.walton@kepstin.ca>,
	Borislav Petkov <bp@suse.de>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Chen Yu <yu.c.chen@intel.com>
Subject: [PATCH 1/2] tools/power/turbostat: Fix turbostat for AMD Zen CPUs
Date: Wed, 28 Apr 2021 17:09:03 +0800	[thread overview]
Message-ID: <3172c45b6e06627e19f3a6f71be7746d89ee8c2e.1619600637.git.yu.c.chen@intel.com> (raw)
In-Reply-To: <cover.1619600637.git.yu.c.chen@intel.com>

From: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>

It was reported that on Zen+ system turbostat started exiting,
which was tracked down to the MSR_PKG_ENERGY_STAT read failing because
offset_to_idx wasn't returning a non-negative index.

This patch combined the modification from Bingsong Si and
Bas Nieuwenhuizen and addd the MSR to the index system as alternative for
MSR_PKG_ENERGY_STATUS.

Fixes: 9972d5d84d76 ("tools/power turbostat: Enable accumulate RAPL display")
Reported-by: youling257 <youling257@gmail.com>
Tested-by: youling257 <youling257@gmail.com>
Tested-by: Kurt Garloff <kurt@garloff.de>
Tested-by: Bingsong Si <owen.si@ucloud.cn>
Tested-by: Artem S. Tashkinov <aros@gmx.com>
Co-developed-by: Bingsong Si <owen.si@ucloud.cn>
Co-developed-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
---
 tools/power/x86/turbostat/turbostat.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 5939615265f1..37759d6c463d 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -297,7 +297,10 @@ int idx_to_offset(int idx)
 
 	switch (idx) {
 	case IDX_PKG_ENERGY:
-		offset = MSR_PKG_ENERGY_STATUS;
+		if (do_rapl & RAPL_AMD_F17H)
+			offset = MSR_PKG_ENERGY_STAT;
+		else
+			offset = MSR_PKG_ENERGY_STATUS;
 		break;
 	case IDX_DRAM_ENERGY:
 		offset = MSR_DRAM_ENERGY_STATUS;
@@ -326,6 +329,7 @@ int offset_to_idx(int offset)
 
 	switch (offset) {
 	case MSR_PKG_ENERGY_STATUS:
+	case MSR_PKG_ENERGY_STAT:
 		idx = IDX_PKG_ENERGY;
 		break;
 	case MSR_DRAM_ENERGY_STATUS:
@@ -353,7 +357,7 @@ int idx_valid(int idx)
 {
 	switch (idx) {
 	case IDX_PKG_ENERGY:
-		return do_rapl & RAPL_PKG;
+		return do_rapl & (RAPL_PKG | RAPL_AMD_F17H);
 	case IDX_DRAM_ENERGY:
 		return do_rapl & RAPL_DRAM;
 	case IDX_PP0_ENERGY:
-- 
2.25.1


  reply	other threads:[~2021-04-28  9:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28  9:08 [PATCH 0/2] tools/power/turbostat: Fix long time duration RAPL calculation Chen Yu
2021-04-28  9:09 ` Chen Yu [this message]
2021-04-28  9:09 ` [PATCH 2/2] tools/power turbostat: Fix offset overflow issue in index converting Chen Yu
2021-04-29 19:47 ` [PATCH 0/2] tools/power/turbostat: Fix long time duration RAPL calculation Terry Bowman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3172c45b6e06627e19f3a6f71be7746d89ee8c2e.1619600637.git.yu.c.chen@intel.com \
    --to=yu.c.chen@intel.com \
    --cc=aros@gmx.com \
    --cc=bas@basnieuwenhuizen.nl \
    --cc=bp@suse.de \
    --cc=calvin.walton@kepstin.ca \
    --cc=kurt@garloff.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=owen.si@ucloud.cn \
    --cc=terry.bowman@amd.com \
    --cc=youling257@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®