]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf pmu: Make pmu_alias_terms weak again
authorIan Rogers <irogers@google.com>
Sun, 9 Nov 2025 00:59:58 +0000 (16:59 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Mon, 10 Nov 2025 07:07:57 +0000 (23:07 -0800)
The terms for a json event should be weak so they don't override
command line options.

Before:
```
$ perf record -vv -c 1000 -e uops_issued.any -o /dev/null true 2>&1
|grep "{ sample_period, sample_freq }"
 { sample_period, sample_freq }   200003
 { sample_period, sample_freq }   2000003
 { sample_period, sample_freq }   1000
```

After:
```
$ perf record -vv -c 1000 -e uops_issued.any -o /dev/null true 2>&1
|grep "{ sample_period, sample_freq }"
 { sample_period, sample_freq }   1000
 { sample_period, sample_freq }   1000
 { sample_period, sample_freq }   1000
```

Fixes: 84bae3af20d0 ("perf pmu: Don't eagerly parse event terms")
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/pmu.c

index d597263fab4f7ef5f3dd98292969f3da54adbe44..f14f2a12d061524cad8bf682928c8a84820c7a31 100644 (file)
@@ -802,6 +802,7 @@ static int pmu_aliases_parse_eager(struct perf_pmu *pmu, int sysfs_fd)
 static int pmu_alias_terms(struct perf_pmu_alias *alias, struct list_head *terms)
 {
        struct parse_events_terms alias_terms;
+       struct parse_events_term *term;
        int ret;
 
        parse_events_terms__init(&alias_terms);
@@ -812,6 +813,13 @@ static int pmu_alias_terms(struct perf_pmu_alias *alias, struct list_head *terms
                parse_events_terms__exit(&alias_terms);
                return ret;
        }
+       list_for_each_entry(term, &alias_terms.terms, list) {
+               /*
+                * Weak terms don't override command line options,
+                * which we don't want for implicit terms in aliases.
+                */
+               term->weak = true;
+       }
        list_splice_init(&alias_terms.terms, terms);
        parse_events_terms__exit(&alias_terms);
        return 0;