diff mbox series

[bpf-next,v1] bpf,arena: Rename the kfunc set variable

Message ID 20240507024952.1590681-1-haiyue.wang@intel.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next,v1] bpf,arena: Rename the kfunc set variable | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-18 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-31 success Logs for x86_64-llvm-17 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-16 success Logs for s390x-gcc / test (test_verifier, false, 360) / test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for s390x-gcc / test (test_maps, false, 360) / test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-gcc / test (test_progs_no_alu32_parallel, true, 30) / test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-39 success Logs for x86_64-llvm-18 / test (test_progs_cpuv4, false, 360) / test_progs_cpuv4 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-37 success Logs for x86_64-llvm-18 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-36 success Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18 and -O2 optimization
bpf/vmtest-bpf-next-VM_Test-22 success Logs for x86_64-gcc / test (test_progs, false, 360) / test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for aarch64-gcc / test (test_verifier, false, 360) / test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-gcc / test (test_verifier, false, 360) / test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-40 success Logs for x86_64-llvm-18 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-35 success Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-30 success Logs for x86_64-llvm-17 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-17 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-34 success Logs for x86_64-llvm-17 / veristat
bpf/vmtest-bpf-next-VM_Test-10 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-gcc / veristat / veristat on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-41 success Logs for x86_64-llvm-18 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-38 success Logs for x86_64-llvm-18 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-33 success Logs for x86_64-llvm-17 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test (test_maps, false, 360) / test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17 and -O2 optimization
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-21 success Logs for x86_64-gcc / test (test_maps, false, 360) / test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-42 success Logs for x86_64-llvm-18 / veristat
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / test (test_progs, false, 360) / test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for s390x-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for aarch64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-32 success Logs for x86_64-llvm-17 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-14 success Logs for s390x-gcc / test (test_progs, false, 360) / test_progs on s390x with gcc

Commit Message

Wang, Haiyue May 7, 2024, 2:49 a.m. UTC
Rename the kfunc set variable to specify the 'arena' function scope,
although the 'UNSPEC' type BPF program is mapped to 'COMMON' hook.

And there is 'common_kfunc_set' defined for real 'common' function in
file 'kernel/bpf/helpers.c'.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
---
 kernel/bpf/arena.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alexei Starovoitov May 7, 2024, 2:36 p.m. UTC | #1
On Mon, May 6, 2024 at 7:46 PM Haiyue Wang <haiyue.wang@intel.com> wrote:
>
> Rename the kfunc set variable to specify the 'arena' function scope,
> although the 'UNSPEC' type BPF program is mapped to 'COMMON' hook.
>
> And there is 'common_kfunc_set' defined for real 'common' function in
> file 'kernel/bpf/helpers.c'.

I think common_kfunc_set is a better name to describe that these
two kfuncs are in a common category.
BPF_PROG_TYPE_UNSPEC is a lot less obvious.

There are two static common_kfunc_set in helpers.c and arena.c
and that's fine.

pw-bot: cr
Andrii Nakryiko May 7, 2024, 4:43 p.m. UTC | #2
On Tue, May 7, 2024 at 7:36 AM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Mon, May 6, 2024 at 7:46 PM Haiyue Wang <haiyue.wang@intel.com> wrote:
> >
> > Rename the kfunc set variable to specify the 'arena' function scope,
> > although the 'UNSPEC' type BPF program is mapped to 'COMMON' hook.
> >
> > And there is 'common_kfunc_set' defined for real 'common' function in
> > file 'kernel/bpf/helpers.c'.
>
> I think common_kfunc_set is a better name to describe that these
> two kfuncs are in a common category.
> BPF_PROG_TYPE_UNSPEC is a lot less obvious.
>
> There are two static common_kfunc_set in helpers.c and arena.c
> and that's fine.

it is actually confusing when reading/grepping code, though, so why
not have arena_common_kfunc_set and whatever the meaningful
"qualifier" name for the other one?

>
> pw-bot: cr
Alexei Starovoitov May 7, 2024, 8:41 p.m. UTC | #3
On Tue, May 7, 2024 at 9:43 AM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Tue, May 7, 2024 at 7:36 AM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Mon, May 6, 2024 at 7:46 PM Haiyue Wang <haiyue.wang@intel.com> wrote:
> > >
> > > Rename the kfunc set variable to specify the 'arena' function scope,
> > > although the 'UNSPEC' type BPF program is mapped to 'COMMON' hook.
> > >
> > > And there is 'common_kfunc_set' defined for real 'common' function in
> > > file 'kernel/bpf/helpers.c'.
> >
> > I think common_kfunc_set is a better name to describe that these
> > two kfuncs are in a common category.
> > BPF_PROG_TYPE_UNSPEC is a lot less obvious.
> >
> > There are two static common_kfunc_set in helpers.c and arena.c
> > and that's fine.
>
> it is actually confusing when reading/grepping code, though, so why

What's the confusion? Same name static var in different files?
There are tons of such cases in the kernel src tree.

> not have arena_common_kfunc_set and whatever the meaningful
> "qualifier" name for the other one?

arena_common_kfunc_set is certainly better than arena_kfunc_set,
but I don't like to make the precedent to start renaming static vars
because they have the same name.

> >
> > pw-bot: cr
Andrii Nakryiko May 7, 2024, 9:20 p.m. UTC | #4
On Tue, May 7, 2024 at 1:42 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Tue, May 7, 2024 at 9:43 AM Andrii Nakryiko
> <andrii.nakryiko@gmail.com> wrote:
> >
> > On Tue, May 7, 2024 at 7:36 AM Alexei Starovoitov
> > <alexei.starovoitov@gmail.com> wrote:
> > >
> > > On Mon, May 6, 2024 at 7:46 PM Haiyue Wang <haiyue.wang@intel.com> wrote:
> > > >
> > > > Rename the kfunc set variable to specify the 'arena' function scope,
> > > > although the 'UNSPEC' type BPF program is mapped to 'COMMON' hook.
> > > >
> > > > And there is 'common_kfunc_set' defined for real 'common' function in
> > > > file 'kernel/bpf/helpers.c'.
> > >
> > > I think common_kfunc_set is a better name to describe that these
> > > two kfuncs are in a common category.
> > > BPF_PROG_TYPE_UNSPEC is a lot less obvious.
> > >
> > > There are two static common_kfunc_set in helpers.c and arena.c
> > > and that's fine.
> >
> > it is actually confusing when reading/grepping code, though, so why
>
> What's the confusion? Same name static var in different files?

Not in general, but in this case it's arena-specific kfuncs for all
program types, and it's initialized with &arena_kfuncs, so it would be
matching to have some "arena" mention in the name. But it's minor,
let's keep it.

> There are tons of such cases in the kernel src tree.
>
> > not have arena_common_kfunc_set and whatever the meaningful
> > "qualifier" name for the other one?
>
> arena_common_kfunc_set is certainly better than arena_kfunc_set,
> but I don't like to make the precedent to start renaming static vars
> because they have the same name.
>
> > >
> > > pw-bot: cr
Wang, Haiyue May 8, 2024, 12:49 a.m. UTC | #5
> -----Original Message-----
> From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
> Sent: Wednesday, May 8, 2024 05:21
> To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
> Cc: Wang, Haiyue <haiyue.wang@intel.com>; bpf <bpf@vger.kernel.org>; Alexei Starovoitov
> <ast@kernel.org>; Daniel Borkmann <daniel@iogearbox.net>; Andrii Nakryiko <andrii@kernel.org>; Martin
> KaFai Lau <martin.lau@linux.dev>; Eduard Zingerman <eddyz87@gmail.com>; Song Liu <song@kernel.org>;
> Yonghong Song <yonghong.song@linux.dev>; John Fastabend <john.fastabend@gmail.com>; KP Singh
> <kpsingh@kernel.org>; Stanislav Fomichev <sdf@google.com>; Hao Luo <haoluo@google.com>; Jiri Olsa
> <jolsa@kernel.org>; open list <linux-kernel@vger.kernel.org>
> Subject: Re: [PATCH bpf-next v1] bpf,arena: Rename the kfunc set variable
> 
> On Tue, May 7, 2024 at 1:42 PM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Tue, May 7, 2024 at 9:43 AM Andrii Nakryiko
> > <andrii.nakryiko@gmail.com> wrote:
> > >
> > > On Tue, May 7, 2024 at 7:36 AM Alexei Starovoitov
> > > <alexei.starovoitov@gmail.com> wrote:
> > > >
> > > > On Mon, May 6, 2024 at 7:46 PM Haiyue Wang <haiyue.wang@intel.com> wrote:
> > > > >
> > > > > Rename the kfunc set variable to specify the 'arena' function scope,
> > > > > although the 'UNSPEC' type BPF program is mapped to 'COMMON' hook.
> > > > >
> > > > > And there is 'common_kfunc_set' defined for real 'common' function in
> > > > > file 'kernel/bpf/helpers.c'.
> > > >
> > > > I think common_kfunc_set is a better name to describe that these
> > > > two kfuncs are in a common category.
> > > > BPF_PROG_TYPE_UNSPEC is a lot less obvious.
> > > >
> > > > There are two static common_kfunc_set in helpers.c and arena.c
> > > > and that's fine.
> > >
> > > it is actually confusing when reading/grepping code, though, so why
> >
> > What's the confusion? Same name static var in different files?
> 
> Not in general, but in this case it's arena-specific kfuncs for all
> program types, and it's initialized with &arena_kfuncs, so it would be

Yes, the original idea is to try match some kind of map style:
	common_kfunc_set.set = &common_btf_ids

> matching to have some "arena" mention in the name. But it's minor,
> let's keep it.
> 
> > There are tons of such cases in the kernel src tree.
> >
> > > not have arena_common_kfunc_set and whatever the meaningful
> > > "qualifier" name for the other one?
> >
> > arena_common_kfunc_set is certainly better than arena_kfunc_set,
> > but I don't like to make the precedent to start renaming static vars
> > because they have the same name.

From the category point of view, "arena" should be "common" function, and
make sense to name "common_kfunc_set". ;-)

> >
> > > >
> > > > pw-bot: cr
diff mbox series

Patch

diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c
index 6c81630c5293..ef2177c0465f 100644
--- a/kernel/bpf/arena.c
+++ b/kernel/bpf/arena.c
@@ -557,13 +557,13 @@  BTF_ID_FLAGS(func, bpf_arena_alloc_pages, KF_TRUSTED_ARGS | KF_SLEEPABLE)
 BTF_ID_FLAGS(func, bpf_arena_free_pages, KF_TRUSTED_ARGS | KF_SLEEPABLE)
 BTF_KFUNCS_END(arena_kfuncs)
 
-static const struct btf_kfunc_id_set common_kfunc_set = {
+static const struct btf_kfunc_id_set arena_kfunc_set = {
 	.owner = THIS_MODULE,
 	.set   = &arena_kfuncs,
 };
 
 static int __init kfunc_init(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, &common_kfunc_set);
+	return register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, &arena_kfunc_set);
 }
 late_initcall(kfunc_init);