Re: [PATCH dwarves] btf_encoder: fix and complete filtering out zero-sized per-CPU variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 27, 2021 at 7:55 AM Arnaldo Carvalho de Melo
<acme@xxxxxxxxxx> wrote:
>
> Em Mon, May 24, 2021 at 04:42:22PM -0700, Andrii Nakryiko escreveu:
> > btf_encoder is ignoring zero-sized per-CPU ELF symbols, but the same has to be
> > done for DWARF variables when matching them with ELF symbols. This is due to
> > zero-sized DWARF variables matching unrelated (non-zero-sized) variable that
> > happens to be allocated at the exact same address, leading to a lot of
> > confusion in BTF.
>
> > See [0] for when this causes big problems.
>
> >   [0] https://lore.kernel.org/bpf/CAEf4BzZ0-sihSL-UAm21JcaCCY92CqfNxycHRZYXcoj8OYb=wA@xxxxxxxxxxxxxx/
>
> > +++ b/btf_encoder.c
> > @@ -550,6 +551,7 @@ int cu__encode_btf(struct cu *cu, int verbose, bool force,
> >
> >               /* addr has to be recorded before we follow spec */
> >               addr = var->ip.addr;
> > +             dwarf_name = variable__name(var, cu);
> >
> >               /* DWARF takes into account .data..percpu section offset
> >                * within its segment, which for vmlinux is 0, but for kernel
> > @@ -582,11 +584,9 @@ int cu__encode_btf(struct cu *cu, int verbose, bool force,
> >                *  modules per-CPU data section has non-zero offset so all
> >                *  per-CPU symbols have non-zero values.
> >                */
> > -             if (var->ip.addr == 0) {
> > -                     dwarf_name = variable__name(var, cu);
> > +             if (var->ip.addr == 0)
> >                       if (!dwarf_name || strcmp(dwarf_name, name))
> >                               continue;
> > -             }
> >
> >               if (var->spec)
> >                       var = var->spec;
> > @@ -600,6 +600,13 @@ int cu__encode_btf(struct cu *cu, int verbose, bool force,
>
> I just changed the above hunk to be:
>
> @@ -583,7 +585,6 @@ int cu__encode_btf(struct cu *cu, int verbose, bool force,
>                  *  per-CPU symbols have non-zero values.
>                  */
>                 if (var->ip.addr == 0) {
> -                       dwarf_name = variable__name(var, cu);
>                         if (!dwarf_name || strcmp(dwarf_name, name))
>                                 continue;
>                 }
>
>
> Which is shorter and keeps the {} around a multi line if block, ok?

yeah, no problem

>
> Thanks, applied!

Thanks!
>
> - Arnaldo



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux