Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2201343rdb; Tue, 20 Feb 2024 23:22:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVvIR0NKdl5rqMmxPJrXZzTkmPZ4M6Wfj8Gf+gx+8IilD6ya12XR0GlkOcZaIpuKyKwbYS85fZiXo+yMulLna5bptL2ygVP2A4nLYehCA== X-Google-Smtp-Source: AGHT+IEsgEd4VFMbRH8vYdDgKpXBmAhk1u91+7hfOKl4TW7OoE4IcLecdLEADyy6T9dCGQwLlsxh X-Received: by 2002:a05:6e02:592:b0:365:55fb:9944 with SMTP id c18-20020a056e02059200b0036555fb9944mr482907ils.4.1708500152835; Tue, 20 Feb 2024 23:22:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708500152; cv=pass; d=google.com; s=arc-20160816; b=Spdz33T2UoPRhUU/HjovuISpjH0zWzFj26zhRgWYOdJnKc/Iz2eJ4KtEd0pViwthtj 9wzPNqxie+vmdF7pz6ZQjvnakI+WaKwNZAQKpn5GbRH6EhK9EUjhHJH3Bw1NOvAnEybL lV2M26DNWh8w7WKvEAMrF0LzbQagTHOoAzraS7x7wezM1ZYB96C738IUPafL2Rv43Gz3 Exfow8yGOr1GjQ+tBNvOU5ZXaGWjd42hgHjyKxDqxOJC0UDyqLXq7e9tZ4JfCseBKkEH kxHvWj59qPDH2WfDNEIrZDfjMGdoVHwL14kKqJnt5rCPk//IUdAIh/mmOiM0gJFDFCwS 269g== 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=TcVwGn170Zo5eAMEm+EjLbHVZtqXibuaZ52KocpxJtk=; fh=D8N1uhCLBRzbbRgEj9aMJ2/kVuNqnMf8W9VxSJOfqPA=; b=JD4O9mRlDfsC9GSQrXh5ox9kNb2FbgQsWMsPyBT5s+V2ZrRhPn/X7gW7yGbKaIcf75 yc37jZJ9trwhSQA1JhKSGUyG3elnznUmEjrGFg+FcCNJDZ7/Y2ikPqLAPgda5bPGPlIh 4wIS9TPJWWKAodZKIL9yUxCIE9oZq8pZS79Ha7kTFABAwhshcyecnE5LbL1AXuxanfMp EiZjx7Q1N9D4l9g+YGWy/HXIxUbU+04cOrArMxQS2n0X4x2uRQaSgH0fmLSMFQwvcvO+ ex/1CWf9Ij2jZXHGyoyir2Y+7+DCFsDDb4NX0UP/VojhxWlqPSW8zyUa3S1MzJvaFNZ0 GP7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Npx7Ky7F; 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-74213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74213-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e1-20020a631e01000000b005d2520bdefbsi7690639pge.208.2024.02.20.23.22.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 23:22:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Npx7Ky7F; 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-74213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74213-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 805672830B6 for ; Wed, 21 Feb 2024 07:22:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95A043A8DD; Wed, 21 Feb 2024 07:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Npx7Ky7F" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 0E13B3AC1B; Wed, 21 Feb 2024 07:21:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708500084; cv=none; b=jaVkXgMjC71ezH/Hb41mwvm8UT7ypLhtg5sk5BuMZbctJdRCjCwdAsO4BQf6gafdNImhveL0DvVugL6c76RLnibSbfjdXhaNOPmIBKnsJYgCzoks67u/Pf1JW26RL9VIekkB3b/QqyhB9ab9Bb6mQfL6IiHKrY+5NKMCpsdw1dk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708500084; c=relaxed/simple; bh=pBmDQG90CSvCkfKWC4qRQdDiK4qAtYJT4uG6gsEtW/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TxpUQS3Qktux386fhFIPfzTlslpAx8LUqnfxY6ePIAreyMlVdBsXkJ47bkinB7LEgl7Jtm8kKjIWMCRZNdHKTvDzQNhCaRbmFqw6eS0qFben8lpPsODX9CsM/Nct6/NRkWWSgNQdu0PlDbymTuLQ12CYp2nevZtuFKXdSg/ap6s= 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=Npx7Ky7F; arc=none smtp.client-ip=192.198.163.18 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=1708500083; x=1740036083; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pBmDQG90CSvCkfKWC4qRQdDiK4qAtYJT4uG6gsEtW/0=; b=Npx7Ky7Fb/sCATN7vrkTiWjxIiGflN4jxyinzaaKKLH/hHVH/S/fkvqZ kRhAEUL8CH+QBAHB2s/rWoiagIzJcqpnclIMqSfZs3NLoO940y48Z/1c6 7H/A7D86okzGoTBkFBV/E+gAy9ZSM4j4Y3Znl1dU5fjznJ2psX2gkYfaT 5im1nVbKjX5GXv4P7tmUAwOF3wwjGWOX0KX7oPxWLsGJF7ZTi6hD02AZ4 a4S3uXjKFRnb3gSzUV8HuzXykwrTyludFsA1qNhMKuXEloy4gRSpQNukE YYF/6PoMJqXiaPiOXEwB8g+ogxPATfjJANS8sb7BrITNMFmFPGM2PfAxy g==; X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="2530010" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="2530010" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 23:21:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="5017442" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa010.fm.intel.com with ESMTP; 20 Feb 2024 23:21:20 -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 v1 3/5] perf stat: Add retire latency values into the expr_parse_ctx to prepare for final metric calculation Date: Wed, 21 Feb 2024 02:20:57 -0500 Message-ID: <20240221072100.412939-4-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221072100.412939-1-weilin.wang@intel.com> References: <20240221072100.412939-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 --- 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 e03665af9da2..948caab9ea91 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 1c5c3eeba4cf..262a6960b461 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(struct evsel **metric_events, struct metric_ref *metric_refs, struct expr_parse_ctx *pctx, @@ -467,6 +480,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(metric_events, metric_refs, pctx, aggr_idx); if (i < 0) { expr__ctx_free(pctx); -- 2.43.0