netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andriin@fb.com>,
	Qais Yousef <qais.yousef@arm.com>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>
Subject: Re: [PATCH bpf-next] tools/resolve_btfids: Warn when having multiple IDs for single type
Date: Tue, 5 Jan 2021 23:47:28 +0100	[thread overview]
Message-ID: <20210105224728.GB936454@krava> (raw)
In-Reply-To: <CAEf4Bzb95cyrku5g+SvOmAWCV6kRhqJAFayp4fdzT31dMjjVXQ@mail.gmail.com>

On Tue, Jan 05, 2021 at 01:15:39PM -0800, Andrii Nakryiko wrote:
> On Tue, Jan 5, 2021 at 7:41 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > The kernel image can contain multiple types (structs/unions)
> > with the same name. This causes distinct type hierarchies in
> > BTF data and makes resolve_btfids fail with error like:
> >
> >   BTFIDS  vmlinux
> > FAILED unresolved symbol udp6_sock
> >
> > as reported by Qais Yousef [1].
> >
> > This change adds warning when multiple types of the same name
> > are detected:
> >
> >   BTFIDS  vmlinux
> > WARN: multiple IDs found for 'file' (526, 113351)
> > WARN: multiple IDs found for 'sk_buff' (2744, 113958)
> >
> > We keep the lower ID for the given type instance and let the
> > build continue.
> >
> > [1] https://lore.kernel.org/lkml/20201229151352.6hzmjvu3qh6p2qgg@e107158-lin/
> > Reported-by: Qais Yousef <qais.yousef@arm.com>
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> 
> see comments below, but otherwise lgtm
> 
> Acked-by: Andrii Nakryiko <andrii@kernel.org>
> 
> >  tools/bpf/resolve_btfids/main.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c
> > index e3ea569ee125..36a3b1024cdc 100644
> > --- a/tools/bpf/resolve_btfids/main.c
> > +++ b/tools/bpf/resolve_btfids/main.c
> > @@ -139,6 +139,8 @@ int eprintf(int level, int var, const char *fmt, ...)
> >  #define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__)
> >  #define pr_err(fmt, ...) \
> >         eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
> > +#define pr_info(fmt, ...) \
> > +       eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
> 
> how is it different from pr_err? Did you forget to update verboseness
> levels or it's intentional?

intentional, I'm using pr_err to print in error paths,
so I wanted to add new one for other 'info' messages without -v

> 
> >
> >  static bool is_btf_id(const char *name)
> >  {
> > @@ -526,8 +528,13 @@ static int symbols_resolve(struct object *obj)
> >
> >                 id = btf_id__find(root, str);
> >                 if (id) {
> > -                       id->id = type_id;
> > -                       (*nr)--;
> > +                       if (id->id) {
> > +                               pr_info("WARN: multiple IDs found for '%s' (%d, %d)\n",
> > +                                       str, id->id, type_id);
> > +                       } else {
> > +                               id->id = type_id;
> > +                               (*nr)--;
> 
> btw, there is a nasty shadowing of nr variable, which is used both for
> the for() loop condition (as int) and as `int *` inside the loop body.
> It's better to rename inner (or outer) nr, it's extremely confusing as
> is.

nice, I'll change that

thanks,
jirka

> 
> > +                       }
> >                 }
> >         }
> >
> > --
> > 2.26.2
> >
> 


      reply	other threads:[~2021-01-05 22:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 15:39 [PATCH bpf-next] tools/resolve_btfids: Warn when having multiple IDs for single type Jiri Olsa
2021-01-05 19:37 ` Alexei Starovoitov
2021-01-05 19:50   ` Jiri Olsa
2021-01-05 20:02     ` Alexei Starovoitov
2021-01-05 21:15 ` Andrii Nakryiko
2021-01-05 22:47   ` Jiri Olsa [this message]

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=20210105224728.GB936454@krava \
    --to=jolsa@redhat.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=netdev@vger.kernel.org \
    --cc=qais.yousef@arm.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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).