Re: [PATCH 02/21] perf pmu: Add const to pmu_events_map.

From: Andrew Kilroy
Date: Fri Oct 08 2021 - 11:23:04 EST




On 08/10/2021 12:01, John Garry wrote:
On 07/10/2021 17:56, Ian Rogers wrote:
The pmu_events_map is generated at compile time and used for lookup. For
testing purposes we need to swap the map being used. Having the
pmu_events_map be non-const is misleading as it may be an out argument.
Make it const and update uses so they work on const too.

Signed-off-by: Ian Rogers<irogers@xxxxxxxxxx>

Reviewed-by: John Garry <john.garry@xxxxxxxxxx>

Got a compile error for this on arm64 when basing these patches on acme/perf/core (be8ecc57f180415e8a7c1cc5620c5236be2a7e56):

$ make DEBUG=1 O=output
...<snipped>...
arch/arm64/util/pmu.c:6:24: error: conflicting types for ‘pmu_events_map__find’
struct pmu_events_map *pmu_events_map__find(void)
^~~~~~~~~~~~~~~~~~~~
In file included from arch/arm64/util/pmu.c:4:0:
arch/arm64/util/../../../util/pmu.h:126:30: note: previous declaration of ‘pmu_events_map__find’ was here
const struct pmu_events_map *pmu_events_map__find(void);
^~~~~~~~~~~~~~~~~~~~
arch/arm64/util/pmu.c: In function ‘pmu_events_map__find’:
arch/arm64/util/pmu.c:21:10: error: return discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
return perf_pmu__find_map(pmu);
^~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
/home/andkil01/linux/tools/build/Makefile.build:96: recipe for target '/home/andkil01/linux/tools/perf/output/arch/arm64/util/pmu.o' failed
make[6]: *** [/home/andkil01/linux/tools/perf/output/arch/arm64/util/pmu.o] Error 1
/home/andkil01/linux/tools/build/Makefile.build:139: recipe for target 'util' failed
make[5]: *** [util] Error 2
/home/andkil01/linux/tools/build/Makefile.build:139: recipe for target 'arm64' failed
make[4]: *** [arm64] Error 2
/home/andkil01/linux/tools/build/Makefile.build:139: recipe for target 'arch' failed
make[3]: *** [arch] Error 2
make[3]: *** Waiting for unfinished jobs....


Andrew