From nobody Sun May 24 22:35:56 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 972A63FB07B for ; Wed, 20 May 2026 18:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300310; cv=none; b=thx2eJ79wUJtbdUeAFsLw7wfaXUUvZqS2XGT4dIMt54MqA7iR4EDHI+LufyGNyRAVCxHVe8mGgOy3t0yXMAYHUOeiXkVQkWGfJ3AhwuWJegbktdth2bWu4ms7Ix0Y9Q/jXqgO7HtArBuroU6lPN6rfTYWEyFrUbGfPUiJaCc64E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300310; c=relaxed/simple; bh=f8FByKZr79DkT6BMcGWxy/na+rDZcXlfSk9L5YebsZg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Rhx5eO08wspBZkLfj+yPgZdRtrw5o0O1GwkNupBSfoRZ2Jrcrl/8xStWqRc2+Q3uUi6pXGTfuXXSH+KV55kB3ZiMa5Qv7Jo30HNR0HpLqLuTF8fcQRjwu9oUA82gPSxZHXIvrcqfNtqUQ/8Wu3FCy8vRf48B9UFVLi7XE+jCO44= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ctshao.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ehLW3q8J; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ctshao.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ehLW3q8J" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-3684cb22502so4900409a91.2 for ; Wed, 20 May 2026 11:05:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779300307; x=1779905107; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FUmAxNctkKaSoLQjMgfyesaS+Z3sI58rwiPX1y4bp8o=; b=ehLW3q8JIB/yZIWuBUumckTfSH06Tyb2nigF4a9CWdPcmj/gHwhk8acqZFX9k3PjnO VWsRQ8xPC1Q7P77d2HPoxszQ0z6XPiX/xQDXpogNivDpVDzz1FxXbamZjozXF0bXs3ju o/Xy9mkTjdCrT6J6JVzOrWzrZU/NekfeHM0W0To7SwkCO+5Kwd3KRsNbYshbpo1U5EhM 6L873hukvzsakn+8jF5RdpIUOOxnyGsm1LMInEd58T6J3mQXsUaHmmJDrj0taMWO2OuU vtoy0t70NRor5G3AjcDdZCDSePtrE6wxfxZOWxZJZtc8Hh5tJ23tyC/RcVUubKhOK2JC QDSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779300307; x=1779905107; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FUmAxNctkKaSoLQjMgfyesaS+Z3sI58rwiPX1y4bp8o=; b=oObLpOe6Lorg9SnHserYbdXXMkTgmazrZwN8/XPGVTclYFV0mjTMMgIjG08XvQvPtd alWyCdy4UUS/91kb/eJ+uBpKhYis7/vBVQblD13WBJWTT2ev5JcEHlBI2zhpAumeGe1q ojNPNc92QW9ik6LC0J20VMCgRbCsqYsremE9WaUEMCZjOlicYd9UUaW+pGnI0CYpl+W6 uJSg2SJ+gdslA/qoct78A//dJFJV3Z9FaK/H77p71xZgtxB5ARnd+TzdSrHS6GN6ze7w 8+EHP7cgN8kY7qpG51f/EmQyXoDD8a6FofBiqqMhfx0/VK1J6T+jWZmtqsMDgOwg06Fh FQ3g== X-Gm-Message-State: AOJu0YyOtjHIqqWMFQHz/Ezbxji5FhQwKlw6OeGn6ieGudwIAoud+PJN JuJb+QYqgHd56NZ/FumE+vw3M1eF0ILrCE0gzNzENVxU2y1paGA9K2FZbT5QnRyhGTpyuBpOv/M VM3Vpn7ErD5vwGjPV6DeqyXLSsrjtJFBC6t53WVI32HiG2QIF0QTSYOo+kudk8GTRu9SVBRyhH3 VEkfa7H9nFV19ZFcLo9oiCAUwN8B1Hs/bEEKZa94Z6dUvg X-Received: from pjvf3.prod.google.com ([2002:a17:90a:da83:b0:369:3fa4:a760]) (user=ctshao job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2703:b0:368:7327:6326 with SMTP id 98e67ed59e1d1-369519e207cmr25146102a91.1.1779300306674; Wed, 20 May 2026 11:05:06 -0700 (PDT) Date: Wed, 20 May 2026 10:58:21 -0700 In-Reply-To: <20260520180032.3045144-1-ctshao@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260520180032.3045144-1-ctshao@google.com> X-Mailer: git-send-email 2.54.0.669.g59709faab0-goog Message-ID: <20260520180032.3045144-2-ctshao@google.com> Subject: [PATCH 1/2] perf stat: Add aggr_nr metric parser support From: Chun-Tse Shao To: linux-kernel@vger.kernel.org Cc: Chun-Tse Shao , peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, james.clark@linaro.org, leo.yan@arm.com, thomas.falcon@intel.com, yang.lee@linux.alibaba.com, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce the `aggr_nr` function to the metric expression parser. `aggr_nr` allows metric formulas to dynamically utilize the number of aggregated targets (`aggr->nr`) instead of relying on the static `source_count` (which represents the static socket or node count). This adds the `AGGR_NR` token to the lexer and parser, updates the expression parsing context helpers to store `aggr_nr`, and feeds `aggr->nr` from the aggregation structure in `prepare_metric`. Signed-off-by: Chun-Tse Shao --- tools/perf/util/expr.c | 27 +++++++++++++++++++++++---- tools/perf/util/expr.h | 4 ++++ tools/perf/util/expr.l | 1 + tools/perf/util/expr.y | 24 +++++++++++++++++------- tools/perf/util/stat-shadow.c | 4 +++- 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c index 644769e92708..8d00805f93c4 100644 --- a/tools/perf/util/expr.c +++ b/tools/perf/util/expr.c @@ -27,6 +27,7 @@ struct expr_id_data { struct { double val; int source_count; + int aggr_nr; } val; struct { double val; @@ -151,8 +152,8 @@ int expr__add_id_val(struct expr_parse_ctx *ctx, const = char *id, double val) } /* Caller must make sure id is allocated */ -int expr__add_id_val_source_count(struct expr_parse_ctx *ctx, const char *= id, - double val, int source_count) +int expr__add_id_val_source_count_aggr_nr(struct expr_parse_ctx *ctx, cons= t char *id, + double val, int source_count, int aggr_nr) { struct expr_id_data *data_ptr =3D NULL, *old_data =3D NULL; char *old_key =3D NULL; @@ -163,6 +164,7 @@ int expr__add_id_val_source_count(struct expr_parse_ctx= *ctx, const char *id, return -ENOMEM; data_ptr->val.val =3D val; data_ptr->val.source_count =3D source_count; + data_ptr->val.aggr_nr =3D aggr_nr; data_ptr->kind =3D EXPR_ID_DATA__VALUE; ret =3D hashmap__set(ctx->ids, id, data_ptr, &old_key, &old_data); @@ -177,6 +179,14 @@ int expr__add_id_val_source_count(struct expr_parse_ct= x *ctx, const char *id, return ret; } +/* Caller must make sure id is allocated */ +int expr__add_id_val_source_count(struct expr_parse_ctx *ctx, const char *= id, + double val, int source_count) +{ + return expr__add_id_val_source_count_aggr_nr(ctx, id, val, source_count, = 1); +} + + int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref) { struct expr_id_data *data_ptr =3D NULL, *old_data =3D NULL; @@ -390,10 +400,19 @@ double expr_id_data__value(const struct expr_id_data = *data) double expr_id_data__source_count(const struct expr_id_data *data) { - assert(data->kind =3D=3D EXPR_ID_DATA__VALUE); - return data->val.source_count; + if (data->kind =3D=3D EXPR_ID_DATA__VALUE) + return data->val.source_count; + return 1.0; } +double expr_id_data__aggr_nr(const struct expr_id_data *data) +{ + if (data->kind =3D=3D EXPR_ID_DATA__VALUE) + return data->val.aggr_nr; + return 1.0; +} + + double expr__get_literal(const char *literal, const struct expr_scanner_ct= x *ctx) { double result =3D NAN; diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h index c0cec29ddc29..865bb63cdb03 100644 --- a/tools/perf/util/expr.h +++ b/tools/perf/util/expr.h @@ -37,6 +37,8 @@ int expr__add_id(struct expr_parse_ctx *ctx, const char *= id); int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double va= l); int expr__add_id_val_source_count(struct expr_parse_ctx *ctx, const char *= id, double val, int source_count); +int expr__add_id_val_source_count_aggr_nr(struct expr_parse_ctx *ctx, cons= t char *id, + double val, int source_count, int aggr_nr); int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref); int expr__get_id(struct expr_parse_ctx *ctx, const char *id, struct expr_id_data **data); @@ -53,6 +55,8 @@ int expr__find_ids(const char *expr, const char *one, double expr_id_data__value(const struct expr_id_data *data); double expr_id_data__source_count(const struct expr_id_data *data); +double expr_id_data__aggr_nr(const struct expr_id_data *data); + double expr__get_literal(const char *literal, const struct expr_scanner_ct= x *ctx); double expr__has_event(const struct expr_parse_ctx *ctx, bool compute_ids,= const char *id); double expr__strcmp_cpuid_str(const struct expr_parse_ctx *ctx, bool compu= te_ids, const char *id); diff --git a/tools/perf/util/expr.l b/tools/perf/util/expr.l index a2fc43159ee9..f16ccff278d0 100644 --- a/tools/perf/util/expr.l +++ b/tools/perf/util/expr.l @@ -121,6 +121,7 @@ min { return MIN; } if { return IF; } else { return ELSE; } source_count { return SOURCE_COUNT; } +aggr_nr { return AGGR_NR; } has_event { return HAS_EVENT; } strcmp_cpuid_str { return STRCMP_CPUID_STR; } NaN { return nan_value(yyscanner); } diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y index e364790babb5..e20f649354cf 100644 --- a/tools/perf/util/expr.y +++ b/tools/perf/util/expr.y @@ -41,7 +41,7 @@ int expr_lex(YYSTYPE * yylval_param , void *yyscanner); } ids; } -%token ID NUMBER MIN MAX IF ELSE LITERAL D_RATIO SOURCE_COUNT HAS_EVENT ST= RCMP_CPUID_STR EXPR_ERROR +%token ID NUMBER MIN MAX IF ELSE LITERAL D_RATIO SOURCE_COUNT AGGR_NR HAS_= EVENT STRCMP_CPUID_STR EXPR_ERROR %left MIN MAX IF %left '|' %left '^' @@ -87,8 +87,14 @@ static struct ids union_expr(struct ids ids1, struct ids= ids2) return result; } +enum expr_id_kind { + EXPR_ID_KIND__VALUE, + EXPR_ID_KIND__SOURCE_COUNT, + EXPR_ID_KIND__AGGR_NR, +}; + static struct ids handle_id(struct expr_parse_ctx *ctx, char *id, - bool compute_ids, bool source_count) + bool compute_ids, enum expr_id_kind kind) { struct ids result; @@ -101,9 +107,12 @@ static struct ids handle_id(struct expr_parse_ctx *ctx= , char *id, result.val =3D NAN; if (expr__resolve_id(ctx, id, &data) =3D=3D 0) { - result.val =3D source_count - ? expr_id_data__source_count(data) - : expr_id_data__value(data); + if (kind =3D=3D EXPR_ID_KIND__SOURCE_COUNT) + result.val =3D expr_id_data__source_count(data); + else if (kind =3D=3D EXPR_ID_KIND__AGGR_NR) + result.val =3D expr_id_data__aggr_nr(data); + else + result.val =3D expr_id_data__value(data); } result.ids =3D NULL; free(id); @@ -201,8 +210,9 @@ expr: NUMBER $$.val =3D $1; $$.ids =3D NULL; } -| ID { $$ =3D handle_id(ctx, $1, compute_ids, /*source_count=3D*/false)= ; } -| SOURCE_COUNT '(' ID ')' { $$ =3D handle_id(ctx, $3, compute_ids, /*sourc= e_count=3D*/true); } +| ID { $$ =3D handle_id(ctx, $1, compute_ids, EXPR_ID_KIND__VALUE); } +| SOURCE_COUNT '(' ID ')' { $$ =3D handle_id(ctx, $3, compute_ids, EXPR_ID= _KIND__SOURCE_COUNT); } +| AGGR_NR '(' ID ')' { $$ =3D handle_id(ctx, $3, compute_ids, EXPR_ID_KIN= D__AGGR_NR); } | HAS_EVENT '(' ID ')' { $$.val =3D expr__has_event(ctx, compute_ids, $3); diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index bc2d44df7baf..e375f6f942be 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -53,6 +53,7 @@ static int prepare_metric(struct perf_stat_config *config, for (i =3D 0; metric_events[i]; i++) { int source_count =3D 0, tool_aggr_idx; + int aggr_nr =3D 1; bool is_tool_time =3D tool_pmu__is_time_event(config, metric_events[i], &tool_aggr_idx); struct perf_stat_evsel *ps =3D metric_events[i]->stats; @@ -104,13 +105,14 @@ static int prepare_metric(struct perf_stat_config *co= nfig, } if (!source_count) source_count =3D evsel__source_count(metric_events[i]); + aggr_nr =3D aggr->nr ?: 1; } } n =3D strdup(evsel__metric_id(metric_events[i])); if (!n) return -ENOMEM; - expr__add_id_val_source_count(pctx, n, val, source_count); + expr__add_id_val_source_count_aggr_nr(pctx, n, val, source_count, aggr_n= r); } for (int j =3D 0; metric_refs && metric_refs[j].metric_name; j++) { -- 2.54.0.669.g59709faab0-goog From nobody Sun May 24 22:35:56 2026 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DE7C3FB074 for ; Wed, 20 May 2026 18:05:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300323; cv=none; b=itH0+r8xsapwZZUR4YvBRLvA32mX2mjXTiyALl8hkr98o1NvYoBi2F3ih+QIMvqlUKkTrZDKKMbNjKkywS8Kr18/WNRa6x+yjwtmskBNOSPtPHLtOap75sfHc0S5uM9XswjY5V7CS/kq0OoWdY9++9pqRS5kRsX2o5BUM1Tk4Ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300323; c=relaxed/simple; bh=sIEA+CmW18QpPvy2pvsIC0vFH+Tb50rCXUcoDoQHWNU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=c8qEdfpyNJ48Nvgqr1ak9PZ3AJzDuQHlSus/qz9tVdyL7I5u2VYPGkRL1JmDxjb3eiSrnvjnvZRx7Y88pYeRXcUNLqXQ0tl2+Bwqd2k8QeLyLYfSmnPMuCE48leCm004bmi+dp71/LDhn6OjZ1sLOeaOOZ+o5fniCrijpB4C0XE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ctshao.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lfc3plLn; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ctshao.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lfc3plLn" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2babbeff9e4so55989145ad.0 for ; Wed, 20 May 2026 11:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779300322; x=1779905122; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=O/4UM21HNphfC3/apIv+GViPAA1EhF64J1eocrwZvEY=; b=lfc3plLntnGsLxA67uvIETlkc11aaU44hAXo1MFTuA/fSKiJC8fJdpCwxVjf4K6BhK RWuhyOBa6WkU8pjobHJJcsDMeM8aCuvXI6Q86U/BVfdkpVtLaBugdBRnEWDrD7+038rK P2/CFsRCeX0YK9anyRuRG8SrNTGIMKnN0AE3GiqO1VAt+0ZbgV9Sme+qrq01kv0d09F7 5KR/Gv3oQBue0o/+4sy21RzKfLKRAmGsHDp7zKTopbKJmjpND3gxs8dCVmVUEy25oyMe biwZjIB6S2Fue6ckYKpHojvHrsZkDU0FWv0uqO18MGHzjVrksTkxGKrKNqnsLjlKMwA4 gAkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779300322; x=1779905122; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=O/4UM21HNphfC3/apIv+GViPAA1EhF64J1eocrwZvEY=; b=aX9jNpt7+k/QqiwZk7WavsRj1aIRxVP71W3+dJqw9UTGp79j02UXB82pZZwWHjGyaD JrBG4I567oaWLbezcLJYBDB3en0lOnbBBbdzU+2bIGxOamZ5sI7ZFjtEYxnxLEd8Mn68 tWQDeF0VfqwDC7lOfjfbLCzbZDxI5DPFfrdpRXyuZvAj9f4bhnmltZuGws+H3LvlzPMB b5orEFvS/LRZpbQXSjDCOnvMz6CoN88PtSeD5m7+84VTOq8kDsN6GYN9dDj/riWb2r99 EB5alwGorEeI9JsfOfTwL2oNxeWgJjLq60z/Aw5EJvRYvJ3eZoJDBomAdhH+xNEbaMzZ l8sQ== X-Gm-Message-State: AOJu0YzTVjKZEG+wsKhVDG9w+Nc45vfoCr1MAtaZirMvqNMJULtmIess C2/I+4UevoQ83dmHGk8VEseJTfyiyD/NLcO3X+n2PDvnwYzyRmkwENhXV1tPmxzaYMB6N6ihKKd WGRnwjztlsYOs+Kwe9g40TuBkbVoR4W8i7y34iaIhE3Gd3buew+pgQoq4SPNbOFM79g1HE4UJmY 3LTAubHvq/5w0Sk/Izc33LNNyt55SmOV3P0tszG0PdNrUF X-Received: from plkk11.prod.google.com ([2002:a17:902:c40b:b0:2bc:c1af:322f]) (user=ctshao job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1aef:b0:2bc:dc1c:438e with SMTP id d9443c01a7336-2be9d40fc9amr4566345ad.11.1779300321595; Wed, 20 May 2026 11:05:21 -0700 (PDT) Date: Wed, 20 May 2026 10:58:22 -0700 In-Reply-To: <20260520180032.3045144-1-ctshao@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260520180032.3045144-1-ctshao@google.com> X-Mailer: git-send-email 2.54.0.669.g59709faab0-goog Message-ID: <20260520180032.3045144-3-ctshao@google.com> Subject: [PATCH 2/2] perf stat: Use aggr_nr scaling for Intel uncore miss latency metrics From: Chun-Tse Shao To: linux-kernel@vger.kernel.org Cc: Chun-Tse Shao , peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, james.clark@linaro.org, sandipan.das@amd.com, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update `metric.py` to support the new `aggr_nr` keyword in the python metric generator. Replace the usage of `source_count` with `aggr_nr` in `IntelMissLat` inside `intel_metrics.py` so that uncore latency metrics (like `lpm_miss_lat`) scale correctly on multi-socket and SNC systems when aggregated globally. Signed-off-by: Chun-Tse Shao --- tools/perf/pmu-events/intel_metrics.py | 8 ++++---- tools/perf/pmu-events/metric.py | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events= /intel_metrics.py index 52035433b505..50d5a20fa354 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -5,9 +5,9 @@ import json import math import os import re -from typing import Optional +from typing import List, Optional from common_metrics import Cycles -from metric import (d_ratio, has_event, max, source_count, CheckPmu, Event, +from metric import (d_ratio, has_event, max, aggr_nr, CheckPmu, Event, JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, Literal, LoadEvents, Metric, MetricConstraint, MetricG= roup, MetricRef, Select) @@ -674,10 +674,10 @@ def IntelMissLat() -> Optional[MetricGroup]: else: assert data_rd_loc_occ.name =3D=3D "UNC_CHA_TOR_OCCUPANCY.IA_MISS_= DRD_LOCAL", data_rd_loc_occ =20 - ticks_per_cha =3D ticks / source_count(data_rd_loc_ins) + ticks_per_cha =3D ticks / aggr_nr(data_rd_loc_ins) loc_lat =3D interval_sec * 1e9 * data_rd_loc_occ / \ (ticks_per_cha * data_rd_loc_ins) - ticks_per_cha =3D ticks / source_count(data_rd_rem_ins) + ticks_per_cha =3D ticks / aggr_nr(data_rd_rem_ins) rem_lat =3D interval_sec * 1e9 * data_rd_rem_occ / \ (ticks_per_cha * data_rd_rem_ins) return MetricGroup("lpm_miss_lat", [ diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric= .py index ac582db785fc..424659b021ff 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -93,7 +93,7 @@ def CheckEveryEvent(*names: str) -> None: name =3D name[:name.find(':')] elif '/' in name: name =3D name[:name.find('/')] - if any([name.startswith(x) for x in ['amd', 'arm', 'cpu', 'msr', 'po= wer']]): + if any([name.startswith(x) for x in ['amd', 'arm', 'cpu', 'msr', 'po= wer', 'cha', 'uncore']]): continue if name not in all_events_all_models: raise Exception(f"Is {name} a named json event?") @@ -576,6 +576,13 @@ def source_count(event: Event) -> Function: return Function('source_count', event) =20 =20 +def aggr_nr(event: Event) -> Function: + # pylint: disable=3Dredefined-builtin + # pylint: disable=3Dinvalid-name + return Function('aggr_nr', event) + + + def has_event(event: Event) -> Function: # pylint: disable=3Dredefined-builtin # pylint: disable=3Dinvalid-name @@ -762,7 +769,7 @@ def ParsePerfJson(orig: str) -> Expression: # Convert accidentally converted scientific notation constants back py =3D re.sub(r'([0-9]+)Event\(r"(e[0-9]*)"\)', r'\1\2', py) # Convert all the known keywords back from events to just the keyword - keywords =3D ['if', 'else', 'min', 'max', 'd_ratio', 'source_count', 'ha= s_event', 'strcmp_cpuid_str'] + keywords =3D ['if', 'else', 'min', 'max', 'd_ratio', 'source_count', 'ag= gr_nr', 'has_event', 'strcmp_cpuid_str'] for kw in keywords: py =3D re.sub(rf'Event\(r"{kw}"\)', kw, py) try: --=20 2.54.0.669.g59709faab0-goog