Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp158089lqc; Thu, 29 Feb 2024 13:16:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVgbosKO5VvNgt+Mxfa3jqbcaMprllRIlelZ3p+2sjxj33vtQVEIN+NltpKchnM7+oSBybUUteQOQALcz5znSDrv7c4hOqABpwLGokLew== X-Google-Smtp-Source: AGHT+IH2cSL4C4fr3g4idhw4kF60cz71VcsKua/+pRH8HpAakZstTZZoU9lMhmmUJ7OhjvC9Jdsw X-Received: by 2002:a50:cbcd:0:b0:566:777:af4f with SMTP id l13-20020a50cbcd000000b005660777af4fmr82095edi.1.1709241368893; Thu, 29 Feb 2024 13:16:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709241368; cv=pass; d=google.com; s=arc-20160816; b=cs4Bj4JBQP0qTitSGxxCt9nwNgssE2QKCO5JN66S0TY0ell7tCAvTo5567E2zf+3UF 1u3T54pm7QnMf/8oe2cMdqVPtv6z6LX4OCA2YDoEo+u0K1y3MuJ9WAeH8g+nAlNurbKG 8wXjcxDDEvclf9dlm8awuNsfj63pO9MEOD/gDBJqFBatU4RwYvB6dbC37SSVGE7TV89M M5ZAMx8FlROryTZt92f6HhBNfP3erUY6UQxkT+bFZnEmf+J7VXOoEv/GzC/wfEBSCUoq nFVRTdUL+INkTjWZd0f3/3V1gkcuADon0ghZsMc6U4pfY9tMp406rEyivy65/e9hXF6X 8Zmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=bgxCKl/HHG/VaDRPrDcttpsk3k6bJ0WvCmkKRhH+b8w=; fh=xwiTb8dW8FnIyS8b3h9/neqRLRhsKMpwfKiuZ0NbPVk=; b=F/8vgxaemxjb/3zrmoGZ6W9aLns7lECpJ71orJcbQHov3kasLN64i42XNHXnz/y8U1 OCrCD+pWCvpuorgP7fib8nMsLQB/U4Z+k1qg2127SLTMmcIKTUtwqH4350os+wryrfSs Tq5YjuaqXviJ9ZoDfHqoe+9byOinUFLZGhtE0BylA9B4yfqNx1icRGBAdqz3XxBtUIWX /8wMjLdr7F2oD/OqWvbnqlsAepavfUN6WCMuOWiDcOuQ6/vTu/RRHf+U94FYWNa6vHvX 0zMB6FC7Adf3etYpJrerJt9xi+JqdzOF93iOV4NTvGK6gLmDXqbc/+DJK13zTMmigbeQ ps+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JxnxiymL; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-87567-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87567-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s5-20020a50ab05000000b00566afb7bb1asi515617edc.62.2024.02.29.13.16.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 13:16:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87567-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JxnxiymL; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-87567-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87567-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6F4D01F24D7F for ; Thu, 29 Feb 2024 21:16:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9843B16FF47; Thu, 29 Feb 2024 21:16:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JxnxiymL" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9310116FF31; Thu, 29 Feb 2024 21:15:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709241359; cv=none; b=d+2QyKKMV4m8riG3SCPZ+c80c4ZGh89bot8WivgkXwMrt6aLyL2UozbQWdnbBBYsJgU3zPi8UNPWakkJKdvRk8qP/jx618pWI3nBXAjZBHjMbuWYtWWA8SxI7ngiT3/VVmdsk3U8UZ8ZdCY9ZmsonwzEILswwcisQ3jh8A962CQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709241359; c=relaxed/simple; bh=xOxDegQasEklfMTwb0uGHJaYs+H/kBKUxdhMsGU3IZ8=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=EbkRhaPic9U5kUwCA3xrx5duHUzYiQ0yE6R5cZxspYvdbHew4M1eny4pC0kCgoIC8hBE+yIntmORlpRwXATTxJgAc6RV7z3K0/s2h6eaHQmRnFsC5Ul+ENQthOGG0vQmdJKzu7rNh+mnDKWTUaGWs4yXze+PnLvC0/M75d1wK4M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=JxnxiymL; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709241358; x=1740777358; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=xOxDegQasEklfMTwb0uGHJaYs+H/kBKUxdhMsGU3IZ8=; b=JxnxiymLfJowhP2WLR+xVw+9vy39ULxCWEEOPhjS2GjHzyWwob/qvrPF Evg7WbzZBsZiQmxRL78M0FuDlGk52kxLcssBxcwFEklCb5QOCs7GtL562 a35MsBMig504/BeyBuO11gInMYlUUWOM0xV3rhcnxrA+eZo2uy+hO9UAX sS8s3QthXPD1m9upCqt9PoEugmtUe37JEL5xOjxxlSPOI9v64PrngkPec LuPwcZ7peiO7BoFrHlv9Gw2Z9Cd6BSX9fPMR/BJh/ac9EXvW1CwoY2gLx yJX6oL9Pqbugrisp/YGizNyw2vUWU7jRXq0JXmwAKdWC+bbSd3ibyUqEI Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10999"; a="3634344" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="3634344" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 13:15:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="38803997" Received: from linux.intel.com ([10.54.29.200]) by orviesa002.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 13:15:56 -0800 Received: from [10.212.85.217] (kliang2-mobl1.ccr.corp.intel.com [10.212.85.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 46342580D37; Thu, 29 Feb 2024 13:15:53 -0800 (PST) Message-ID: <7aa2d2a2-b8f9-478f-9699-7b717d38a8ab@linux.intel.com> Date: Thu, 29 Feb 2024 16:15:51 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 04/20] perf jevents: Add tsx metric group for Intel models Content-Language: en-US To: Ian Rogers , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Andi Kleen , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , John Garry , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Stephane Eranian References: <20240229001806.4158429-1-irogers@google.com> <20240229001806.4158429-5-irogers@google.com> From: "Liang, Kan" In-Reply-To: <20240229001806.4158429-5-irogers@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2024-02-28 7:17 p.m., Ian Rogers wrote: > Allow duplicated metric to be dropped from json files. > > Signed-off-by: Ian Rogers > --- > tools/perf/pmu-events/intel_metrics.py | 51 ++++++++++++++++++++++++++ > 1 file changed, 51 insertions(+) > > diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py > index 20c25d142f24..1096accea2aa 100755 > --- a/tools/perf/pmu-events/intel_metrics.py > +++ b/tools/perf/pmu-events/intel_metrics.py > @@ -7,6 +7,7 @@ import argparse > import json > import math > import os > +from typing import Optional > > parser = argparse.ArgumentParser(description="Intel perf json generator") > parser.add_argument("-metricgroups", help="Generate metricgroups data", action='store_true') > @@ -77,10 +78,60 @@ def Smi() -> MetricGroup: > ]) > > > +def Tsx() -> Optional[MetricGroup]: > + if args.model not in [ > + 'alderlake', > + 'cascadelakex', > + 'icelake', > + 'icelakex', > + 'rocketlake', > + 'sapphirerapids', > + 'skylake', > + 'skylakex', > + 'tigerlake',> + ]: Can we get ride of the model list? Otherwise, we have to keep updating the list. > + return None > +> + pmu = "cpu_core" if args.model == "alderlake" else "cpu" Is it possible to change the check to the existence of the "cpu" PMU here? has_pmu("cpu") ? "cpu" : "cpu_core" > + cycles = Event('cycles') > + cycles_in_tx = Event(f'{pmu}/cycles\-t/') > + transaction_start = Event(f'{pmu}/tx\-start/') > + cycles_in_tx_cp = Event(f'{pmu}/cycles\-ct/') > + metrics = [ > + Metric('tsx_transactional_cycles', > + 'Percentage of cycles within a transaction region.', > + Select(cycles_in_tx / cycles, has_event(cycles_in_tx), 0), > + '100%'), > + Metric('tsx_aborted_cycles', 'Percentage of cycles in aborted transactions.', > + Select(max(cycles_in_tx - cycles_in_tx_cp, 0) / cycles, > + has_event(cycles_in_tx), > + 0), > + '100%'), > + Metric('tsx_cycles_per_transaction', > + 'Number of cycles within a transaction divided by the number of transactions.', > + Select(cycles_in_tx / transaction_start, > + has_event(cycles_in_tx), > + 0), > + "cycles / transaction"), > + ] > + if args.model != 'sapphirerapids': Add the "tsx_cycles_per_elision" metric only if has_event(f'{pmu}/el\-start/')? Thanks, Kan > + elision_start = Event(f'{pmu}/el\-start/') > + metrics += [ > + Metric('tsx_cycles_per_elision', > + 'Number of cycles within a transaction divided by the number of elisions.', > + Select(cycles_in_tx / elision_start, > + has_event(elision_start), > + 0), > + "cycles / elision"), > + ] > + return MetricGroup('transaction', metrics) > + > + > all_metrics = MetricGroup("", [ > Idle(), > Rapl(), > Smi(), > + Tsx(), > ]) > > if args.metricgroups: