From: Leon Hwang <leon.hwang@linux.dev>
To: Eduard Zingerman <eddyz87@gmail.com>, bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
menglong8.dong@gmail.com
Subject: Re: [RFC PATCH bpf-next v2 4/6] bpf: Add common attr support for map_create
Date: Wed, 24 Sep 2025 00:31:29 +0800 [thread overview]
Message-ID: <9d155b1c-aa37-40c8-ac58-797f67b8d07c@linux.dev> (raw)
In-Reply-To: <5d1f41605348e45e60c95a75bdbb286efa3ef3ac.camel@gmail.com>
On 2025/9/19 07:29, Eduard Zingerman wrote:
> On Fri, 2025-09-12 at 00:33 +0800, Leon Hwang wrote:
>
> [...]
>
>> @@ -1355,6 +1356,18 @@ static int map_create(union bpf_attr *attr, bool kernel)
>> if (err)
>> return -EINVAL;
>>
>> + if (common_attrs->log_buf) {
>> + log = kvzalloc(sizeof(*log), GFP_KERNEL);
>> + if (!log)
>> + return -ENOMEM;
>> + err = bpf_vlog_init(log, BPF_LOG_FIXED, u64_to_user_ptr(common_attrs->log_buf),
>> + common_attrs->log_size, NULL);
>
> Maybe use common_attrs->log_level instead of BPF_LOG_FIXED?
> Just for consistent behavior with program and btf load operations.
>
It doesn’t really make sense to let users set log_level in this case,
because logging in map_create is too simple for different log levels to
have any meaningful effect.
>> + if (err) {
>> + kvfree(log);
>> + return err;
>> + }
>> + }
>> +
>> /* check BPF_F_TOKEN_FD flag, remember if it's set, and then clear it
>> * to avoid per-map type checks tripping on unknown flag
>> */
>
> [...]
>
>> @@ -1565,6 +1605,10 @@ static int map_create(union bpf_attr *attr, bool kernel)
>> bpf_map_free(map);
>> put_token:
>> bpf_token_put(token);
>> + if (err && log)
>> + (void) bpf_vlog_finalize(log, &log_true_size);
>> + if (log)
>> + kvfree(log);
>> return err;
>> }
>
> +1 to Andrii's suggestion to report log size back,
> just for consistency reasons.
Right.
The log_true_size will be reported back to users.
Thanks,
Leon
next prev parent reply other threads:[~2025-09-23 16:31 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
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 [this message]
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=9d155b1c-aa37-40c8-ac58-797f67b8d07c@linux.dev \
--to=leon.hwang@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox