From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: Yonghong Song <yhs@fb.com>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
<bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>,
Mark Wielaard <mark@klomp.org>
Subject: Re: [PATCH bpf-next v2 00/11] bpf: add support for new btf kind BTF_KIND_TAG
Date: Thu, 27 Jan 2022 16:38:23 +0100 [thread overview]
Message-ID: <87pmodgpe8.fsf@oracle.com> (raw)
In-Reply-To: <61e04a73-bc4d-b250-31fe-93df4100c923@fb.com> (Yonghong Song's message of "Mon, 24 Jan 2022 19:58:25 -0800")
> On 12/20/21 1:49 AM, Jose E. Marchesi wrote:
>>
>>> On 12/17/21 5:44 PM, Alexei Starovoitov wrote:
>>>> On Fri, Dec 17, 2021 at 11:40:10AM +0100, Jose E. Marchesi wrote:
>>>>>
>>>>> 2) The need for DWARF to convey free-text tags on certain elements, such
>>>>> as members of struct types.
>>>>>
>>>>> The motivation for this was originally the way the Linux kernel
>>>>> generates its BTF information, using pahole, using DWARF as a source.
>>>>> As we discussed in our last exchange on this topic, this is
>>>>> accidental, i.e. if the kernel switched to generate BTF directly from
>>>>> the compiler and the linker could merge/deduplicate BTF, there would
>>>>> be no need for using DWARF to act as the "unwilling conveyer" of this
>>>>> information. There are additional benefits of this second approach.
>>>>> Thats why we didn't plan to add these extended DWARF DIEs to GCC.
>>>>>
>>>>> However, it now seems that a DWARF consumer, the drgn project, would
>>>>> also benefit from having such a support in DWARF to distinguish
>>>>> between different kind of pointers.
>>>> drgn can use .percpu section in vmlinux for global percpu vars.
>>>> For pointers the annotation is indeed necessary.
>>>>
>>>>> So it seems to me that now we have two use-cases for adding support
>>>>> for these free-text tags to DWARF, as a proper extension to the
>>>>> format, strictly unrelated to BTF, BPF or even the kernel, since:
>>>>> - This is not kernel specific.
>>>>> - This is not directly related to BTF.
>>>>> - This is not directly related to BPF.
>>>> __percpu annotation is kernel specific.
>>>> __user and __rcu are kernel specific too.
>>>> Only BPF and BTF can meaningfully consume all three.
>>>> drgn can consume __percpu.
>>>> In that sense if GCC follows LLVM and emits compiler specific DWARF
>>>> tag
>>>> pahole can convert it to the same BTF regardless whether kernel
>>>> was compiled with clang or gcc.
>>>> drgn can consume dwarf generated by clang or gcc as well even when BTF
>>>> is not there. That is the fastest way forward.
>>>> In that sense it would be nice to have common DWARF tag for pointer
>>>> annotations, but it's not mandatory. The time is the most valuable asset.
>>>> Implementing GCC specific DWARF tag doesn't require committee voting
>>>> and the mailing list bikeshedding.
>>>>
>>>>> 3) Addition of C-family language-level constructions to specify
>>>>> free-text tags on certain language elements, such as struct fields.
>>>>>
>>>>> These are the attributes, or built-ins or whatever syntax.
>>>>>
>>>>> Note that, strictly speaking:
>>>>> - This is orthogonal to both DWARF and BTF, and any other supported
>>>>> debugging format, which may or may not be expressive enough to
>>>>> convey the free-form text tag.
>>>>> - This is not specific to BPF.
>>>>>
>>>>> Therefore I would avoid any reference to BTF or BPF in the attribute
>>>>> names. Something like `__attribute__((btf_tag("arbitrary_str")))'
>>>>> makes very little sense to me; the attribute name ought to be more
>>>>> generic.
>>>> Let's agree to disagree.
>>>> When BPF ISA was designed we didn't go to Intel, Arm, Mips, etc in order to
>>>> come up with the best ISA that would JIT to those architectures the best
>>>> possible way. Same thing with btf_tag. Today it is specific to BTF and BPF
>>>> only. Hence it's called this way. Whenever actual users will appear that need
>>>> free-text tags on a struct field then and only then will be the time to discuss
>>>> generic tag name. Just because "free-text tag on a struct field" sounds generic
>>>> it doesn't mean that it has any use case beyond what we're using it for in BPF
>>>> land. It goes back to the point of coding now instead of talking about coding.
>>>> If gcc wants to call it __attribute__((my_precious_gcc_tag("arbitrary_str")))
>>>> go ahead and code it this way. The include/linux/compiler.h can accommodate it.
>>>
>>> Just want to add a little bit context for this. In the beginning when
>>> we proposed to add the attribute, we named as a generic name like
>>> 'tag' (or something like that). But eventually upstream suggested
>>> 'btf_tag' since the use case we proposed is for bpf. At that point, we
>>> don't know drgn use cases yet. Even with that, the use cases are still
>>> just for linux kernel.
>>>
>>> At that time, some *similar* use cases did came up, e.g., for
>>> swift<->C++ conversion encoding ("tag name", "attribute info") for
>>> attributes in the source code, will help a lot. But they will use a
>>> different "tag name" than btf_tag to differentiate.
>> Thanks for the info.
>> I find it very interesting that the LLVM people prefers to have
>> several
>> "use case specific" tag names instead of something more generic, which
>> is the exact opposite of what I would have done :) They may have
>> appealing reasons for doing so. Do you have a pointer to the dicussion
>> you had upstream at hand?
>> Anyway, I will taste the waters with the other GCC hackers about
>> both
>> DIEs and attribute and see what we can come out with. Thanks again for
>> reaching out Yonghong.
>
> Hi, Jose,
>
> Any progress on gcc btf_tag support discussion? If possible, could
> you add me to the discussion mailing list so I may help to move
> the project forward? Thanks a lot!
We are in the process of implementing the support of the BTF extensions
(which is done) and the C language attributes (which is WIP.)
I haven't started the discussion about DWARF yet. Will do shortly. You
will be in CC :)
next prev parent reply other threads:[~2022-01-27 15:39 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 15:51 [PATCH bpf-next v2 00/11] bpf: add support for new btf kind BTF_KIND_TAG Yonghong Song
2021-09-13 15:51 ` [PATCH bpf-next v2 01/11] btf: change BTF_KIND_* macros to enums Yonghong Song
2021-09-14 4:59 ` Andrii Nakryiko
2021-09-14 15:53 ` Yonghong Song
2021-09-13 15:51 ` [PATCH bpf-next v2 02/11] bpf: support for new btf kind BTF_KIND_TAG Yonghong Song
2021-09-14 5:08 ` Andrii Nakryiko
2021-09-14 15:59 ` Yonghong Song
2021-09-14 23:30 ` Andrii Nakryiko
2021-09-13 15:51 ` [PATCH bpf-next v2 03/11] libbpf: rename btf_{hash,equal}_int to btf_{hash,equal}_int_tag Yonghong Song
2021-09-13 15:51 ` [PATCH bpf-next v2 04/11] libbpf: add support for BTF_KIND_TAG Yonghong Song
2021-09-14 5:15 ` Andrii Nakryiko
2021-09-14 16:42 ` Yonghong Song
2021-09-13 15:51 ` [PATCH bpf-next v2 05/11] bpftool: " Yonghong Song
2021-09-14 5:16 ` Andrii Nakryiko
2021-09-13 15:51 ` [PATCH bpf-next v2 06/11] selftests/bpf: test libbpf API function btf__add_tag() Yonghong Song
2021-09-14 5:18 ` Andrii Nakryiko
2021-09-13 15:52 ` [PATCH bpf-next v2 07/11] selftests/bpf: change NAME_NTH/IS_NAME_NTH for BTF_KIND_TAG format Yonghong Song
2021-09-14 5:23 ` Andrii Nakryiko
2021-09-13 15:52 ` [PATCH bpf-next v2 08/11] selftests/bpf: add BTF_KIND_TAG unit tests Yonghong Song
2021-09-14 5:31 ` Andrii Nakryiko
2021-09-14 17:00 ` Yonghong Song
2021-09-13 15:52 ` [PATCH bpf-next v2 09/11] selftests/bpf: test BTF_KIND_TAG for deduplication Yonghong Song
2021-09-14 5:38 ` Andrii Nakryiko
2021-09-14 17:15 ` Yonghong Song
2021-09-14 19:39 ` Yonghong Song
2021-09-14 23:31 ` Andrii Nakryiko
2021-09-13 15:52 ` [PATCH bpf-next v2 10/11] selftests/bpf: add a test with a bpf program with btf_tag attributes Yonghong Song
2021-09-13 15:52 ` [PATCH bpf-next v2 11/11] docs/bpf: add documentation for BTF_KIND_TAG Yonghong Song
2021-09-14 5:40 ` Andrii Nakryiko
2021-09-13 16:08 ` [PATCH bpf-next v2 00/11] bpf: add support for new btf kind BTF_KIND_TAG Yonghong Song
2021-09-13 16:40 ` Jose E. Marchesi
2021-12-16 21:52 ` Yonghong Song
2021-12-17 10:40 ` Jose E. Marchesi
2021-12-18 1:44 ` Alexei Starovoitov
2021-12-18 20:15 ` Yonghong Song
2021-12-20 9:49 ` Jose E. Marchesi
2021-12-20 15:52 ` Yonghong Song
2022-01-25 3:58 ` Yonghong Song
2022-01-27 15:38 ` Jose E. Marchesi [this message]
2022-01-27 16:42 ` Yonghong Song
2022-02-17 13:20 ` Jose E. Marchesi
2022-02-17 15:28 ` Alexei Starovoitov
2022-02-17 16:41 ` Jose E. Marchesi
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=87pmodgpe8.fsf@oracle.com \
--to=jose.marchesi@oracle.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=mark@klomp.org \
--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).