Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp410254ybi; Wed, 19 Jun 2019 01:28:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNHgXbp7rL7cSCONx6/MJEuSLaTRZI1oPRgj/pw/gl/o2DhqmH4t3DdQX8gSRkvoa9sNE/ X-Received: by 2002:a17:902:b713:: with SMTP id d19mr6759524pls.267.1560932923203; Wed, 19 Jun 2019 01:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560932923; cv=none; d=google.com; s=arc-20160816; b=G97LNrp1ntbUKXLIlya8ITtlY3StO7fvejbp2eQ1LpecFMUFuJhkShjzYKpGP9xjGB JGTsTfzI48Zf6BecdxoOIapx9dqTVDiJJno9+r0VJJEH/w3/lFf+pga5u8gsisAah+vc x1ptwT3bji0ho4l07S0+cJ0fU296sS39QFWmczD3RyP71Sp6EVyNK0O+PweeRM+/RewV TRE1dbMVgNxHZEk0O0TUiypkx4z8RVhJVmm+KFSJw2mR+kbDJam1NwLRJkOlrSv16dyE Gjbiaw3+rI6lFNmZ4NgJt5sehfKmNq0m9acJiA62sbnKRItYdejx+slKv/4hmm1MIBMZ 1oqw== 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=RD0cp/I6H4Z70xlzm0eumdPIsp1N9VldTCe01VvLr18=; b=KDXDERc/IHapRwt4mD/0gLpQm2nyjnxC61DzPF5eSqmzeFqDlxBvGNqNHA938bIsFP /1hCo4g16QSzThCunWkikrKIhsokdk7w31h+XlDBJ/teDACL5akHcOiP7yQQwoOj8TYm qoYNrmICYOwD8jdRcGATZMsCYk+Pw3rEYvrVhzeC/Nn9HxE1ZdEwiDfarheFOX1RsrLJ ngOJr6JX27HsFuqOFlyP3lDgV5MAyCHKqPRQBGclVltph2iCDf6I8v0IvyvcjRabhICb h81V13DA6zy8TiPYv1vlZRHkh2smDaXcCRx+4VtRQPvyYFkZL7usyGWf3xm9YUj+sm6V ev0A== 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 d4si15825317plj.124.2019.06.19.01.28.27; Wed, 19 Jun 2019 01:28:43 -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 S1731239AbfFSI2R (ORCPT + 99 others); Wed, 19 Jun 2019 04:28:17 -0400 Received: from [192.198.146.188] ([192.198.146.188]:13318 "EHLO E6440.gar.corp.intel.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1731134AbfFSI2R (ORCPT ); Wed, 19 Jun 2019 04:28:17 -0400 Received: from E6440.gar.corp.intel.com (localhost [127.0.0.1]) by E6440.gar.corp.intel.com (Postfix) with ESMTP id 414CDC1165; Wed, 19 Jun 2019 16:28:14 +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 v3] platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds Date: Wed, 19 Jun 2019 16:28:01 +0800 Message-Id: <20190619082801.21699-1-harry.pan@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528025727.6014-1-harry.pan@intel.com> References: <20190528025727.6014-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. v3: apply kernel do_div() macro to calculate division Signed-off-by: Harry Pan --- drivers/platform/x86/intel_pmc_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c index f2c621b55f49..ab798efacc85 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,7 +739,9 @@ 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 *= 1000; + do_div(pcstate_count, tsc_khz); + seq_printf(s, "%-8s : %llu\n", map[index].name, pcstate_count); } -- 2.20.1