From: Leon Hwang <leon.hwang@linux.dev>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, menglong8.dong@gmail.com
Subject: Re: [RFC PATCH bpf-next v2 3/6] bpf: Add common attr support for prog_load and btf_load
Date: Tue, 23 Sep 2025 23:50:45 +0800 [thread overview]
Message-ID: <b16183df-2915-4369-a0ae-ea484924ad79@linux.dev> (raw)
In-Reply-To: <CAEf4BzaRYeT4wzU7uCuYLF-7THnXL2KgbF3kkg-8fLE3phM-5w@mail.gmail.com>
On 2025/9/18 05:12, Andrii Nakryiko wrote:
> On Thu, Sep 11, 2025 at 9:33 AM Leon Hwang <leon.hwang@linux.dev> wrote:
>>
>> The log buffer of common attributes would be confusing with the one in
>> 'union bpf_attr' for BPF_PROG_LOAD and BPF_BTF_LOAD.
>>
>> In order to clarify the usage of these two 'log_buf's, they both can be
>> used for logging if:
>>
>> * They are same, including 'log_buf', 'log_level' and 'log_size'.
>> * One of them is missing, then another one will be used for logging.
>>
>
> I agree with the logic above, but I'm not sure whether we need to
> plumb common_attrs all the way into bpf_vlog_init, tbh. There are only
> two commands that can have log specified through both bpf_attr and
> bpf_common_attrs. I'd have those two commands check and resolve the
> log buffer pointer, size and flags on their own (sure, a bit of
> duplicated logic, but we won't have any new command having to do that,
> so that's fine in my book).
>
> And then I'd keep bpf_vlog_init completely unaware of common_attrs
> (which eventually have more stuff in it that's irrelevant to logging).
>
To avoid modifying bpf_vlog_init directly, one option would be to
introduce a new helper, e.g. bpf_vlog_init2 or
bpf_vlog_init_with_cattrs, to handle the case with common_attrs.
This way, bpf_vlog_init_with_cattrs could be used for BPF_PROG_LOAD and
BPF_BTF_LOAD, while the existing bpf_vlog_init remains unchanged and
could be used for BPF_MAP_CREATE.
That would avoid duplicating the log handling logic, while also keeping
the separation between the two cases clear.
> This seems cleaner than plumbing this through so deeply.
>
>> If they both have 'log_buf' but they are not same, a log message will be
>> written to the log buffer of 'union bpf_attr'.
>>
>
> Meh, whatever, this is unlikely user error, just error out with
> -EINVAL or something. Let's not invent "log here, but not here" logic.
>
In that case, we can return -EUSERS, as Alexei suggested earlier.
Thanks,
Leon
next prev parent reply other threads:[~2025-09-23 15:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 16:33 [RFC PATCH bpf-next v2 0/6] bpf: Extend bpf syscall with common attributes support Leon Hwang
2025-09-11 16:33 ` [RFC PATCH bpf-next v2 1/6] " Leon Hwang
2025-09-17 0:06 ` Andrii Nakryiko
2025-09-23 15:23 ` Leon Hwang
2025-09-11 16:33 ` [RFC PATCH bpf-next v2 2/6] libbpf: Add support for extended bpf syscall Leon Hwang
2025-09-17 0:06 ` Andrii Nakryiko
2025-09-23 15:36 ` Leon Hwang
2025-09-24 23:57 ` Andrii Nakryiko
2025-09-11 16:33 ` [RFC PATCH bpf-next v2 3/6] bpf: Add common attr support for prog_load and btf_load Leon Hwang
2025-09-17 21:12 ` Andrii Nakryiko
2025-09-23 15:50 ` Leon Hwang [this message]
2025-09-25 0:00 ` Andrii Nakryiko
2025-09-11 16:33 ` [RFC PATCH bpf-next v2 4/6] bpf: Add common attr support for map_create Leon Hwang
2025-09-17 21:39 ` Andrii Nakryiko
2025-09-17 21:49 ` Alexei Starovoitov
2025-09-23 15:52 ` Leon Hwang
2025-09-23 16:27 ` Leon Hwang
2025-09-18 23:29 ` Eduard Zingerman
2025-09-23 16:31 ` Leon Hwang
2025-09-11 16:33 ` [RFC PATCH bpf-next v2 5/6] libbpf: " Leon Hwang
2025-09-17 21:45 ` Andrii Nakryiko
2025-09-17 21:46 ` Andrii Nakryiko
2025-09-23 16:40 ` Leon Hwang
2025-09-25 0:02 ` Andrii Nakryiko
2025-09-11 16:33 ` [RFC PATCH bpf-next v2 6/6] selftests/bpf: Add cases to test map create failure log Leon Hwang
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=b16183df-2915-4369-a0ae-ea484924ad79@linux.dev \
--to=leon.hwang@linux.dev \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=menglong8.dong@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.