Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2345809lqz; Tue, 2 Apr 2024 14:46:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUzAX9aY2ToObxntHiSqMZb9fWH9u1WdbBxetLj/EdqBGOThWc+EMFrrvZpKGC0qhCOsAYhnDu9/DPO4Q5GQ4yzV1lLe3UdG6ygnyV0iw== X-Google-Smtp-Source: AGHT+IH3RV+qPIvMwPWr+sAkd/KXr1Fg76MxVMjkroMS3zXvZOLS9Fmg2jA7kduyKP899WuawkBv X-Received: by 2002:a05:6a20:3d06:b0:1a7:177:4517 with SMTP id y6-20020a056a203d0600b001a701774517mr14156585pzi.49.1712094404589; Tue, 02 Apr 2024 14:46:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712094404; cv=pass; d=google.com; s=arc-20160816; b=XiDlV2SfEKxfSZ15uL2yBsB1ms0NrBzRKjP71/WPn3sybkQcca/fxSU/0MihdVMvHK dvShhZ05B0y8pyX4on7XuoFbCehin3b1vwsmrG+ivfY7n1odo1yX/ziCgADq5aOxr2uN 2emP6jY+LSqvPRwmBvdlQ9ij2jxsy9IJYurAqhSZQ5nF9S12Y7/8XYGnBl6IXEpCAkSE Zg2pPUnxuHTXZF+lRtJtsLPNSioOqBIPGKtbo/emdGn31rE6YI4XcDFh54MxJV8DW4Xw tDKA6HOusSDhx67jxJnFUK3miV53E/BYtjEHMIABBHDfqPucDjNN8sg04AWqsHq6EN8Q zjOw== 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=CMxkD6J0KSI88Iqvik3LQKhnt8bvAY9Kmm8nmqxrcgc=; fh=7D8bWqELNqJM6KF7zbibUOya8038rGAdDMFXsJMRu8c=; b=pey5KG/oWFsF8Oja38IvB+cPvwDUbPV5pzsyggRVKZPxeqeUPSSYHxOBj1Q2O5RNTG Ud8I0DIsmnvmd6XPu330fuPutNlY3kL7Y7aC+Ly2vPj0tB955PuEFUZy0EouCKzn33Aw 5oWhyLBRVdKhdubLoAXR4vHRTA+p/374VZQVm4pKM3RcQ4m9qvhQZMNewL15vqbLaJa+ qaJjV8irPYbqu5nX/w8gTb1dP+v23w34uq0MkM0JAvwDvNIPOZIscDEBTUKfkz8SzFxL 4DT2QHJHgt3LjXfuMJv60Aio5AOQOngOGnDMhMGl7Z2aS46H0NuUpQ5Kok+Gwthb6zQX x7jQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fdGyjJVF; 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-128746-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128746-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. [139.178.88.99]) by mx.google.com with ESMTPS id h20-20020a631214000000b005f3c8f1f441si2944936pgl.640.2024.04.02.14.46.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 14:46:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128746-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fdGyjJVF; 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-128746-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128746-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 3E2B2289611 for ; Tue, 2 Apr 2024 21:46:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D5BA15ECE7; Tue, 2 Apr 2024 21:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fdGyjJVF" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 CC2EA15E801; Tue, 2 Apr 2024 21:46:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712094375; cv=none; b=QYbVkwUlAxA83UpUU2wzi0oQB9C8xusyfw58Yl1XgmrOvHwyhgYtc++9arGA85bgNUXiaBEVP2cAKtpi9ElqnBWhTrs33rikIiTOGlSGh/FDqeiPCxjgQ/3D68Kg7EgsbQdcuh9W5aP3lONUCmcSTqbEjSW/DZm00xZe0y7KtAQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712094375; c=relaxed/simple; bh=2lHSEpJTsedWv+KHgknqQO3JpNz+YAg/uqo64Wkj/Zo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jTMsWvwyHSVF3VrHbWA9TAF7rR2xUQ7PUzUjw3DLZ6JlSJ2JnTOmtutel7/LUFEQEPOznQCKbs7yzWkTIIpkleHI73OEA328ICVGCyqNoEpOLV1+6o61L3Uj7sKyvJ0mSMakw4RIpo4UUI1EPAjm4bft+UX5S4hdEpVqlGJyiSY= 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=fdGyjJVF; arc=none smtp.client-ip=192.198.163.9 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=1712094374; x=1743630374; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2lHSEpJTsedWv+KHgknqQO3JpNz+YAg/uqo64Wkj/Zo=; b=fdGyjJVF3bTQtquN7KhhOZNI2ru1QleIP3O+7pL+SUT//tFBk+etzd13 NFIyhl5Yh5+W3pwCpX7olgJzslTkpnRvvWx1/GRDDABhKxq26kowPHmCG jSOdait3/6jr3bppkqIvMOq6J1QMMQS+WUr3JpZmhTojm5RvVb/+TxFkL DB5kIJWUKPBAyU95UbcPD/y/r5rfWTLi88ggTkcV3e0nXPrgmFJBt6l0U SQjAM08OmQ/U/2GZ529cB7SdJYXIW1upwUKgh8hLHGIk+q/BIa9QhwFqZ 2p+BZTXBCgM2okpIR18RukuYWaci9aGZO07p5fZh1vNqI8CssKxTZxjyy Q==; X-CSE-ConnectionGUID: /J719p/tTo+b2d3Qjmo+Mw== X-CSE-MsgGUID: 863Kr1m6RWKRDlFNcZhj/w== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="18020021" X-IronPort-AV: E=Sophos;i="6.07,176,1708416000"; d="scan'208";a="18020021" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 14:45:05 -0700 X-CSE-ConnectionGUID: 1rRHjqmfQ3yvHUK1yoob8Q== X-CSE-MsgGUID: lRFKOsFQRqOEfD99O9qttg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,176,1708416000"; d="scan'208";a="22849088" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa004.fm.intel.com with ESMTP; 02 Apr 2024 14:45:04 -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 v7 4/6] perf stat: Add retire latency values into the expr_parse_ctx to prepare for final metric calculation Date: Tue, 2 Apr 2024 17:44:34 -0400 Message-ID: <20240402214436.1409476-5-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240402214436.1409476-1-weilin.wang@intel.com> References: <20240402214436.1409476-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/builtin-stat.c | 1 + tools/perf/util/metricgroup.h | 4 ++++ tools/perf/util/stat-shadow.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 2dcc1a12f7ef..bf8045f0b879 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -816,6 +816,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused, if (!strcmp(evname, t->event.name)) { t->count += 1; t->sum += sample->retire_lat; + t->val = (double) t->sum / t->count; break; } } diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h index ae788edef30f..d63209b29bf1 100644 --- a/tools/perf/util/metricgroup.h +++ b/tools/perf/util/metricgroup.h @@ -76,8 +76,12 @@ struct tpebs_event { struct tpebs_retire_lat { struct tpebs_event event; + /* Count of retire_latency values found in sample data */ size_t count; + /* Sum of all the retire_latency values in sample data */ int sum; + /* Average of retire_latency, val = sum / count */ + 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..bc77e9e02892 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -355,6 +355,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, event.nd) { + ret = expr__add_id_val(pctx, strdup(t->event.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 +500,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