Message ID | 20230915-bpf_collision-v2-1-027670d38bdf@google.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | BPF |
Headers | show |
Series | [v2] bpf: Fix BTF_ID symbol generation collision | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
bpf/vmtest-bpf-next-PR | fail | PR summary |
bpf/vmtest-bpf-next-VM_Test-0 | success | Logs for ${{ matrix.test }} on ${{ matrix.arch }} with ${{ matrix.toolchain_full }} |
bpf/vmtest-bpf-next-VM_Test-1 | success | Logs for ShellCheck |
bpf/vmtest-bpf-next-VM_Test-2 | fail | Logs for build for aarch64 with gcc |
bpf/vmtest-bpf-next-VM_Test-3 | fail | Logs for build for s390x with gcc |
bpf/vmtest-bpf-next-VM_Test-4 | fail | Logs for build for x86_64 with gcc |
bpf/vmtest-bpf-next-VM_Test-6 | success | Logs for set-matrix |
bpf/vmtest-bpf-next-VM_Test-5 | fail | Logs for build for x86_64 with llvm-16 |
bpf/vmtest-bpf-next-VM_Test-7 | success | Logs for veristat |
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: stable@vger.kernel.org > Reported-by: Satya Durga Srinivasu Prabhala <quic_satyap@quicinc.com> > Reported-by: Marcus Seyfarth <m.seyfarth@gmail.com> > Closes: https://github.com/ClangBuiltLinux/linux/issues/1913 > Tested-by: Marcus Seyfarth <m.seyfarth@gmail.com> > Debugged-by: Nathan Chancellor <nathan@kernel.org> > Co-developed-by: Jiri Olsa <jolsa@kernel.org> > Link: https://lore.kernel.org/bpf/CAEf4Bzb5KQ2_LmhN769ifMeSJaWfebccUasQOfQKaOd0nQ51tw@mail.gmail.com/ > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > --- > 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. > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/include/linux/btf_ids.h b/tools/include/linux/btf_ids.h > index 71e54b1e3796..30e920b96a18 100644 > --- a/tools/include/linux/btf_ids.h > +++ b/tools/include/linux/btf_ids.h > @@ -38,7 +38,7 @@ asm( \ > ____BTF_ID(symbol) > > #define __ID(prefix) \ > - __PASTE(prefix, __COUNTER__) > + __PASTE(prefix, __COUNTER__ __LINE__) > > /* > * The BTF_ID defines unique symbol for each ID pointing > > --- > base-commit: 9fdfb15a3dbf818e06be514f4abbfc071004cbe7 > change-id: 20230915-bpf_collision-36889a391d44 > > Best regards, > -- > Nick Desaulniers <ndesaulniers@google.com> >
On Fri, Sep 15, 2023 at 10:18 AM Nathan Chancellor <nathan@kernel.org> 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: stable@vger.kernel.org > > Reported-by: Satya Durga Srinivasu Prabhala <quic_satyap@quicinc.com> > > Reported-by: Marcus Seyfarth <m.seyfarth@gmail.com> > > Closes: https://github.com/ClangBuiltLinux/linux/issues/1913 > > Tested-by: Marcus Seyfarth <m.seyfarth@gmail.com> > > Debugged-by: Nathan Chancellor <nathan@kernel.org> > > Co-developed-by: Jiri Olsa <jolsa@kernel.org> > > Link: https://lore.kernel.org/bpf/CAEf4Bzb5KQ2_LmhN769ifMeSJaWfebccUasQOfQKaOd0nQ51tw@mail.gmail.com/ > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > > --- > > 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. 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.
On Fri, Sep 15, 2023 at 10:22 AM Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote: > > On Fri, Sep 15, 2023 at 10:18 AM Nathan Chancellor <nathan@kernel.org> 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: stable@vger.kernel.org > > > Reported-by: Satya Durga Srinivasu Prabhala <quic_satyap@quicinc.com> > > > Reported-by: Marcus Seyfarth <m.seyfarth@gmail.com> > > > Closes: https://github.com/ClangBuiltLinux/linux/issues/1913 > > > Tested-by: Marcus Seyfarth <m.seyfarth@gmail.com> > > > Debugged-by: Nathan Chancellor <nathan@kernel.org> > > > Co-developed-by: Jiri Olsa <jolsa@kernel.org> > > > Link: https://lore.kernel.org/bpf/CAEf4Bzb5KQ2_LmhN769ifMeSJaWfebccUasQOfQKaOd0nQ51tw@mail.gmail.com/ > > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > > > --- > > > 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?)
On Fri, Sep 15, 2023 at 10:24 AM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Fri, Sep 15, 2023 at 10:22 AM Alexei Starovoitov > <alexei.starovoitov@gmail.com> wrote: > > > > On Fri, Sep 15, 2023 at 10:18 AM Nathan Chancellor <nathan@kernel.org> 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: stable@vger.kernel.org > > > > Reported-by: Satya Durga Srinivasu Prabhala <quic_satyap@quicinc.com> > > > > Reported-by: Marcus Seyfarth <m.seyfarth@gmail.com> > > > > Closes: https://github.com/ClangBuiltLinux/linux/issues/1913 > > > > Tested-by: Marcus Seyfarth <m.seyfarth@gmail.com> > > > > Debugged-by: Nathan Chancellor <nathan@kernel.org> > > > > Co-developed-by: Jiri Olsa <jolsa@kernel.org> > > > > Link: https://lore.kernel.org/bpf/CAEf4Bzb5KQ2_LmhN769ifMeSJaWfebccUasQOfQKaOd0nQ51tw@mail.gmail.com/ > > > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > > > > --- > > > > 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.
On Fri, Sep 15, 2023 at 10:27 AM Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote: > > On Fri, Sep 15, 2023 at 10:24 AM Nick Desaulniers > <ndesaulniers@google.com> wrote: > > > > On Fri, Sep 15, 2023 at 10:22 AM Alexei Starovoitov > > <alexei.starovoitov@gmail.com> wrote: > > > > > > On Fri, Sep 15, 2023 at 10:18 AM Nathan Chancellor <nathan@kernel.org> 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: stable@vger.kernel.org > > > > > Reported-by: Satya Durga Srinivasu Prabhala <quic_satyap@quicinc.com> > > > > > Reported-by: Marcus Seyfarth <m.seyfarth@gmail.com> > > > > > Closes: https://github.com/ClangBuiltLinux/linux/issues/1913 > > > > > Tested-by: Marcus Seyfarth <m.seyfarth@gmail.com> > > > > > Debugged-by: Nathan Chancellor <nathan@kernel.org> > > > > > Co-developed-by: Jiri Olsa <jolsa@kernel.org> > > > > > Link: https://lore.kernel.org/bpf/CAEf4Bzb5KQ2_LmhN769ifMeSJaWfebccUasQOfQKaOd0nQ51tw@mail.gmail.com/ > > > > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > > > > > --- > > > > > 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.
On Fri, Sep 15, 2023 at 10:28 AM Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote: > > And please use [PATCH bpf v3] in subject, so that BPF CI can test it properly. Testing `b4 prep --set-prefixes "PATCH bpf "`
On Fri, Sep 15, 2023 at 10:33 AM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Fri, Sep 15, 2023 at 10:28 AM Alexei Starovoitov > <alexei.starovoitov@gmail.com> wrote: > > > > And please use [PATCH bpf v3] in subject, so that BPF CI can test it properly. > > Testing `b4 prep --set-prefixes "PATCH bpf "` Ah, should just be "bpf" for --set-prefixes (fixed before sending v3).
diff --git a/tools/include/linux/btf_ids.h b/tools/include/linux/btf_ids.h index 71e54b1e3796..30e920b96a18 100644 --- a/tools/include/linux/btf_ids.h +++ b/tools/include/linux/btf_ids.h @@ -38,7 +38,7 @@ asm( \ ____BTF_ID(symbol) #define __ID(prefix) \ - __PASTE(prefix, __COUNTER__) + __PASTE(prefix, __COUNTER__ __LINE__) /* * The BTF_ID defines unique symbol for each ID pointing