Re: [PATCH] perf script: Fix output type for dynamically allocated core PMU's

From: Ravi Bangoria
Date: Fri Dec 13 2024 - 02:07:49 EST


Hi Thomas,

> @@ -386,6 +386,8 @@ static int evsel_script__fprintf(struct evsel_script *es, FILE *fp)
>
> static inline int output_type(unsigned int type)
> {
> + struct perf_pmu *pmu;
> +
> switch (type) {
> case PERF_TYPE_SYNTH:
> return OUTPUT_TYPE_SYNTH;
> @@ -394,6 +396,10 @@ static inline int output_type(unsigned int type)
> return type;
> }
>
> + pmu = perf_pmus__find_by_type(type);
> + if (pmu && pmu->is_core)
> + return PERF_TYPE_RAW;

Minor nit ...

output_type() seems to be getting called a lot. For ex, for a perf.data
with 4530 samples, output_type() was called 181246 times when I ran
"perf script". IIUC, this pmu lookup is unnecessary for homogeneous
platforms? If so, can we make it conditional?

Thanks,
Ravi