dwarves.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: "Michal Suchánek" <msuchanek@suse.de>
Cc: Andrii Nakryiko <andrii@kernel.org>,
	dwarves@vger.kernel.org, bpf@vger.kernel.org, jolsa@kernel.org,
	kernel-team@fb.com
Subject: Re: [PATCH dwarves] btf_encoder: fix and complete filtering out zero-sized per-CPU variables
Date: Thu, 27 May 2021 13:47:41 -0300	[thread overview]
Message-ID: <YK/NLcM9ww2eXlmT@kernel.org> (raw)
In-Reply-To: <YK+8/lg7ZUJIH7Kv@kernel.org>

Em Thu, May 27, 2021 at 12:38:38PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Thu, May 27, 2021 at 05:27:58PM +0200, Michal Suchánek escreveu:
> > Hello,
> > 
> > On Thu, May 27, 2021 at 11:58:24AM -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Thu, May 27, 2021 at 11:55:10AM -0300, Arnaldo Carvalho de Melo escreveu:
> > > > 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@mail.gmail.com/
> > > 
> > > I also added this:
> > > 
> > > Reported-by: Michal Suchánek <msuchanek@suse.de>
> > > 
> > > Michal, so you tested this patch and verified it fixed the problem? If
> > > so please let me know so that I also add:
> > 
> > This is the first time I see this patch.
> > 
> > Given that linux-next does not build for me at the moment
> > I don't think I will test it soon.
> 
> Ok, I'm test building with torvalds/master, will try with linux-next
> afterwards,

I build and booted torvalds/master, all seems to work, now moving to
linux-next.
 
> Thanks,
> 
> - Arnaldo
>  
> > Thanks
> > 
> > Michal
> > 
> > > 
> > > Tested-by: Michal Suchánek <msuchanek@suse.de>
> > > 
> > > Thanks,
> > > 
> > > - Arnaldo
> > >  
> > > > > +++ 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?
> > > > 
> > > > Thanks, applied!
> > > > 
> > > > - Arnaldo
> > > 
> > > -- 
> > > 
> > > - Arnaldo
> 
> -- 
> 
> - Arnaldo

-- 

- Arnaldo

  reply	other threads:[~2021-05-27 16:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 23:42 [PATCH dwarves] btf_encoder: fix and complete filtering out zero-sized per-CPU variables Andrii Nakryiko
2021-05-25 19:58 ` Arnaldo Carvalho de Melo
2021-05-27 14:55 ` Arnaldo Carvalho de Melo
2021-05-27 14:58   ` Arnaldo Carvalho de Melo
2021-05-27 15:27     ` Michal Suchánek
2021-05-27 15:38       ` Arnaldo Carvalho de Melo
2021-05-27 16:47         ` Arnaldo Carvalho de Melo [this message]
2021-05-28  6:24           ` Michal Suchánek
2021-05-27 16:45       ` Andrii Nakryiko
2021-05-27 16:43   ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YK/NLcM9ww2eXlmT@kernel.org \
    --to=acme@kernel.org \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=msuchanek@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).