Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3107152lqo; Tue, 14 May 2024 22:45:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURwwst32UQI3VHzHlpzV5kzZShw5i0R0/tZrhHe86cPnspEu8nLVXXxeCGZbOtZtxeWGaCL3WgJ7WAycYzW+9Y5SdHv2sFuo2g3fk9ow== X-Google-Smtp-Source: AGHT+IHzF54uGTUn+6MGklW0/H+LuqhlJeMlhROeDDLN6oAmzbIbFUxbrgv6MKindiAGZNF/XqBQ X-Received: by 2002:a17:902:c94a:b0:1e8:26e4:d089 with SMTP id d9443c01a7336-1ef4404a1b8mr179273645ad.54.1715751941201; Tue, 14 May 2024 22:45:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715751941; cv=pass; d=google.com; s=arc-20160816; b=CWAxWblTDh5L6RlcBqPOFTZSSed91tkQe7BrLl1QYm1nOQGA+axxye2rZs385twIPt mjtOxQD8wYB+9FVPApWBKitVVvVd8AZe69ii0CQpT/W5Pj+thC/BzznEd/Z1zEcePG4t dqAA8HtydJQtxJVEV2ctK+26kT4tlbZ4D2mvYXzJyWtCuj2vCP5dNJQjTzoZQ8jP/mwb WBbAjKbji7xzet8o+UMV+khDThAJqilm1XlT2TYDJ26xMkBDRgG3NFoxndBpUkhC3HOm kyufxGcLprZuyj5CR33KVJniLfrvl6IeRjZ8yQ5+2ngevvBDM8lp4iL47/PTy42Xe295 zmsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=cltKgkAdT5kWyPnV9AZTIEyRIkCk+SKCpuF8AUhcEL0=; fh=7D8bWqELNqJM6KF7zbibUOya8038rGAdDMFXsJMRu8c=; b=hL2GP5QRV0x8OpaZKjDdaDj1YQskMDWXeFV7b2Bkz9E8D3HqUy9F/XUvdEUac53UnW RRizw3k/RYz+oHD0UuNgRKSEDvnM6bL1J7hpr2uKqfcQTCewd7KBsVDdsjAoZnnunQYv X8BsuFHcMECA47FIwrM7E82FDcQzkAIsMTvWYuBWzv2pz8fk0hYQAs4uDoa/SjRKTUAa b8c3GK8oX/42WSlGynUUDx/l3ny+EKiz48YBf6xC2TxmHRYHmSBrxGXnWh49tyg8D6q/ bNWndGslxjMTOUBYI1iNxapiSX1futh/vhFa0otcpF/A+8DSyWE6GTfkj/r1PmNXEkgJ Q62Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WMNIxJw8; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-179470-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179470-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c0372a2si123488455ad.334.2024.05.14.22.45.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 22:45:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179470-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WMNIxJw8; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-179470-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179470-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 32B7DB20D8D for ; Wed, 15 May 2024 05:45:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FC3C3D967; Wed, 15 May 2024 05:44:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WMNIxJw8" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 A786E3839C; Wed, 15 May 2024 05:44:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715751895; cv=none; b=u3dd2X42g7kqVPdjZJbjRauFY/R0ZxAyIukn1BZc/0c/O/8jsQw9ybdIL7Jum/RCx/a0W1f1J7EKxka46015apVxf9/6trHX1z5bulNlH6XnbD6G0rP4Ld47PZh9Y2tOkObaS1Uhw/NB9SuqmBa8b+TZf/CtIsrKpXtpXogcQjc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715751895; c=relaxed/simple; bh=k03uHL02yJNFBSXmc8VPdCv9Pz2G1voZfKzU6/p+8vk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MXmDbMacw85zKd0X8+GcPJH9oETSfwlH93iI6WVC8jP0/E39M0uwAlfAg0h7TVdMtyqoQnnX7kz2arFID8LxCWAkXR/Axa20wXxYha4qMupJsi3e4iHfVj8cWsqkqlW0UqO3lqJL1QaFOXkQFIXR7tlyH3x+zGlYvXm/+H3bsGE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WMNIxJw8; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715751893; x=1747287893; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k03uHL02yJNFBSXmc8VPdCv9Pz2G1voZfKzU6/p+8vk=; b=WMNIxJw8Pu80ZSHyRVfHc2sYR+RmVtgH6Qp3Fb+laAEksG/RoMUWavvT eAQ/+6SlrDWfRgQkZk90kHqjqENTvuM6H6nKu2Vss7cEXeV5nMq91OING VIssx/3nJ6WcfYzTd5RuuVe6dfefHu1vE4rKxQUh3s18yYOYFL5jzdIVK E1PEXEw8Pole3EvbM4VGKUC9cNHL8YPoLQxyShxCc0oZyilhRcWHZQfya q9PYZ+hT7ptk+YhalmJogQW0LxLuhSmuBRxgmKDQz0Gv5NQHSxBvam0xj GrCQji5v5PesRUJQfgeW7b8q83YzhAgcqVvfBMhs/dVFYZqjHSJ13xH5a w==; X-CSE-ConnectionGUID: PV3j9YwCQrWZJUWgwySMlA== X-CSE-MsgGUID: oEj0tg6fQIS7lCPA8UpikQ== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="29298035" X-IronPort-AV: E=Sophos;i="6.08,160,1712646000"; d="scan'208";a="29298035" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 22:44:51 -0700 X-CSE-ConnectionGUID: 0CuZXGj1Q7KzsH84CYoZng== X-CSE-MsgGUID: epQTg4+BSk61yYNEOzONTg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,160,1712646000"; d="scan'208";a="35469209" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa003.fm.intel.com with ESMTP; 14 May 2024 22:44:50 -0700 From: weilin.wang@intel.com To: weilin.wang@intel.com, Namhyung Kim , Ian Rogers , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers Subject: [RFC PATCH v8 4/7] perf stat: Add retire latency values into the expr_parse_ctx to prepare for final metric calculation Date: Wed, 15 May 2024 01:44:26 -0400 Message-ID: <20240515054443.2824147-5-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240515054443.2824147-1-weilin.wang@intel.com> References: <20240515054443.2824147-1-weilin.wang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Weilin Wang Retire latency values of events are used in metric formulas. This update adds code to process data from perf record for required retire latency values. Signed-off-by: Weilin Wang Reviewed-by: Ian Rogers --- tools/perf/util/stat-shadow.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 3466aa952442..b97d23bfeac1 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -15,6 +15,7 @@ #include #include "iostat.h" #include "util/hashmap.h" +#include "util/intel-tpebs.h" struct stats walltime_nsecs_stats; struct rusage_stats ru_stats; @@ -355,6 +356,20 @@ static void print_nsecs(struct perf_stat_config *config, print_metric(config, ctxp, NULL, NULL, "CPUs utilized", 0); } +static int prepare_retire_lat(struct expr_parse_ctx *pctx, + struct list_head *retire_lats) +{ + int ret = 0; + struct tpebs_retire_lat *t; + + list_for_each_entry(t, retire_lats, nd) { + ret = expr__add_id_val(pctx, strdup(t->tpebs_name), t->val); + if (ret < 0) + return ret; + } + return ret; +} + static int prepare_metric(const struct metric_expr *mexp, const struct evsel *evsel, struct expr_parse_ctx *pctx, @@ -369,6 +384,9 @@ static int prepare_metric(const struct metric_expr *mexp, double val; int source_count = 0; + if (metric_events[i]->retire_lat) + continue; + if (evsel__is_tool(metric_events[i])) { struct stats *stats; double scale; @@ -486,6 +504,11 @@ static void generic_metric(struct perf_stat_config *config, pctx->sctx.user_requested_cpu_list = strdup(config->user_requested_cpu_list); pctx->sctx.runtime = runtime; pctx->sctx.system_wide = config->system_wide; + i = prepare_retire_lat(pctx, &config->tpebs_results); + if (i < 0) { + expr__ctx_free(pctx); + return; + } i = prepare_metric(mexp, evsel, pctx, aggr_idx); if (i < 0) { expr__ctx_free(pctx); -- 2.43.0