From patchwork Wed Feb 28 16:12:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Weilin" X-Patchwork-Id: 207918 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3466492dyb; Wed, 28 Feb 2024 08:41:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW1nqZgQBFZ3CPnrQc9ZP1W3HJZSBEWaiiMjYzGaA3UkSpo/AW7W17WdicmC4zwUAgLtGjJrXyQI4NS6kqCc8toPaakjw== X-Google-Smtp-Source: AGHT+IGzG3pprW1zV+CicfuAaLX2b4jNgsJNZ/R632/RyLYg9shvKuj5JczM6FHjQp0XAZOQIRHu X-Received: by 2002:a62:f24e:0:b0:6e1:3d21:bacf with SMTP id y14-20020a62f24e000000b006e13d21bacfmr139964pfl.19.1709138487364; Wed, 28 Feb 2024 08:41:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709138487; cv=pass; d=google.com; s=arc-20160816; b=NPMjcK/6yl4+j6sbtaK+97QDn3NDmhBBWAvEJGrlL6FGednyOt+ddADQKEARhIOV8o yw0d0kSIYGcGtBfILq9rJvWlzarORtEUJweguTiqzueEHtvcsy8AbQR3WpgCFQmj9EmT 6HMqp79odb1Hc76ASwpZX+iBl8cOcX05xq4kGMu1AKtrJGufEKwZtKTRhYiQo/DpROGn p7lS78is9gRmWlZgC5yNdLSd8FlQjNUN+32BKjk2Tw7952Wzq6uet3saHJBiHOcqvW+D 4rO/2JSWP1d8YOKY7U386ZrvmEX0rxvw3Lq3vE7SbBqd8uLQ+nL25elpK1PHDKeaKbJq 4OEA== 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=tJgw1ruj+vuryK774yIVECmg9ZBDWhQQi6ccKVmwsro=; fh=D8N1uhCLBRzbbRgEj9aMJ2/kVuNqnMf8W9VxSJOfqPA=; b=XSc6EGsNX3oC3wGV4DeBkYOq0Sup+w3Wo7j2c4Nr11edXfby2AFY5Lw28a/kh7PCQr tliR8WgMX5/WhIgY/PSRv5eQFSl5a3Hnr9puIBedNpzoOT8OSwJ4LO7YUMVfQqEd2M+5 CnypmOW4/ccLzUHhc2e/mRnzzryUPIEMJJkdzpixzAUvmSRjvOWBE8JAXSM5KkW5OUpv 0qwuK8vq2F525LHFJSmqLu8VGS0SSZ5QXQq2Ku7yvwOilv8hpkiOrOr7nuDFUf6aQsrG +K21Xd3yVKenKCSObZN3APxayQXuD3Oz0X/BVLweNYEuDmYVmBTacVMhkPJPg1i1Kia0 Sc7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=d6K3fTGS; 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-85336-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85336-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e37-20020a635025000000b005dc504e597csi7597718pgb.513.2024.02.28.08.41.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 08:41:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85336-ouuuleilei=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=d6K3fTGS; 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-85336-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85336-ouuuleilei=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 D73B4B28A5E for ; Wed, 28 Feb 2024 16:14:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 592231649DE; Wed, 28 Feb 2024 16:12:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="d6K3fTGS" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 D67FA15E5DE; Wed, 28 Feb 2024 16:12:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709136763; cv=none; b=YECAaQMWtyaqWEzkQmN3mUKBEmg4tQL6sP7U4jTR/cEvs2e/8wWfIwM+o85O1ghZNuZm1Ru0yFDtYuZE4IW+pdbA6sGiwZ5LBtR+XtJhZv6PRhx0/TSnzDloO3WCK/W84kqUXcQ/A3yoEv3rtlOx8YH70Ds4WGOrBQwN8cNGsy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709136763; c=relaxed/simple; bh=6wo/+6fc+LTd+YM3oQ6kkcsi6l7BgZUng26rp9OSpk8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JzAVJi21fPz+D0qbxVQM2iptbPfOKuD+qNOS1YTbdGWO7nAMRiKbnoxM2qcvnfFpba8rmMjfbjYB//RVbltJ1Yibzo/9MWWjLkDBMUePRsiVbtN1pfYtWcWGBUBgc4tJhDoNoEtgIyB/mci4Zm9BJjllaVvR2qNb3TFJnKB7qrI= 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=d6K3fTGS; arc=none smtp.client-ip=192.198.163.11 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=1709136761; x=1740672761; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6wo/+6fc+LTd+YM3oQ6kkcsi6l7BgZUng26rp9OSpk8=; b=d6K3fTGSlb6V+GYse0vM0JYKMykx/JGlrRuupyV9EXaPvy/7FKCquKLJ 7jQI6z23EBOfMFoXRtCt+JYlP8panHNBu7yrndWOAPo5hWaC70hC414ai Y5KQE7iXJdfHdzBjKa1qbiz60F6KEFmpsl45w3xfCRQyIDXWPKLzNPb70 Wq0DuEtf8rl4kLZ8y8UqnVEE2rWyz2K0qV02Zradgq/hoXpnu1vfJioyT Z4Pb3ear68q0OOsjDRo2NPb5GcWo9XByH/RKjw/u2NvSH8dVNzsTwSlgQ 9UcgM0ppYGXPs0KJN43uWgMiGVCdEzgx9pPpV3vgDFRGXx81AO06Ggfly w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14185456" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="14185456" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:12:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="7418096" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by orviesa010.jf.intel.com with ESMTP; 28 Feb 2024 08:12:37 -0800 From: weilin.wang@intel.com To: weilin.wang@intel.com, Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , 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 v2 3/6] perf stat: Add retire latency values into the expr_parse_ctx to prepare for final metric calculation Date: Wed, 28 Feb 2024 11:12:24 -0500 Message-ID: <20240228161227.484886-4-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240228161227.484886-1-weilin.wang@intel.com> References: <20240228161227.484886-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792161598894098679 X-GMAIL-MSGID: 1792161598894098679 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 --- tools/perf/builtin-stat.c | 1 + tools/perf/util/metricgroup.h | 1 + tools/perf/util/stat-shadow.c | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 3890a579349e..3e5865572266 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -792,6 +792,7 @@ static int process_sample_event(struct perf_tool *tool, if (!strcmp(evname, t->name)) { t->count += 1; t->sum += sample->retire_lat; + t->val = t->count > 0 ? t->sum/t->count : 0; break; } } diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h index 1fa12cc3294e..08af0f447550 100644 --- a/tools/perf/util/metricgroup.h +++ b/tools/perf/util/metricgroup.h @@ -77,6 +77,7 @@ struct tpebs_retire_lat { const char *tpebs_name; size_t count; int sum; + double val; }; struct metric_event *metricgroup__lookup(struct rblist *metric_events, diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 3466aa952442..c63ba52004fc 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -355,6 +355,19 @@ 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, @@ -486,6 +499,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);