Skip to contentSkip to conversation

bpf,arena: Rename the kfunc set variable

PATCH In review Haiyue Wang 3 participants 6 messages May 7, 2024 – May 8, 2024 BPF

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf,arena: Rename the kfunc set variable

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'.

---
 kernel/bpf/arena.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/arena.c +2 -2
index 6c81630c5293..ef2177c0465f 100644
@@ -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);
Signature · 1 line
2.43.2
#1 lore raw
Quoted 6 lines · Haiyue Wang

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

#2 lore raw
Quoted 9 lines · Alexei Starovoitov
Quoted 6 lines · Haiyue Wang

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'.

Quoted 6 lines

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?

Quoted 2 lines

pw-bot: cr

#3 lore raw
Quoted 12 lines · Andrii Nakryiko
Quoted 9 lines · Alexei Starovoitov
Quoted 6 lines · Haiyue Wang

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'.

Quoted 8 lines
Quoted 6 lines

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.

Quoted 2 lines

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.

Quoted 2 lines
Quoted 2 lines

pw-bot: cr

#4 lore raw
Quoted 19 lines · Alexei Starovoitov
Quoted 16 lines · Andrii Nakryiko
Quoted 13 lines · Alexei Starovoitov
Quoted 6 lines · Haiyue Wang

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.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

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.

Quoted 11 lines

There are tons of such cases in the kernel src tree.

Quoted 2 lines

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.

Quoted 2 lines
Quoted 2 lines

pw-bot: cr

#5 lore raw
Quoted 36 lines

-----Original Message-----
From: Andrii Nakryiko <[email protected]>
Sent: Wednesday, May 8, 2024 05:21
To: Alexei Starovoitov <[email protected]>
Cc: Wang, Haiyue <[email protected]>; bpf <[email protected]>; Alexei Starovoitov <[email protected]>; Daniel Borkmann <[email protected]>; Andrii Nakryiko <[email protected]>; Martin KaFai Lau <[email protected]>; Eduard Zingerman <[email protected]>; Song Liu <[email protected]>; Yonghong Song <[email protected]>; John Fastabend <[email protected]>; KP Singh <[email protected]>; Stanislav Fomichev <[email protected]>; Hao Luo <[email protected]>; Jiri Olsa <[email protected]>; open list <[email protected]>
Subject: Re: [PATCH bpf-next v1] bpf,arena: Rename the kfunc set variable

Quoted 22 lines · Alexei Starovoitov
Quoted 19 lines · Andrii Nakryiko
Quoted 15 lines · Alexei Starovoitov
Quoted 6 lines · Haiyue Wang

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.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

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

Quoted 11 lines

matching to have some "arena" mention in the name. But it's minor, let's keep it.

Quoted 8 lines

There are tons of such cases in the kernel src tree.

Quoted 2 lines

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". ;-)

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

pw-bot: cr