Re: [PATCH v2 1/4] perf pmu: Correct perf_pmu__auto_merge_stats affecting hybrid

From: Liang, Kan
Date: Thu Jun 01 2023 - 09:52:22 EST




On 2023-06-01 4:29 a.m., Ian Rogers wrote:
> Flip the return value correcting a bug.

The bug is that perf fails to create a normal core event on each hybrid
PMU even if the event is available on all hybrid PMUs.

Without the patch,

# ./perf_old stat -e inst_retired.any -a sleep 1

Performance counter stats for 'system wide':

21,760,495 cpu_core/inst_retired.any/

1.004010591 seconds time elapsed

With the patch,

# ./perf stat -e inst_retired.any -a sleep 1

Performance counter stats for 'system wide':

19,874,833 cpu_core/inst_retired.any/
3,102,256 cpu_atom/inst_retired.any/

1.004081307 seconds time elapsed

I think we need to fold the above to the description.

Thanks,
Kan
>
> Fixes: 6b9da2607030 ("perf pmu: Remove is_pmu_hybrid")
> Reported-by: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> tools/perf/util/pmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 0520aa9fe991..36e163f38368 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -1424,7 +1424,7 @@ bool perf_pmu__supports_legacy_cache(const struct perf_pmu *pmu)
>
> bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu)
> {
> - return pmu->is_core && perf_pmus__num_core_pmus() > 1;
> + return pmu->is_core && perf_pmus__num_core_pmus() == 1;
> }
>
> bool perf_pmu__have_event(const struct perf_pmu *pmu, const char *name)