summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2025-11-11 13:21:50 -0800
committerNamhyung Kim <namhyung@kernel.org>2025-11-11 16:48:34 -0800
commit2e5140849b021889cf4dd8df5d2352e508213607 (patch)
tree2f7f0bf4e86d90d12d5bca16ecb0d224eacd8ae2
parentc8035a496141b9c05dc3ce034c7a1d4b64f4eccb (diff)
perf expr: Add #target_cpu literal
For CPU nanoseconds a lot of the stat-shadow metrics use either task-clock or cpu-clock, the latter being used when target__has_cpu. Add a #target_cpu literal so that json metrics can perform the same test. Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
-rw-r--r--tools/perf/util/expr.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
index 7fda0ff89c16..4df56f2b283d 100644
--- a/tools/perf/util/expr.c
+++ b/tools/perf/util/expr.c
@@ -409,6 +409,9 @@ double expr__get_literal(const char *literal, const struct expr_scanner_ctx *ctx
} else if (!strcmp("#core_wide", literal)) {
result = core_wide(ctx->system_wide, ctx->user_requested_cpu_list)
? 1.0 : 0.0;
+ } else if (!strcmp("#target_cpu", literal)) {
+ result = (ctx->system_wide || ctx->user_requested_cpu_list)
+ ? 1.0 : 0.0;
} else {
pr_err("Unrecognized literal '%s'", literal);
}