BPF List
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, "Alexei Starovoitov" <ast@kernel.org>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Song Liu" <song@kernel.org>, Eduard <eddyz87@gmail.com>,
	"Daniel Xu" <dxu@dxuuu.xyz>, "Daniel Müller" <deso@posteo.net>,
	kernel-patches-bot@fb.com
Subject: Re: [PATCH bpf-next v6 2/7] bpf: Introduce BPF_F_CPU and BPF_F_ALL_CPUS flags
Date: Wed, 10 Sep 2025 10:20:16 +0800	[thread overview]
Message-ID: <73949da2-30fe-482e-ba2b-443978a666ef@linux.dev> (raw)
In-Reply-To: <CAADnVQJcu2VM-NdXsteA=0+MtdxvhGya7PZ5_UcYe+d9xqobbw@mail.gmail.com>



On 10/9/25 07:07, Alexei Starovoitov wrote:
> On Tue, Sep 9, 2025 at 7:14 AM Leon Hwang <leon.hwang@linux.dev> wrote:
>>
>> Introduce BPF_F_CPU and BPF_F_ALL_CPUS flags and check them for
>> following APIs:
>>
>> * 'map_lookup_elem()'
>> * 'map_update_elem()'
>> * 'generic_map_lookup_batch()'
>> * 'generic_map_update_batch()'
>>
>> And, get the correct value size for these APIs.
>>
>> Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
>> ---
>>  include/linux/bpf.h            | 22 ++++++++++++++++++
>>  include/uapi/linux/bpf.h       |  2 ++
>>  kernel/bpf/syscall.c           | 42 ++++++++++++++++++++++------------
>>  tools/include/uapi/linux/bpf.h |  2 ++
>>  4 files changed, 54 insertions(+), 14 deletions(-)
>>
>> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
>> index 8f6e87f0f3a89..60c235836987d 100644
>> --- a/include/linux/bpf.h
>> +++ b/include/linux/bpf.h
>> @@ -3709,4 +3709,26 @@ int bpf_prog_get_file_line(struct bpf_prog *prog, unsigned long ip, const char *
>>                            const char **linep, int *nump);
>>  struct bpf_prog *bpf_prog_find_from_stack(void);
>>
>> +static inline int bpf_map_check_cpu_flags(u64 flags, bool check_all_cpus_flag)
>> +{
> 
> This function is not used in this patch. Don't add it without users.
> 
> Also I really don't like 'bool' arguments.
> They make callsite hard to read.

Agreed. Using a bool argument here makes the call sites harder to
understand.

> Instead of bool use
> bpf_map_check_flags(u64 flags, u64 allowed_flags)
> 
> so the callsites will look like:
> bpf_map_check_flags(flags, BPF_F_CPU);
> and
> bpf_map_check_flags(flags, BPF_F_CPU | BPF_F_ALL_CPUS);
> 
> Also two functions that do very similar things look redundant.
> This bpf_map_check_flags() vs bpf_map_check_op_flags()...
> I think one should do it.
> 
Yes. It would be better to consolidate this logic into
bpf_map_check_op_flags(), rather than introducing a separate but
overlapping helper. That should keep the code simpler and avoid redundancy.

Thanks,
Leon

[...]

  reply	other threads:[~2025-09-10  2:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09 14:14 [PATCH bpf-next v6 0/7] bpf: Introduce BPF_F_CPU and BPF_F_ALL_CPUS flags for percpu maps Leon Hwang
2025-09-09 14:14 ` [PATCH bpf-next v6 1/7] bpf: Introduce internal bpf_map_check_op_flags helper function Leon Hwang
2025-09-09 14:14 ` [PATCH bpf-next v6 2/7] bpf: Introduce BPF_F_CPU and BPF_F_ALL_CPUS flags Leon Hwang
2025-09-09 23:07   ` Alexei Starovoitov
2025-09-10  2:20     ` Leon Hwang [this message]
2025-09-09 14:14 ` [PATCH bpf-next v6 3/7] bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_array maps Leon Hwang
2025-09-09 14:14 ` [PATCH bpf-next v6 4/7] bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_hash and lru_percpu_hash maps Leon Hwang
2025-09-09 14:14 ` [PATCH bpf-next v6 5/7] bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_cgroup_storage maps Leon Hwang
2025-09-09 14:14 ` [PATCH bpf-next v6 6/7] libbpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu maps Leon Hwang
2025-09-09 14:14 ` [PATCH bpf-next v6 7/7] selftests/bpf: Add cases to test BPF_F_CPU and BPF_F_ALL_CPUS flags 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=73949da2-30fe-482e-ba2b-443978a666ef@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=deso@posteo.net \
    --cc=dxu@dxuuu.xyz \
    --cc=eddyz87@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-patches-bot@fb.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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