Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp301962lqg; Fri, 1 Mar 2024 05:53:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWlWk9QqgVU0HDJXEv2S2Eho/lO/3AaLgi7k4lrgD382MVM7OZjVDGE6GKOWQAtkTSR3OOwBTuQknpmeVrnx+Bda2HTzCPCebbVkOM8hw== X-Google-Smtp-Source: AGHT+IEXGOC+pc2RT29JHTnesjP4UIdydkxwDAiUZZZf27Dt44nFa1rcb479SHSlNJ0VAPbjpny/ X-Received: by 2002:a0c:da8b:0:b0:68f:edeb:6b8c with SMTP id z11-20020a0cda8b000000b0068fedeb6b8cmr1724164qvj.12.1709301235960; Fri, 01 Mar 2024 05:53:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709301235; cv=pass; d=google.com; s=arc-20160816; b=paSnwVFsvFWra8nQN/JkhsBgpkiYC6lmXgkhfxppjQAAg1qwwTz/YxdA+iewYeYWzV pb48s0Tx5ylNh40/ZU4GT1Q1AgTijShV26/pR9dtHE5XYYdnlATKyqg7OXWWiQhEW8rN yJl793kPfpAHhhxGlCh3ZhSOvqwYgA64Wmacbx/sGAubIYd6pNFB99eHAAWrMn+Ekakx wuqvnvzJwB9ps0w9T8DTu/yhq4WrIWT+z5wA7RWZlatalqB2KjSXwmVxJ2waFmnMj+bK tCXvwJWKdTTBtgI8KldnlfGHoW3XMrpbMGjBsknBlYAAwwNbMmwA12ZM77CANMXdNJd6 es7w== 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:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=d1mWJuLmvPWKNoY9ye3HKzRG+vntGfFweKqdF5FmxVc=; fh=STTD5aoeUDANr7cpZgVNFoCso8bmCF8arViDLStxsFA=; b=Pe9grrhSW56jYUV/RLCGE8KWAqAVffYYY1huGQ9kOZGFO2hjlXZqgwEhragrPHKyEJ NoSgFWlI+Qkf3dayWqtJNZLC5/z8FX+0ygBYlUNlWc824fiZ7JGESDpBFBiSGjeLTH8I nuZktFAB6qMHNhmf3hj+W1LnJSN2hunhiCzIX3iAbMj5xZd/7BMg/Ons12l8/hN1fTpd Y3upYRi2EpvUrgHA9j5+BOehu8sUebsK8swj0Y8g8jNA+f1pDBPgK1KM4e9kRqLzDMoG vDi79zYdkplJCKwc4N7gJ+NFSToBvp7p28xjEPX1sYM9Hgo7okWZz35LHKy0i4G8GbCW cUzQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=oHyJwO+M; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-88520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88520-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i4-20020ad45c64000000b0068f62ba06dfsi3572379qvh.551.2024.03.01.05.53.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 05:53:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=oHyJwO+M; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-88520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88520-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A87831C212C7 for ; Fri, 1 Mar 2024 13:53:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0807B6F099; Fri, 1 Mar 2024 13:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="oHyJwO+M" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 7F1D06F061; Fri, 1 Mar 2024 13:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709301213; cv=none; b=gp9cqtlfGumRluRdsLk55stHquVYu4k9v/N848Gbwhc8FjwaYC8pcaIghSE6H2XG8TlX+Vbv18Gr5IK78uY2RsMlpu+V+S7nkm8TUMaFTnZxgPk1BPPhS1i5CmVCyYE9U9GplmMV/1x0jeIneLGblNOgfC4k0+sxTtmkAstirQs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709301213; c=relaxed/simple; bh=M1xUh7ZKCKbjOhIeycBxfyXIaBQ4HjPL23BzKlTCLkk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Su+fkNQmIvI96tjRiT3bBwORphk1ATCdSykBF0LYDVx/xwM37OnuSeBNufqBJkP2GoOe9M1PPOpoYvJMpus0HOSxUxtMCJC0QV6ZVMp6B18Gam/T3wZTqaVWJtIpCPeMzVb1JL87TTRiZ1wQmqgS3kQXy/W2kTF3ojzCVvHAEXg= 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=oHyJwO+M; arc=none smtp.client-ip=198.175.65.21 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=1709301211; x=1740837211; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=M1xUh7ZKCKbjOhIeycBxfyXIaBQ4HjPL23BzKlTCLkk=; b=oHyJwO+MAFbLYCZrlUYyXDetcjvk0IeIZ/+sZ1uE+PePPwMbFrzv5J1K StwYZcw8ixPA3dHYny1WQBezAWkMzhFS6v/99v/+tUjdff/TBvxhU/0Xe Te8SD/hxkSOhaNUNj47EHR/lA6WpLK+S0yx0sc/O24Tm7hH38NK0ixs0i 3ZemXob42Bs6Hl/iin647unnDidKFSFycEpTZD0fQiIkdEU8ocOMYeiHT vZIUXxYCqAuJxQdBhkRGgaEqkdHUwnG8BwhgFLzIlQqYEhbJMt3Z0FYPy cH5jrcfvmSB+CUJavkLRrN/KnypP41gCbl0bR/YcqIXCajzqPSaWifWFR A==; X-IronPort-AV: E=McAfee;i="6600,9927,10999"; a="3764687" X-IronPort-AV: E=Sophos;i="6.06,196,1705392000"; d="scan'208";a="3764687" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 05:53:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,196,1705392000"; d="scan'208";a="8603825" Received: from linux.intel.com ([10.54.29.200]) by orviesa007.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 05:53:31 -0800 Received: from [10.209.156.90] (kliang2-mobl1.ccr.corp.intel.com [10.209.156.90]) (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 57568580DA4; Fri, 1 Mar 2024 05:53:27 -0800 (PST) Message-ID: Date: Fri, 1 Mar 2024 08:53:26 -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 13/20] perf jevents: Add cycles breakdown metric for Intel To: Ian Rogers Cc: 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-14-irogers@google.com> Content-Language: en-US From: "Liang, Kan" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2024-02-29 7:48 p.m., Ian Rogers wrote: > On Thu, Feb 29, 2024 at 1:30 PM Liang, Kan wrote: >> >> >> >> On 2024-02-28 7:17 p.m., Ian Rogers wrote: >>> Breakdown cycles to user, kernel and guest. >>> >>> Signed-off-by: Ian Rogers >>> --- >>> tools/perf/pmu-events/intel_metrics.py | 18 ++++++++++++++++++ >>> 1 file changed, 18 insertions(+) >>> >>> diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py >>> index dae44d296861..fef40969a4b8 100755 >>> --- a/tools/perf/pmu-events/intel_metrics.py >>> +++ b/tools/perf/pmu-events/intel_metrics.py >>> @@ -26,6 +26,23 @@ core_cycles = Event("CPU_CLK_UNHALTED.THREAD_P_ANY", >>> smt_cycles = Select(core_cycles / 2, Literal("#smt_on"), core_cycles) >>> >>> >>> +def Cycles() -> MetricGroup: >>> + cyc_k = Event("cycles:kHh") >>> + cyc_g = Event("cycles:G") >>> + cyc_u = Event("cycles:uH") >>> + cyc = cyc_k + cyc_g + cyc_u >>> + >>> + return MetricGroup("cycles", [ >>> + Metric("cycles_total", "Total number of cycles", cyc, "cycles"), >>> + Metric("cycles_user", "User cycles as a percentage of all cycles", >>> + d_ratio(cyc_u, cyc), "100%"), >>> + Metric("cycles_kernel", "Kernel cycles as a percentage of all cycles", >>> + d_ratio(cyc_k, cyc), "100%"), >>> + Metric("cycles_guest", "Hypervisor guest cycles as a percentage of all cycles", >>> + d_ratio(cyc_g, cyc), "100%"), >>> + ], description = "cycles breakdown per privilege level (users, kernel, guest)") >>> + >>> + >>> def Idle() -> Metric: >>> cyc = Event("msr/mperf/") >>> tsc = Event("msr/tsc/") >>> @@ -770,6 +787,7 @@ def IntelLdSt() -> Optional[MetricGroup]: >>> >>> >>> all_metrics = MetricGroup("", [ >>> + Cycles(), >> >> The metric group seem exactly the same on AMD and ARM. Maybe we can have >> tools/perf/pmu-events/common_metrics.py for all the common metrics. > > Agreed. I think we can drop cycles in the three sets and then once > then do the common_metrics.py as a follow up. > Sounds good to me. Thanks, Kan > Thanks, > Ian > >> Thanks, >> Kan >> >>> Idle(), >>> Rapl(), >>> Smi(), >