Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp97019ybi; Sat, 29 Jun 2019 06:24:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNJ2NO96RxD/cUlSni/wYaBSkaQm/TnbVHkVY2MGUGyDKuLVn7YxYukHL1mbYLAsvYy5P/ X-Received: by 2002:a17:90a:db44:: with SMTP id u4mr19438486pjx.52.1561814688970; Sat, 29 Jun 2019 06:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561814688; cv=none; d=google.com; s=arc-20160816; b=TIPbn+d5D51qyhWNdQrStqxt5F+fkpTeEcQPRtBW/O0HOC5nh0N5q0SM14RB6XT/Fx rIxIRxRlLCk7sOfhEAqo8irVd3pprrEZmx+9KJnEJjbNQyNWZkURgeIul76i+TJZAh+H Z/hMQOIyIzYkbKTQGNgQmYbW2AFNHGZTwev4h6ax3yjhRpSsadr8N9rkLk77Im3ZJL5F 2Plg23mJ8ZcQJW45sxHnUJyUenOVWRZ4DXF8f7308JyfUdbRgORuwt5YzkXinxoSHScx V2v3yz7YF8dHSKXksWMc3yxobbuiI4EcRv+Yvx5e2WUkfNOrptXe944ALvP60A4KK0tv RMRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=GyjmIieAkSvtFPJ2RM/QvCR+edPTBd5UDZcV9pbUH70=; b=xUVcIfoq4C0Ep51l3poZmEpjwm/wZ9kFSnYq0p61EsvkkuuFxsGW1/+ae91Peqq19R hXSvVrWG7qCJu9CT3jF214r9D/klOavIEQofsiI39vVQn+e6OE18RGAYtYoOobhIQV90 gOtvyZIhCfJB+uMUl9pTv52tA0hD01dXcHPCD2iwLsOKjMYiOf+aXedGV8mkuTQtdbTL mkw2FmnC9/naqV17jCUctjaW/A7Fwlbuxu+XraFjyTzZIYg/xMn1FOcEYl2El3Ei/p7O C42MUKdcCJehiWEW4RA9RzE/Oof87X5Qs8DJVeVwSAOsmod5iyvms49EzVtReQzb+8sF wypw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WQm+cBYM; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x14si5145722pgt.495.2019.06.29.06.24.32; Sat, 29 Jun 2019 06:24:48 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WQm+cBYM; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726849AbfF2NYX (ORCPT + 99 others); Sat, 29 Jun 2019 09:24:23 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:41134 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726731AbfF2NYX (ORCPT ); Sat, 29 Jun 2019 09:24:23 -0400 Received: by mail-pg1-f193.google.com with SMTP id q4so2363482pgj.8; Sat, 29 Jun 2019 06:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GyjmIieAkSvtFPJ2RM/QvCR+edPTBd5UDZcV9pbUH70=; b=WQm+cBYM3gl/LV62mWMLGd48RbcRoNGivwXmtpu2+hj4KHy0nqlFBNV/ulHzrlXtaB xEVFcniaStIOW6xti2blE5qT62ejR4HIwE5BBytIrro/L4dbLrgrUAMMiGLIgJeZx8z6 O6JKMjiMPvvm8PQc+F2MQ2MhnmgzCuEcWsYfBbLTOqmHgH/oRrJ3R6M9dgm2f+9OjuYt s9XalmOQI9c6qfz4833Tvf2Xj2pQ2Hm4KdUTxVwlTbCXYULATavJmzZ7kVlS83fnO4DB aZZDlJpTYxeGNH/LUXi48CbIThFvCpAc4em7ijai2Wq9J42PsX3RpSS8UcG1xQyUkAgE iYeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GyjmIieAkSvtFPJ2RM/QvCR+edPTBd5UDZcV9pbUH70=; b=WXm0QoZflbCVh9H/nOAVdDGPZY1TBktFkvzq1JfJfI6HIk5L9w/u6Eu+yXfSoj/sq5 axp1duAMo1beMzy45YPWzTWl7Bggko77uAo44tUVyR4liH6WjtLl4g1ig4HMb4Qrqikq NUMx3atGLRZo73pin5CgbVwrMYwUFKpM4lqcqvZSvkzSmKvvKkmrD5maUlBM31hzBK4n e64uiE+a+9Hhb1QKB7l6KtVyFZd5Z5E7b0OPnHFhtnltO3WuTP7ROPvfCN6ZMOZq87GM ithrl/R5MxyY4fDgHZ9pe2/ZuyGGZklW2f3PzP6dmfR22ghLmGmRySF1AiDZ/VtKw0G+ xWfQ== X-Gm-Message-State: APjAAAWU30lIObUMfgX6F5QuSHB8QVYE/0ginRdxftbp8b+R8P26jmBQ M4ODHeh0JVmOUutDPK2G2nkbVfSbAhCcfok2psc= X-Received: by 2002:a17:90b:8d2:: with SMTP id ds18mr19791419pjb.132.1561814662655; Sat, 29 Jun 2019 06:24:22 -0700 (PDT) MIME-Version: 1.0 References: <20190528025727.6014-1-harry.pan@intel.com> <20190619082801.21699-1-harry.pan@intel.com> In-Reply-To: <20190619082801.21699-1-harry.pan@intel.com> From: Andy Shevchenko Date: Sat, 29 Jun 2019 16:24:11 +0300 Message-ID: Subject: Re: [PATCH v3] platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds To: Harry Pan Cc: LKML , gs0622@gmail.com, Vishwanath Somayaji , Andy Shevchenko , Platform Driver , Rajneesh Bhardwaj , Darren Hart Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 19, 2019 at 11:29 AM Harry Pan wrote: > > 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 > Pushed to my review and testing queue, thanks! > --- > > 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 > -- With Best Regards, Andy Shevchenko