Re: [PATCH v3 05/22] perf maps: Use a pointer for kmaps

From: Arnaldo Carvalho de Melo
Date: Mon Feb 14 2022 - 15:53:17 EST


Em Fri, Feb 11, 2022 at 02:23:03PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Feb 11, 2022 at 02:33:58AM -0800, Ian Rogers escreveu:
> > struct maps is reference counted, using a pointer is more idiomatic.
>
> So, I tried to apply this after adding this to the cset comming log to
> make sure reviewers know that this is just a clarifying comming, no code
> change:
>
> Committer notes:
>
> Definition of machine__kernel_maps(machine), the replacement of &machine->kmaps
>
> static inline
> struct maps *machine__kernel_maps(struct machine *machine)
> {
> return machine->kmaps;
> }
>
> but then when building on a f34 system I got:
>
> CC /tmp/build/perf/bench/inject-buildid.o
> In file included from /var/home/acme/git/perf/tools/perf/util/build-id.h:10,
> from /var/home/acme/git/perf/tools/perf/util/dso.h:13,
> from tests/vmlinux-kallsyms.c:8:
> In function ‘machine__kernel_maps’,
> inlined from ‘test__vmlinux_matches_kallsyms’ at tests/vmlinux-kallsyms.c:122:22:
> /var/home/acme/git/perf/tools/perf/util/machine.h:86:23: error: ‘vmlinux.kmaps’ is used uninitialized [-Werror=uninitialized]
> 86 | return machine->kmaps;
> | ~~~~~~~^~~~~~~
> tests/vmlinux-kallsyms.c: In function ‘test__vmlinux_matches_kallsyms’:
> tests/vmlinux-kallsyms.c:121:34: note: ‘vmlinux’ declared here
> 121 | struct machine kallsyms, vmlinux;
> | ^~~~~~~
> cc1: all warnings being treated as errors
> make[4]: *** [/var/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/tests/vmlinux-kallsyms.o] Error 1
> make[4]: *** Waiting for unfinished jobs....
> CC /tmp/build/perf/util/config.o
> CC /tmp/build/perf/arch/x86/util/archinsn.o
> CC /tmp/build/perf/arch/x86/util/intel-pt.o
> CC /tmp/build/perf/arch/x86/util/intel-bts.o
> CC /tmp/build/perf/util/db-export.o
> CC /tmp/build/perf/util/event.o
> make[3]: *** [/var/home/acme/git/perf/tools/build/Makefile.build:139: tests] Error 2
> make[3]: *** Waiting for unfinished jobs....
>
> Can you please take a look at that?

I'm applying this on top:

diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index 84bf5f64006560f5..93dee542a177ed1d 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -119,7 +119,7 @@ static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused
struct symbol *sym;
struct map *kallsyms_map, *vmlinux_map, *map;
struct machine kallsyms, vmlinux;
- struct maps *maps = machine__kernel_maps(&vmlinux);
+ struct maps *maps;
u64 mem_start, mem_end;
bool header_printed;

@@ -132,6 +132,8 @@ static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused
machine__init(&kallsyms, "", HOST_KERNEL_ID);
machine__init(&vmlinux, "", HOST_KERNEL_ID);

+ maps = machine__kernel_maps(&vmlinux);
+
/*
* Step 2:
*