Received: by 2002:ab2:f03:0:b0:1ef:ffd0:ce49 with SMTP id i3csp38752lqf; Tue, 26 Mar 2024 13:35:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXA00pIao8CLEoXSZCD5XGI507+ejIrI1eMtTNUHr3JVUlGH+cCPSBEMHSdDLxlhsuPOfQgB/x5dgREmqthJMdjURO5tEQEDrWjS9598Q== X-Google-Smtp-Source: AGHT+IEVmYY3zXefn4tXlaO+lMCb36cG/PSjGNzM7ueUhQJW7B6OI90Qco37xrKboEq27CKkw58W X-Received: by 2002:a17:907:94c9:b0:a4d:fc83:70e1 with SMTP id dn9-20020a17090794c900b00a4dfc8370e1mr866071ejc.56.1711485347444; Tue, 26 Mar 2024 13:35:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711485347; cv=pass; d=google.com; s=arc-20160816; b=rnYgv+66s2ryGD/qplOL7MtZxd7GBKndk8hCJ6SFunHvAeVtFM7Pk9ZVDoyUEP4Of2 il4FnIJf6zJb6fA4EZ/A4He8VXublpNl9RkcZ1gLEN1EcbCDzCZd08jIxnjH84G5/e8C 5A7UUJ6HDdzFZxnynnulvAVONJQnleXkgJMoA41XT2UocregT+0lzTWJsSpaNan+xQCn qp8LYYd9j53ScWVXO21JQ3UN+p7ZJ1iGMS6rlmuSSS8ld9c6sq6MOw9oELr7Lhb9gHNh sydPmtAGTXBP0FMzi6S9n83hZiEjXXaR69sqVFJwKk0JA2GAiAjgHooR0CgZiIWqoFZl HqoQ== 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=Al+6JRmoDN86lxKQxNVu5jacbzoZH7+wp4abWIOmvm8=; fh=7D8bWqELNqJM6KF7zbibUOya8038rGAdDMFXsJMRu8c=; b=AwkRi97Q/1BK8FlJsZru2GO04Nap2h+3JGfbvDMZ0zKL0ASQKWB1xxsVEu91d1zQUE hhm2P9FUoKuJ7n8ii6fzKqssa7b/BxVwvu2sP1tABZZAlj94g/5SyA+SLq3idsSCBoOi zRC4j04tn6i/SlPjdyK8DQMi6tlkVdFnAkUHxOsag3G0A+B2xmVdzcF05VWMp0n6eNX3 63N6zVpkGa1m416YkXOi6z8UV0ZqXCbv2liPUo/ldn/n2cYJ/8i4+7jP4rS9Y4AmC0wT fKk1n4CXE716nHKc9UPkewAfsdJvQGorT/qagyF/slzHPBPteO7BMulDaoW2cPubmgxn Eo7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Im8aBC0n; 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-119919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119919-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f25-20020a170906561900b00a4856b1646bsi2533958ejq.824.2024.03.26.13.35.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 13:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Im8aBC0n; 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-119919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119919-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 29CE31FA03F2 for ; Tue, 26 Mar 2024 20:35:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B15D513F424; Tue, 26 Mar 2024 20:29:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Im8aBC0n" 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 0A04F13E89C; Tue, 26 Mar 2024 20:29:34 +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=1711484976; cv=none; b=Hk95rFrRM7idDvtesY0s63pR0dmDvYrwfmwkId//kX8z9hdw4QchQNKbxAZVJQ2qb0Z08TBA5GYrz+6mfrD/exaKtKjmFdz+4Z/4FL0jIti9g8lZxRnRbVP84ZNs5pkz/yctxy+q7K1nlAkX33/VvE/q3TZ1Xp7P6kur37IWPOw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711484976; c=relaxed/simple; bh=J13VmURiiNTORSB+guGyg+TlES2kTP6wTgLMxrN+wOg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bg4yjpG28C5TgZrmOVpfZVClGfG2M8ZaICVigb9HTp4JBEh6qS/kx5GtAA4EWPf+Zj7aAIy9mHPBODAXrrKE6JRV+uXO4i9r+PKeOfuauYQzdPCMTR8t6hb4/QY5/8VsnFD/hPEhbMvxI7UkAh5zZKJhowWSGGmrbZrLsfyVIw8= 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=Im8aBC0n; 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=1711484975; x=1743020975; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J13VmURiiNTORSB+guGyg+TlES2kTP6wTgLMxrN+wOg=; b=Im8aBC0ngIfjAimYYKjK8g2jK+ncaHXA2fJsxhgvsIA3WykdPSaSA+z+ LmIgoJurRZKUuazF4kjGJmN3BTU2N0itmE+NMpRgXZbPAQFAvZXc+wkxd WXrGdR2GdsoZoInPkJo+JDUiNLLRPC+SpKd9//9TD897l5OUno/6H5FrH RWax95ckljyNZ3IdQqVSxLUTFb1XNbgU+PEl2isLpCBfHqq6QhS6b2iIk gYxuoByAAZ+hQ2hh8u5O/BzZBKn6h9upNaCHdfr+9kHa4bdnmmy1izbtv 7j+AM2WeXm1QRLTq8awFQ9naBgjmTrrch5kbNB/2cI4SU9x4XcJX0Ltv4 A==; X-CSE-ConnectionGUID: 32pTqn67SaCwtu4kAtRbFQ== X-CSE-MsgGUID: Riyi8/HjQk2WOGw+7Ld6lA== X-IronPort-AV: E=McAfee;i="6600,9927,11025"; a="24049087" X-IronPort-AV: E=Sophos;i="6.07,157,1708416000"; d="scan'208";a="24049087" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2024 13:29:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,157,1708416000"; d="scan'208";a="16163010" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa008.fm.intel.com with ESMTP; 26 Mar 2024 13:29:32 -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 v5 3/6] perf stat: Add retire latency values into the expr_parse_ctx to prepare for final metric calculation Date: Tue, 26 Mar 2024 16:28:56 -0400 Message-ID: <20240326202859.960577-4-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240326202859.960577-1-weilin.wang@intel.com> References: <20240326202859.960577-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 fb08cef42d95..fc887d9aaa66 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -786,6 +786,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 e5bafb45d4d9..b073682b4067 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..8fc3415de106 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, 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 +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