Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1936430ybb; Sun, 29 Mar 2020 17:41:20 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvcRnAUNskWD26saUscx1Eqd9VuIwqP8Fr8GM9kGXn01IuS1GD6y5fw1WE0TpXD67U5z7fx X-Received: by 2002:a05:6830:23b6:: with SMTP id m22mr7241503ots.225.1585528880620; Sun, 29 Mar 2020 17:41:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585528880; cv=none; d=google.com; s=arc-20160816; b=FiQ+rWAxXmrY0EwoWvKZ9ZpXC7vW4XRGtuaBAfiDZsHaVY+PWyjxMuyTdkasiO0uLD 0Qqcz76o1rTQ2W8t0tCfLUs58SZuFtXS85J2GVOeZRIJc7hpt25L7RsPwLy/h81IiHkH M6B80a5D1rY4YEPVP85XADzwNPKkL6ugxpcPf4DXQZM8EOi/lEeStMYf6VU20k708DR7 XUj7JmNXVXQxDqqlVk/9mkMmU6Sr4dOhlf2UYnP8e7vNU0VIvFa2kbvnm+vMq0WKnrfX 2HSlopdfkKor3CBZ2ZmPpgseYthW6NomuzqnTBqUzH8N7YwHByEMtSOiqf/gnuD7Bd/+ TNvQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=a3kcM/APpdycAAgdOj6l+0XP7CqZlRCj6KYJjYBzGFI=; b=NksfD3ZCqaTiNl7MWvaKLlmELrWTPLbCjEwZc0SyO+gEWC2MyIOb+3RNqnaKgjv0pY oxvnAKKy9RGuzdDNhsDuy/L/4yecNqiQ/Mj+/P65kIYTIJGea2zq5k6KuJ2tSqN5beJT NKukJbU2X0CGHEckBL1UhBF+W932MON6uj8zPj4WV9adKzBxvX3OoTXt2FtM2LSrwxtA wyPoBWz/9GBx26l79DQkbzxBnEBMSflK9TzbGS15qWuOiuWT80T0ByBCyCIE9K42S+Vj mqn2SeVT9r5ZYMxmm7+csbQtIX5zGRsur2iiVbXC3hPiUzjbquMtvd1cjTYBS4rDqAC/ 1YtA== 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 h59si5426195oth.233.2020.03.29.17.41.06; Sun, 29 Mar 2020 17:41:20 -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 S1728005AbgC3Aie (ORCPT + 99 others); Sun, 29 Mar 2020 20:38:34 -0400 Received: from mga14.intel.com ([192.55.52.115]:63049 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727805AbgC3Aid (ORCPT ); Sun, 29 Mar 2020 20:38:33 -0400 IronPort-SDR: 5yn+51Exat0X1zkpsVk1zpt2p+HFXmvCxLjz5HQmuuCukSSF0wYkvpRQqaeq3Ptm+K7sQL3XyC QZMp6O/UJeTw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2020 17:38:32 -0700 IronPort-SDR: FoVSLBcD2+G6A4CKsu6XNQcUdfLO8NnKvubZ/E2ePVHJY8vN6gB3gr2xXyKICzC1W1L8IoXBUD 8mCdZ4wViRjA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,322,1580803200"; d="scan'208";a="239625188" Received: from yjin15-mobl1.ccr.corp.intel.com (HELO [10.238.4.151]) ([10.238.4.151]) by fmsmga007.fm.intel.com with ESMTP; 29 Mar 2020 17:38:30 -0700 Subject: Re: [PATCH] perf/x86/pmu-events: Use CPU_CLK_UNHALTED.THREAD in Kernel_Utilization metric To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com References: <20200309013125.7559-1-yao.jin@linux.intel.com> From: "Jin, Yao" Message-ID: Date: Mon, 30 Mar 2020 08:38:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200309013125.7559-1-yao.jin@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Any comments for this patch? Thanks Jin Yao On 3/9/2020 9:31 AM, Jin Yao wrote: > The kernel utilization metric does multiplexing currently and is somewhat > unreliable. The problem is that it uses two instances of the fixed counter, > and the kernel has to multipleplex which causes errors. So should use > CPU_CLK_UNHALTED.THREAD instead. > > Before: > > # perf stat -M Kernel_Utilization -- sleep 1 > > Performance counter stats for 'sleep 1': > > 1,419,425 cpu_clk_unhalted.ref_tsc:k > cpu_clk_unhalted.ref_tsc (0.00%) > > After: > > # perf stat -M Kernel_Utilization -- sleep 1 > > Performance counter stats for 'sleep 1': > > 746,688 cpu_clk_unhalted.thread:k # 0.7 Kernel_Utilization > 1,088,348 cpu_clk_unhalted.thread > > Signed-off-by: Jin Yao > --- > tools/perf/pmu-events/arch/x86/broadwell/bdw-metrics.json | 2 +- > tools/perf/pmu-events/arch/x86/broadwellde/bdwde-metrics.json | 2 +- > tools/perf/pmu-events/arch/x86/broadwellx/bdx-metrics.json | 2 +- > tools/perf/pmu-events/arch/x86/cascadelakex/clx-metrics.json | 2 +- > tools/perf/pmu-events/arch/x86/haswell/hsw-metrics.json | 2 +- > tools/perf/pmu-events/arch/x86/haswellx/hsx-metrics.json | 2 +- > tools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json | 2 +- > tools/perf/pmu-events/arch/x86/ivytown/ivt-metrics.json | 2 +- > tools/perf/pmu-events/arch/x86/jaketown/jkt-metrics.json | 2 +- > tools/perf/pmu-events/arch/x86/sandybridge/snb-metrics.json | 2 +- > tools/perf/pmu-events/arch/x86/skylake/skl-metrics.json | 2 +- > tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json | 2 +- > 12 files changed, 12 insertions(+), 12 deletions(-) > > diff --git a/tools/perf/pmu-events/arch/x86/broadwell/bdw-metrics.json b/tools/perf/pmu-events/arch/x86/broadwell/bdw-metrics.json > index 45a34ce4fe89..8cdc7c13dc2a 100644 > --- a/tools/perf/pmu-events/arch/x86/broadwell/bdw-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/broadwell/bdw-metrics.json > @@ -297,7 +297,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, > diff --git a/tools/perf/pmu-events/arch/x86/broadwellde/bdwde-metrics.json b/tools/perf/pmu-events/arch/x86/broadwellde/bdwde-metrics.json > index 961fe4395758..16fd8a7490fc 100644 > --- a/tools/perf/pmu-events/arch/x86/broadwellde/bdwde-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/broadwellde/bdwde-metrics.json > @@ -115,7 +115,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, > diff --git a/tools/perf/pmu-events/arch/x86/broadwellx/bdx-metrics.json b/tools/perf/pmu-events/arch/x86/broadwellx/bdx-metrics.json > index 746734ce09be..1eb0415fa11a 100644 > --- a/tools/perf/pmu-events/arch/x86/broadwellx/bdx-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/broadwellx/bdx-metrics.json > @@ -297,7 +297,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, > diff --git a/tools/perf/pmu-events/arch/x86/cascadelakex/clx-metrics.json b/tools/perf/pmu-events/arch/x86/cascadelakex/clx-metrics.json > index f94653229dd4..a2c32db8f14e 100644 > --- a/tools/perf/pmu-events/arch/x86/cascadelakex/clx-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/cascadelakex/clx-metrics.json > @@ -315,7 +315,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, > diff --git a/tools/perf/pmu-events/arch/x86/haswell/hsw-metrics.json b/tools/perf/pmu-events/arch/x86/haswell/hsw-metrics.json > index 5402cd3120f9..f57c5f3506c2 100644 > --- a/tools/perf/pmu-events/arch/x86/haswell/hsw-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/haswell/hsw-metrics.json > @@ -267,7 +267,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, > diff --git a/tools/perf/pmu-events/arch/x86/haswellx/hsx-metrics.json b/tools/perf/pmu-events/arch/x86/haswellx/hsx-metrics.json > index 832f3cb40b34..311a005dc35b 100644 > --- a/tools/perf/pmu-events/arch/x86/haswellx/hsx-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/haswellx/hsx-metrics.json > @@ -267,7 +267,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, > diff --git a/tools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json b/tools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json > index d69b2a8fc0bc..28e25447d3ef 100644 > --- a/tools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json > @@ -285,7 +285,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, > diff --git a/tools/perf/pmu-events/arch/x86/ivytown/ivt-metrics.json b/tools/perf/pmu-events/arch/x86/ivytown/ivt-metrics.json > index 5f465fd81315..db23db2e98be 100644 > --- a/tools/perf/pmu-events/arch/x86/ivytown/ivt-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/ivytown/ivt-metrics.json > @@ -285,7 +285,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, > diff --git a/tools/perf/pmu-events/arch/x86/jaketown/jkt-metrics.json b/tools/perf/pmu-events/arch/x86/jaketown/jkt-metrics.json > index 3e909b306003..dbb33e00b72a 100644 > --- a/tools/perf/pmu-events/arch/x86/jaketown/jkt-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/jaketown/jkt-metrics.json > @@ -171,7 +171,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, > diff --git a/tools/perf/pmu-events/arch/x86/sandybridge/snb-metrics.json b/tools/perf/pmu-events/arch/x86/sandybridge/snb-metrics.json > index 50c053235752..fb2d7b8875f8 100644 > --- a/tools/perf/pmu-events/arch/x86/sandybridge/snb-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/sandybridge/snb-metrics.json > @@ -171,7 +171,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, > diff --git a/tools/perf/pmu-events/arch/x86/skylake/skl-metrics.json b/tools/perf/pmu-events/arch/x86/skylake/skl-metrics.json > index e7feb60f9fa9..e3afc3178958 100644 > --- a/tools/perf/pmu-events/arch/x86/skylake/skl-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/skylake/skl-metrics.json > @@ -303,7 +303,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, > diff --git a/tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json b/tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json > index 21d7a0c2c2e8..12d1efba79bb 100644 > --- a/tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json > +++ b/tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json > @@ -315,7 +315,7 @@ > }, > { > "BriefDescription": "Fraction of cycles spent in Kernel mode", > - "MetricExpr": "CPU_CLK_UNHALTED.REF_TSC:k / CPU_CLK_UNHALTED.REF_TSC", > + "MetricExpr": "CPU_CLK_UNHALTED.THREAD:k / CPU_CLK_UNHALTED.THREAD", > "MetricGroup": "Summary", > "MetricName": "Kernel_Utilization" > }, >