Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp185841pxy; Wed, 28 Apr 2021 02:07:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5XVBv+1Sz/h1rRvjUHYd2i4Yjqop6FxQhfYfqGrTAy37pOexdAdyi0uM+UutszdYlmFk8 X-Received: by 2002:a05:6402:2366:: with SMTP id a6mr9886337eda.10.1619600823479; Wed, 28 Apr 2021 02:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619600823; cv=none; d=google.com; s=arc-20160816; b=bs9dKBMg/pTsN+H8VGhPYJvuLH4pCURfHjK4eLEflpFRzJjP3ASFJ0DH4nnoBUDxMR OnJsKeMDl+EEt3ZM7/R5+qgbNr40Cxq+R2saEUH7l6psehS4MXioknLkKbhW9dzxtMBQ vO/98ikUeoROxy12BRzgVxHZweU9GB9g05BrS9JjBFFU3gFmcH9DRY92QLT0YWg0zK8n uyQbsoDhGN5FDAg1+JuKRm2JE3FfIl165wH06On/7bi96M1FFzEaIbw3RnIv5BWd+dtw PDaFkdvYjQVKHUwtn91D9HGRLWGbMft1of00mHTL6H673orSHj2x6e+z3LzMOVkfit6j qRhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=WQ4z/XypmyWCFilhKR6tdpuipQtzhqkctP8JpUc9agY=; b=NKELDCeFPvZpt3ye8JFFN2VfLEhjehIAeYJgYL9zs38DrmuzouX1bo1NlMdwRTjULR 6aWJ3olxTaZb2+IyQ2WhtXkzlvjid94/cCeFbA4jjPkQWFFPjWGEnm1x4b55Y21i0cHo 80o2yeUdWkmOqBQJGsF5jmWsyMTu9kuxtmunHsB0we8IFx30zn+RR9Xfl5d8WFu/Ra1r l4RC0Tc3o4cQxf9jEf6ubyq+PcqVAqzrSpnd/ULdprbxxhtqJ06IAJqmm8QP5Ic45JXd l5cW9Z/hohbVQhp014ltP+eS57wJ56CNhLO3N2PDxVz1KBW9wS+aDkdFQ71ESCNPR5pY N9EQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n17si2474367ejb.145.2021.04.28.02.06.39; Wed, 28 Apr 2021 02:07:03 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237919AbhD1JGP (ORCPT + 99 others); Wed, 28 Apr 2021 05:06:15 -0400 Received: from mga05.intel.com ([192.55.52.43]:46664 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbhD1JGH (ORCPT ); Wed, 28 Apr 2021 05:06:07 -0400 IronPort-SDR: XpYaQ+wPj9yDF9Oxd+PDgusaFFj7lB9J3G+zSzM24T8YV41u1LFTI0KSNcc/+9stAuDImjDWDh 1CO9cCj1CNZw== X-IronPort-AV: E=McAfee;i="6200,9189,9967"; a="282031124" X-IronPort-AV: E=Sophos;i="5.82,257,1613462400"; d="scan'208";a="282031124" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2021 02:05:23 -0700 IronPort-SDR: 5Aoaam7uvDmGnboMp2m4iJXVJ8msCtP8Aj6SHv7pgkoOjkwJqUzomvWFvz7pNjJu4Ieyb7OaZg QuPOQqcSLDxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,257,1613462400"; d="scan'208";a="458084228" Received: from chenyu-desktop.sh.intel.com ([10.239.158.173]) by fmsmga002.fm.intel.com with ESMTP; 28 Apr 2021 02:05:20 -0700 From: Chen Yu To: youling257 , Kurt Garloff , Bingsong Si , "Artem S . Tashkinov" Cc: Terry Bowman , Bas Nieuwenhuizen , Calvin Walton , Borislav Petkov , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Yu Subject: [PATCH 1/2] tools/power/turbostat: Fix turbostat for AMD Zen CPUs Date: Wed, 28 Apr 2021 17:09:03 +0800 Message-Id: <3172c45b6e06627e19f3a6f71be7746d89ee8c2e.1619600637.git.yu.c.chen@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bas Nieuwenhuizen 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 Tested-by: youling257 Tested-by: Kurt Garloff Tested-by: Bingsong Si Tested-by: Artem S. Tashkinov Co-developed-by: Bingsong Si Co-developed-by: Terry Bowman Reviewed-by: Chen Yu Signed-off-by: Bas Nieuwenhuizen --- 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