2023-09-15 20:48:45

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH v2] bpf: Fix BTF_ID symbol generation collision

On Fri, Sep 15, 2023 at 10:22 AM Alexei Starovoitov
<[email protected]> wrote:
>
> On Fri, Sep 15, 2023 at 10:18 AM Nathan Chancellor <[email protected]> wrote:
> >
> > On Fri, Sep 15, 2023 at 09:42:20AM -0700, Nick Desaulniers wrote:
> > > Marcus and Satya reported an issue where BTF_ID macro generates same
> > > symbol in separate objects and that breaks final vmlinux link.
> > >
> > > ld.lld: error: ld-temp.o <inline asm>:14577:1: symbol
> > > '__BTF_ID__struct__cgroup__624' is already defined
> > >
> > > This can be triggered under specific configs when __COUNTER__ happens to
> > > be the same for the same symbol in two different translation units,
> > > which is already quite unlikely to happen.
> > >
> > > Add __LINE__ number suffix to make BTF_ID symbol more unique, which is
> > > not a complete fix, but it would help for now and meanwhile we can work
> > > on better solution as suggested by Andrii.
> > >
> > > Cc: [email protected]
> > > Reported-by: Satya Durga Srinivasu Prabhala <[email protected]>
> > > Reported-by: Marcus Seyfarth <[email protected]>
> > > Closes: https://github.com/ClangBuiltLinux/linux/issues/1913
> > > Tested-by: Marcus Seyfarth <[email protected]>
> > > Debugged-by: Nathan Chancellor <[email protected]>
> > > Co-developed-by: Jiri Olsa <[email protected]>
> > > Link: https://lore.kernel.org/bpf/CAEf4Bzb5KQ2_LmhN769ifMeSJaWfebccUasQOfQKaOd0nQ51tw@mail.gmail.com/
> > > Signed-off-by: Nick Desaulniers <[email protected]>
> > > ---
> > > tools/include/linux/btf_ids.h | 2 +-
> >
> > Shouldn't this diff be in include/linux/btf_ids.h as well? Otherwise, I
> > don't think it will be used by the kernel build.

D'oh!

>
> argh.
> Let's do this patch as-is and another patch to update everything
> in tools/../btf_ids.h, since it got out of sync quite a bit.

I think I can do both in a v3? I don't see the issue (in mainline, are
they out of sync in -next?)

--
Thanks,
~Nick Desaulniers


2023-09-16 02:14:07

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH v2] bpf: Fix BTF_ID symbol generation collision

On Fri, Sep 15, 2023 at 10:24 AM Nick Desaulniers
<[email protected]> wrote:
>
> On Fri, Sep 15, 2023 at 10:22 AM Alexei Starovoitov
> <[email protected]> wrote:
> >
> > On Fri, Sep 15, 2023 at 10:18 AM Nathan Chancellor <[email protected]> wrote:
> > >
> > > On Fri, Sep 15, 2023 at 09:42:20AM -0700, Nick Desaulniers wrote:
> > > > Marcus and Satya reported an issue where BTF_ID macro generates same
> > > > symbol in separate objects and that breaks final vmlinux link.
> > > >
> > > > ld.lld: error: ld-temp.o <inline asm>:14577:1: symbol
> > > > '__BTF_ID__struct__cgroup__624' is already defined
> > > >
> > > > This can be triggered under specific configs when __COUNTER__ happens to
> > > > be the same for the same symbol in two different translation units,
> > > > which is already quite unlikely to happen.
> > > >
> > > > Add __LINE__ number suffix to make BTF_ID symbol more unique, which is
> > > > not a complete fix, but it would help for now and meanwhile we can work
> > > > on better solution as suggested by Andrii.
> > > >
> > > > Cc: [email protected]
> > > > Reported-by: Satya Durga Srinivasu Prabhala <[email protected]>
> > > > Reported-by: Marcus Seyfarth <[email protected]>
> > > > Closes: https://github.com/ClangBuiltLinux/linux/issues/1913
> > > > Tested-by: Marcus Seyfarth <[email protected]>
> > > > Debugged-by: Nathan Chancellor <[email protected]>
> > > > Co-developed-by: Jiri Olsa <[email protected]>
> > > > Link: https://lore.kernel.org/bpf/CAEf4Bzb5KQ2_LmhN769ifMeSJaWfebccUasQOfQKaOd0nQ51tw@mail.gmail.com/
> > > > Signed-off-by: Nick Desaulniers <[email protected]>
> > > > ---
> > > > tools/include/linux/btf_ids.h | 2 +-
> > >
> > > Shouldn't this diff be in include/linux/btf_ids.h as well? Otherwise, I
> > > don't think it will be used by the kernel build.
>
> D'oh!
>
> >
> > argh.
> > Let's do this patch as-is and another patch to update everything
> > in tools/../btf_ids.h, since it got out of sync quite a bit.
>
> I think I can do both in a v3? I don't see the issue (in mainline, are
> they out of sync in -next?)

Yes. Pls send v3 with two patches.
We'll apply and flush bpf trees, so both will have all fixes in a day or so.

2023-09-16 02:22:03

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH v2] bpf: Fix BTF_ID symbol generation collision

On Fri, Sep 15, 2023 at 10:27 AM Alexei Starovoitov
<[email protected]> wrote:
>
> On Fri, Sep 15, 2023 at 10:24 AM Nick Desaulniers
> <[email protected]> wrote:
> >
> > On Fri, Sep 15, 2023 at 10:22 AM Alexei Starovoitov
> > <[email protected]> wrote:
> > >
> > > On Fri, Sep 15, 2023 at 10:18 AM Nathan Chancellor <[email protected]> wrote:
> > > >
> > > > On Fri, Sep 15, 2023 at 09:42:20AM -0700, Nick Desaulniers wrote:
> > > > > Marcus and Satya reported an issue where BTF_ID macro generates same
> > > > > symbol in separate objects and that breaks final vmlinux link.
> > > > >
> > > > > ld.lld: error: ld-temp.o <inline asm>:14577:1: symbol
> > > > > '__BTF_ID__struct__cgroup__624' is already defined
> > > > >
> > > > > This can be triggered under specific configs when __COUNTER__ happens to
> > > > > be the same for the same symbol in two different translation units,
> > > > > which is already quite unlikely to happen.
> > > > >
> > > > > Add __LINE__ number suffix to make BTF_ID symbol more unique, which is
> > > > > not a complete fix, but it would help for now and meanwhile we can work
> > > > > on better solution as suggested by Andrii.
> > > > >
> > > > > Cc: [email protected]
> > > > > Reported-by: Satya Durga Srinivasu Prabhala <[email protected]>
> > > > > Reported-by: Marcus Seyfarth <[email protected]>
> > > > > Closes: https://github.com/ClangBuiltLinux/linux/issues/1913
> > > > > Tested-by: Marcus Seyfarth <[email protected]>
> > > > > Debugged-by: Nathan Chancellor <[email protected]>
> > > > > Co-developed-by: Jiri Olsa <[email protected]>
> > > > > Link: https://lore.kernel.org/bpf/CAEf4Bzb5KQ2_LmhN769ifMeSJaWfebccUasQOfQKaOd0nQ51tw@mail.gmail.com/
> > > > > Signed-off-by: Nick Desaulniers <[email protected]>
> > > > > ---
> > > > > tools/include/linux/btf_ids.h | 2 +-
> > > >
> > > > Shouldn't this diff be in include/linux/btf_ids.h as well? Otherwise, I
> > > > don't think it will be used by the kernel build.
> >
> > D'oh!
> >
> > >
> > > argh.
> > > Let's do this patch as-is and another patch to update everything
> > > in tools/../btf_ids.h, since it got out of sync quite a bit.
> >
> > I think I can do both in a v3? I don't see the issue (in mainline, are
> > they out of sync in -next?)
>
> Yes. Pls send v3 with two patches.
> We'll apply and flush bpf trees, so both will have all fixes in a day or so.

And please use [PATCH bpf v3] in subject, so that BPF CI can test it properly.

2023-09-16 13:49:46

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH v2] bpf: Fix BTF_ID symbol generation collision

On Fri, Sep 15, 2023 at 10:28 AM Alexei Starovoitov
<[email protected]> wrote:
>
> And please use [PATCH bpf v3] in subject, so that BPF CI can test it properly.

Testing `b4 prep --set-prefixes "PATCH bpf "`

--
Thanks,
~Nick Desaulniers