Re: [PATCH 2/6] perf annotate-data: Collect global variables in advance

From: Namhyung Kim
Date: Thu May 02 2024 - 19:28:21 EST


On Thu, May 2, 2024 at 11:23 AM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> On Thu, May 2, 2024 at 6:50 AM Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:
> >
> > On Wed, May 01, 2024 at 11:00:07PM -0700, Namhyung Kim wrote:
> > > Currently it looks up global variables from the current CU using address
> > > and name. But it sometimes fails to find a variable as the variable can
> > > come from a different CU - but it's still strange it failed to find a
> > > declaration for some reason.
> > >
> > > Anyway, it can collect all global variables from all CU once and then
> > > lookup them later on. This slightly improves the success rate of my
> > > test data set.
> >
> > It would be interesting you could provide examples from your test data
> > set, i.e. after this patch these extra global variables were considered
> > in the test results, with some tool output, etc.

Here's the example:

Before
-----------------------------------------------------------
find data type for 0x6014(PC) at entry_SYSCALL_64+0x7
CU for arch/x86/entry/entry_64.S (die:0x85e1d)
no variable found

After
-----------------------------------------------------------
find data type for 0x6014(PC) at entry_SYSCALL_64+0x7
CU for arch/x86/entry/entry_64.S (die:0x85e1d)
found by addr=0x6014 type_offset=0x14
type='struct tss_struct' size=0x5000 (die:0x74dbe1)

It was asm code so it doesn't have the type info in the CU.
With this change it can see the type (from a different CU).
It seems we have a per-cpu variable called cpu_tss_rw at
address 0x6000.

$ nm vmlinux | grep 6000 | grep tss
0000000000006000 D cpu_tss_rw

Thanks,
Namhyung