Message ID | 20230915103228.1196234-1-jolsa@kernel.org (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | BPF |
Headers | show |
Series | [bpf] bpf: Fix BTF_ID symbol generation | expand |
On Fri, Sep 15, 2023 at 3:32 AM Jiri Olsa <jolsa@kernel.org> wrote: > > Marcus and Nick reported issue where BTF_ID macro generates same > symbol in separate objects and that breaks final vmlinux link. > > Adding __LINE__ number suffix to make BTF_ID symbol more unique, > which is not real fix, but it would help for now and meanwhile > we can work on better solution as suggested by Andrii in [2]. > > [1] https://github.com/ClangBuiltLinux/linux/issues/1913 > [2] https://lore.kernel.org/bpf/ZQQVr35crUtN1quS@krava/T/#m64d7c29c407d6adf0e7b420359958b3aafa7bf69 > Reported-by: Marcus Seyfarth <m.seyfarth@gmail.com> > Reported-by: Nick Desaulniers <ndesaulniers@google.com> > Signed-off-by: Jiri Olsa <jolsa@kernel.org> > --- > include/linux/btf_ids.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h > index a3462a9b8e18..a9cb10b0e2e9 100644 > --- a/include/linux/btf_ids.h > +++ b/include/linux/btf_ids.h > @@ -49,7 +49,7 @@ word \ > ____BTF_ID(symbol, word) > > #define __ID(prefix) \ > - __PASTE(prefix, __COUNTER__) > + __PASTE(__PASTE(prefix, __COUNTER__), __LINE__) I think __COUNTER__ and __LINE__ both expand to string literals; you can avoid another expansion via __PASTE by just putting them adjacent, like so: https://github.com/ClangBuiltLinux/linux/issues/1913#issuecomment-1710794319 I'll send that as a v2 and link back to your v1. > > /* > * The BTF_ID defines unique symbol for each ID pointing > -- > 2.41.0 >
On Fri, Sep 15, 2023 at 9:25 AM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Fri, Sep 15, 2023 at 3:32 AM Jiri Olsa <jolsa@kernel.org> wrote: > > > > Marcus and Nick reported issue where BTF_ID macro generates same > > symbol in separate objects and that breaks final vmlinux link. > > > > Adding __LINE__ number suffix to make BTF_ID symbol more unique, > > which is not real fix, but it would help for now and meanwhile > > we can work on better solution as suggested by Andrii in [2]. > > > > [1] https://github.com/ClangBuiltLinux/linux/issues/1913 > > [2] https://lore.kernel.org/bpf/ZQQVr35crUtN1quS@krava/T/#m64d7c29c407d6adf0e7b420359958b3aafa7bf69 > > Reported-by: Marcus Seyfarth <m.seyfarth@gmail.com> > > Reported-by: Nick Desaulniers <ndesaulniers@google.com> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org> > > --- > > include/linux/btf_ids.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h > > index a3462a9b8e18..a9cb10b0e2e9 100644 > > --- a/include/linux/btf_ids.h > > +++ b/include/linux/btf_ids.h > > @@ -49,7 +49,7 @@ word \ > > ____BTF_ID(symbol, word) > > > > #define __ID(prefix) \ > > - __PASTE(prefix, __COUNTER__) > > + __PASTE(__PASTE(prefix, __COUNTER__), __LINE__) > > I think __COUNTER__ and __LINE__ both expand to string literals; you ah, no I was wrong. But this change needs to go into tools/include/linux/btf_ids.h, too. I'll wrap that up in my v3. > can avoid another expansion via __PASTE by just putting them adjacent, > like so: > https://github.com/ClangBuiltLinux/linux/issues/1913#issuecomment-1710794319 > I'll send that as a v2 and link back to your v1. > > > > > /* > > * The BTF_ID defines unique symbol for each ID pointing > > -- > > 2.41.0 > > > > > -- > Thanks, > ~Nick Desaulniers
diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h index a3462a9b8e18..a9cb10b0e2e9 100644 --- a/include/linux/btf_ids.h +++ b/include/linux/btf_ids.h @@ -49,7 +49,7 @@ word \ ____BTF_ID(symbol, word) #define __ID(prefix) \ - __PASTE(prefix, __COUNTER__) + __PASTE(__PASTE(prefix, __COUNTER__), __LINE__) /* * The BTF_ID defines unique symbol for each ID pointing
Marcus and Nick reported issue where BTF_ID macro generates same symbol in separate objects and that breaks final vmlinux link. Adding __LINE__ number suffix to make BTF_ID symbol more unique, which is not real fix, but it would help for now and meanwhile we can work on better solution as suggested by Andrii in [2]. [1] https://github.com/ClangBuiltLinux/linux/issues/1913 [2] https://lore.kernel.org/bpf/ZQQVr35crUtN1quS@krava/T/#m64d7c29c407d6adf0e7b420359958b3aafa7bf69 Reported-by: Marcus Seyfarth <m.seyfarth@gmail.com> Reported-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Jiri Olsa <jolsa@kernel.org> --- include/linux/btf_ids.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)