]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf expr: Add #target_cpu literal
authorIan Rogers <irogers@google.com>
Tue, 11 Nov 2025 21:21:50 +0000 (13:21 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 12 Nov 2025 00:48:34 +0000 (16:48 -0800)
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>
tools/perf/util/expr.c

index 7fda0ff89c168b6bdd9ae1bbc6722c179f912e47..4df56f2b283d6fd51309006dbb44b3592107978a 100644 (file)
@@ -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);
        }