Commit 24852ef2 authored by Ian Rogers's avatar Ian Rogers Committed by Namhyung Kim

perf pmu: Treat the msr pmu as software

The msr PMU is a software one, meaning msr events may be grouped
with events in a hardware context. As the msr PMU isn't marked as a
software PMU by perf_pmu__is_software, groups with the msr PMU in
are broken and the msr events placed in a different group. This
may lead to multiplexing errors where a hardware event isn't
counted while the msr event, such as tsc, is. Fix all of this by
marking the msr PMU as software, which agrees with the driver.

Before:
```
$ perf stat -e '{slots,tsc}' -a true
WARNING: events were regrouped to match PMUs

 Performance counter stats for 'system wide':

         1,750,335      slots
         4,243,557      tsc

       0.001456717 seconds time elapsed
```

After:
```
$ perf stat -e '{slots,tsc}' -a true
 Performance counter stats for 'system wide':

        12,526,380      slots
         3,415,163      tsc

       0.001488360 seconds time elapsed
```

Fixes: 251aa040 ("perf parse-events: Wildcard most "numeric" events")
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
Cc: James Clark <james.clark@arm.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Edward Baker <edward.baker@intel.com>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Samantha Alt <samantha.alt@intel.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Link: https://lore.kernel.org/r/20240124234200.1510417-1-irogers@google.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent ac668d52
...@@ -1762,6 +1762,12 @@ bool pmu__name_match(const struct perf_pmu *pmu, const char *pmu_name) ...@@ -1762,6 +1762,12 @@ bool pmu__name_match(const struct perf_pmu *pmu, const char *pmu_name)
bool perf_pmu__is_software(const struct perf_pmu *pmu) bool perf_pmu__is_software(const struct perf_pmu *pmu)
{ {
const char *known_sw_pmus[] = {
"kprobe",
"msr",
"uprobe",
};
if (pmu->is_core || pmu->is_uncore || pmu->auxtrace) if (pmu->is_core || pmu->is_uncore || pmu->auxtrace)
return false; return false;
switch (pmu->type) { switch (pmu->type) {
...@@ -1773,7 +1779,11 @@ bool perf_pmu__is_software(const struct perf_pmu *pmu) ...@@ -1773,7 +1779,11 @@ bool perf_pmu__is_software(const struct perf_pmu *pmu)
case PERF_TYPE_BREAKPOINT: return true; case PERF_TYPE_BREAKPOINT: return true;
default: break; default: break;
} }
return !strcmp(pmu->name, "kprobe") || !strcmp(pmu->name, "uprobe"); for (size_t i = 0; i < ARRAY_SIZE(known_sw_pmus); i++) {
if (!strcmp(pmu->name, known_sw_pmus[i]))
return true;
}
return false;
} }
FILE *perf_pmu__open_file(const struct perf_pmu *pmu, const char *name) FILE *perf_pmu__open_file(const struct perf_pmu *pmu, const char *name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment