Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4493843ybi; Mon, 27 May 2019 20:01:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0hWe7jGqmwt7/0Vt3KXIwRhmB+pk2WcKPnl3zpsnLFfsgS8MjATVMo/f0WqG1IT1GnL+j X-Received: by 2002:a62:6341:: with SMTP id x62mr139541884pfb.63.1559012479117; Mon, 27 May 2019 20:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559012479; cv=none; d=google.com; s=arc-20160816; b=j8sMc0WqU6RmlZdL81UDgxKz9Whm+oOiFPSE2/68tvQDSBBoJjwCrpdY0WDeavMaKv cUGc1YbkiRlYDuFCXq7PHJPYv+b0FkBykp0IcLucRidBgRMoE+QXpke5Nl6CBaZhSl+E dEgvfODfDphDVkPUhZ2BbOeL/KjLruuDBSBhhFLee8f2i4/0MuxAVRK21XZe7JCGCco2 isDl4QCC2pEHBIOLABhwrVIB0ATBBIfrfxyyE8JWMaO0ra5hqs7GN4s6DGg4/QVXPwhP wYSguq4IlQ7e+OpN7+doFdQmYk8eFX7VhgvkD165o2HbSIfvmz1TXQd8bvPfHmXVfMul YahA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=qiVOV0QHGvkudmMZ2fNgTrqy3nby4CMyQtFm8t383e8=; b=nnq7b38j9yEBmp6jnYoGSiEUDTV9mXWh/ZIzk81tmlnefdrI86R/eNEMcDXTm3r6QG UFEnW63fdR9tRIlwCY3X/WdTklyKS8iHtOKZDi6Fatp6ppEbhxPeXKXUyK/6V+PfinJy 6lkSW7skjopmC0nF8DG5hWYMe6CS0vqiGcaTwlmuCax2wWcFYgl78k0djcPXUf1/N6h1 IPYW4gOTDl1ELq58EoXcjhwJB0EJ0N5XofQb47RchxDMda7c8VQBW4X1BFIHxfd9ekTW IVpTY9OJ59AAjA3EGWDYaz7Zj5GsxdhIn5gPbwZGVnzhtvuVFgRv0xzD59ypGQzNYnCv 5dSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id u4si18562254plq.193.2019.05.27.20.01.03; Mon, 27 May 2019 20:01:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727811AbfE1C56 (ORCPT + 99 others); Mon, 27 May 2019 22:57:58 -0400 Received: from [192.198.146.186] ([192.198.146.186]:40519 "EHLO E6440.gar.corp.intel.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727525AbfE1C56 (ORCPT ); Mon, 27 May 2019 22:57:58 -0400 Received: from E6440.gar.corp.intel.com (localhost [127.0.0.1]) by E6440.gar.corp.intel.com (Postfix) with ESMTP id 6ED3BC1AF7; Tue, 28 May 2019 10:57:31 +0800 (CST) From: Harry Pan To: LKML Cc: gs0622@gmail.com, Harry Pan , Vishwanath Somayaji , Andy Shevchenko , platform-driver-x86@vger.kernel.org, Rajneesh Bhardwaj , Darren Hart Subject: [PATCH v2] platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds Date: Tue, 28 May 2019 10:57:27 +0800 Message-Id: <20190528025727.6014-1-harry.pan@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190527130811.450-1-harry.pan@intel.com> References: <20190527130811.450-1-harry.pan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refer to the Intel SDM Vol.4, the package C-state residency counters of modern IA micro-architecture are all ticking in TSC frequency, hence we can apply simple math to transform the ticks into microseconds. i.e., residency (ms) = count / tsc_khz residency (us) = count / tsc_khz * 1000 This also aligns to other sysfs debug entries of residency counter in the same metric in microseconds, benefits reading and scripting. v2: restore the accidentally deleted newline, no function change. Signed-off-by: Harry Pan --- drivers/platform/x86/intel_pmc_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c index f2c621b55f49..c78918a7e731 100644 --- a/drivers/platform/x86/intel_pmc_core.c +++ b/drivers/platform/x86/intel_pmc_core.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "intel_pmc_core.h" @@ -738,8 +739,8 @@ static int pmc_core_pkgc_show(struct seq_file *s, void *unused) if (rdmsrl_safe(map[index].bit_mask, &pcstate_count)) continue; - seq_printf(s, "%-8s : 0x%llx\n", map[index].name, - pcstate_count); + seq_printf(s, "%-8s : %llu\n", map[index].name, + pcstate_count * 1000 / tsc_khz); } return 0; -- 2.20.1