From e565ceb48bbf82cc4db4a42a33e378fe30d8d010 Mon Sep 17 00:00:00 2001 From: Chun-Tse Shao Date: Thu, 21 May 2026 13:15:04 -0700 Subject: perf stat: Add aggr_nr metric parser support 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`. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Chun-Tse Shao Tested-by: Zide Chen Acked-by: Namhyung Kim Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Ian Rogers Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Leo Yan Cc: Mark Rutland Cc: Peter Zijlstra Cc: Sandipan Das Cc: Thomas Falcon Cc: Yang Li Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/expr.l | 1 + 1 file changed, 1 insertion(+) (limited to 'tools/perf/util/expr.l') 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); } -- cgit v1.2.3