Re: [PATCH v3 1/3] perf: Skip and warn on unknown format 'configN' attrs

From: Leo Yan
Date: Thu Oct 06 2022 - 01:45:18 EST


On Tue, Oct 04, 2022 at 12:07:30PM -0500, Rob Herring wrote:

[...]

> > INIT_LIST_HEAD(&perf_pmu__fake.format);
>
> I ended up fixing this in perf_pmu__warn_invalid_formats() instead as
> the test dealing with internal stuct pmu details didn't seem right:
>
> + /* fake pmu doesn't have format list */
> + if (pmu == &perf_pmu__fake)
> + return;
> +

Good point. It would be even better to fix it in the first place
rather than checking fake PMU in perf_pmu__warn_invalid_formats(),
how about below fixing in util/pmu.c?

-struct perf_pmu perf_pmu__fake;
+struct perf_pmu perf_pmu__fake = {
+ .format = LIST_HEAD_INIT(perf_pmu__fake.format),
+};

Thanks,
Leo