BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@meta.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Eduard Zingerman <eddyz87@gmail.com>,
	bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
	daniel@iogearbox.net, kernel-team@fb.com, yhs@fb.com,
	arnaldo.melo@gmail.com
Subject: Re: [RFC bpf-next 00/12] Use uapi kernel headers with vmlinux.h
Date: Fri, 28 Oct 2022 11:56:56 -0700	[thread overview]
Message-ID: <af1facf9-7bc8-8a3d-0db4-7b3f333589a2@meta.com> (raw)
In-Reply-To: <CAEf4BzYT4pwmw64DaCTxR3_QjO5RRVadqVLO0h-hNa-+xOyLZw@mail.gmail.com>



On 10/28/22 10:13 AM, Andrii Nakryiko wrote:
> On Thu, Oct 27, 2022 at 6:33 PM Yonghong Song <yhs@meta.com> wrote:
>>
>>
>>
>> On 10/27/22 4:14 PM, Andrii Nakryiko wrote:
>>> On Tue, Oct 25, 2022 at 3:28 PM Eduard Zingerman <eddyz87@gmail.com> wrote:
>>>>
>>>> Hi BPF community,
>>>>
>>>> AFAIK there is a long standing feature request to use kernel headers
>>>> alongside `vmlinux.h` generated by `bpftool`. For example significant
>>>> effort was put to add an attribute `bpf_dominating_decl` (see [1]) to
>>>> clang, unfortunately this effort was stuck due to concerns regarding C
>>>> language semantics.
>>>>
>>>
>>> Maybe we should make another attempt to implement bpf_dominating_decl?
>>> That seems like a more elegant solution than any other implemented or
>>> discussed alternative. Yonghong, WDYT?
>>
>> I would say it would be very difficult for upstream to agree with
>> bpf_dominating_decl. We already have lots of discussions and we
>> likely won't be able to satisfy Aaron who wants us to emit
>> adequate diagnostics which will involve lots of other work
>> and he also thinks this is too far away from C standard and he
>> wants us to implement in a llvm/clang tool which is not what
>> we want.
> 
> Ok, could we change the problem to detecting if some type is defined.
> Would it be possible to have something like
> 
> #if !__is_type_defined(struct abc)
> struct abc {
> };
> #endif
> 
> I think we talked about this and there were problems with this
> approach, but I don't remember details and how insurmountable the
> problem is. Having a way to check whether some type is defined would
> be very useful even outside of -target bpf parlance, though, so maybe
> it's the problem worth attacking?

Yes, we discussed this before. This will need to add additional work
in preprocessor. I just made a discussion topic in llvm discourse

https://discourse.llvm.org/t/add-a-type-checking-macro-is-type-defined-type/66268

Let us see whether we can get some upstream agreement or not.

> 
>>
>>>
>>> BTW, I suggest splitting libbpf btf_dedup and btf_dump changes into a
>>> separate series and sending them as non-RFC sooner. Those improvements
>>> are independent of all the header guards stuff, let's get them landed
>>> sooner.
>>>
>>>> After some discussion with Alexei and Yonghong I'd like to request
>>>> your comments regarding a somewhat brittle and partial solution to
>>>> this issue that relies on adding `#ifndef FOO_H ... #endif` guards in
>>>> the generated `vmlinux.h`.
>>>>
>>>
>>> [...]
>>>
>>>> Eduard Zingerman (12):
>>>>     libbpf: Deduplicate unambigous standalone forward declarations
>>>>     selftests/bpf: Tests for standalone forward BTF declarations
>>>>       deduplication
>>>>     libbpf: Support for BTF_DECL_TAG dump in C format
>>>>     selftests/bpf: Tests for BTF_DECL_TAG dump in C format
>>>>     libbpf: Header guards for selected data structures in vmlinux.h
>>>>     selftests/bpf: Tests for header guards printing in BTF dump
>>>>     bpftool: Enable header guards generation
>>>>     kbuild: Script to infer header guard values for uapi headers
>>>>     kbuild: Header guards for types from include/uapi/*.h in kernel BTF
>>>>     selftests/bpf: Script to verify uapi headers usage with vmlinux.h
>>>>     selftests/bpf: Known good uapi headers for test_uapi_headers.py
>>>>     selftests/bpf: script for infer_header_guards.pl testing
>>>>
>>>>    scripts/infer_header_guards.pl                | 191 +++++
>>>>    scripts/link-vmlinux.sh                       |  13 +-
>>>>    tools/bpf/bpftool/btf.c                       |   4 +-
>>>>    tools/lib/bpf/btf.c                           | 178 ++++-
>>>>    tools/lib/bpf/btf.h                           |   7 +-
>>>>    tools/lib/bpf/btf_dump.c                      | 232 +++++-
>>>>    .../selftests/bpf/good_uapi_headers.txt       | 677 ++++++++++++++++++
>>>>    tools/testing/selftests/bpf/prog_tests/btf.c  | 152 ++++
>>>>    .../selftests/bpf/prog_tests/btf_dump.c       |  11 +-
>>>>    .../bpf/progs/btf_dump_test_case_decl_tag.c   |  39 +
>>>>    .../progs/btf_dump_test_case_header_guards.c  |  94 +++
>>>>    .../bpf/test_uapi_header_guards_infer.sh      |  33 +
>>>>    .../selftests/bpf/test_uapi_headers.py        | 197 +++++
>>>>    13 files changed, 1816 insertions(+), 12 deletions(-)
>>>>    create mode 100755 scripts/infer_header_guards.pl
>>>>    create mode 100644 tools/testing/selftests/bpf/good_uapi_headers.txt
>>>>    create mode 100644 tools/testing/selftests/bpf/progs/btf_dump_test_case_decl_tag.c
>>>>    create mode 100644 tools/testing/selftests/bpf/progs/btf_dump_test_case_header_guards.c
>>>>    create mode 100755 tools/testing/selftests/bpf/test_uapi_header_guards_infer.sh
>>>>    create mode 100755 tools/testing/selftests/bpf/test_uapi_headers.py
>>>>
>>>> --
>>>> 2.34.1
>>>>

  reply	other threads:[~2022-10-28 18:57 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 22:27 [RFC bpf-next 00/12] Use uapi kernel headers with vmlinux.h Eduard Zingerman
2022-10-25 22:27 ` [RFC bpf-next 01/12] libbpf: Deduplicate unambigous standalone forward declarations Eduard Zingerman
2022-10-27 22:07   ` Andrii Nakryiko
2022-10-31  1:00     ` Eduard Zingerman
2022-10-31 15:49     ` Eduard Zingerman
2022-11-01 17:08       ` Alan Maguire
2022-11-01 17:37         ` Eduard Zingerman
2022-10-25 22:27 ` [RFC bpf-next 02/12] selftests/bpf: Tests for standalone forward BTF declarations deduplication Eduard Zingerman
2022-10-25 22:27 ` [RFC bpf-next 03/12] libbpf: Support for BTF_DECL_TAG dump in C format Eduard Zingerman
2022-10-27 22:36   ` Andrii Nakryiko
2022-10-25 22:27 ` [RFC bpf-next 04/12] selftests/bpf: Tests " Eduard Zingerman
2022-10-25 22:27 ` [RFC bpf-next 05/12] libbpf: Header guards for selected data structures in vmlinux.h Eduard Zingerman
2022-10-27 22:44   ` Andrii Nakryiko
2022-10-25 22:27 ` [RFC bpf-next 06/12] selftests/bpf: Tests for header guards printing in BTF dump Eduard Zingerman
2022-10-25 22:27 ` [RFC bpf-next 07/12] bpftool: Enable header guards generation Eduard Zingerman
2022-10-25 22:27 ` [RFC bpf-next 08/12] kbuild: Script to infer header guard values for uapi headers Eduard Zingerman
2022-10-27 22:51   ` Andrii Nakryiko
2022-10-25 22:27 ` [RFC bpf-next 09/12] kbuild: Header guards for types from include/uapi/*.h in kernel BTF Eduard Zingerman
2022-10-27 18:43   ` Yonghong Song
2022-10-27 18:55     ` Yonghong Song
2022-10-27 22:44       ` Yonghong Song
2022-10-28  0:00         ` Eduard Zingerman
2022-10-28  0:14           ` Mykola Lysenko
2022-10-28  1:23             ` Yonghong Song
2022-10-28  1:21           ` Yonghong Song
2022-10-25 22:27 ` [RFC bpf-next 10/12] selftests/bpf: Script to verify uapi headers usage with vmlinux.h Eduard Zingerman
2022-10-25 22:28 ` [RFC bpf-next 11/12] selftests/bpf: Known good uapi headers for test_uapi_headers.py Eduard Zingerman
2022-10-25 22:28 ` [RFC bpf-next 12/12] selftests/bpf: script for infer_header_guards.pl testing Eduard Zingerman
2022-10-25 23:46 ` [RFC bpf-next 00/12] Use uapi kernel headers with vmlinux.h Alexei Starovoitov
2022-10-26 22:46   ` Eduard Zingerman
2022-10-26 11:10 ` Alan Maguire
2022-10-26 23:54   ` Eduard Zingerman
2022-10-27 23:14 ` Andrii Nakryiko
2022-10-28  1:33   ` Yonghong Song
2022-10-28 17:13     ` Andrii Nakryiko
2022-10-28 18:56       ` Yonghong Song [this message]
2022-10-28 21:35         ` Andrii Nakryiko
2022-11-01 16:01           ` Alan Maguire
2022-11-01 18:35             ` Alexei Starovoitov
2022-11-01 19:21               ` Eduard Zingerman
2022-11-01 19:44                 ` Alexei Starovoitov
2022-11-11 21:55         ` Eduard Zingerman
2022-11-14  7:52           ` Yonghong Song
2022-11-14 21:13             ` Eduard Zingerman
2022-11-14 21:50               ` Alexei Starovoitov
2022-11-16  2:01                 ` Eduard Zingerman

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=af1facf9-7bc8-8a3d-0db4-7b3f333589a2@meta.com \
    --to=yhs@meta.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=arnaldo.melo@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kernel-team@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