All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v1] bpf,arena: Rename the kfunc set variable
@ 2024-05-07  2:49 Haiyue Wang
  2024-05-07 14:36 ` Alexei Starovoitov
  0 siblings, 1 reply; 6+ messages in thread
From: Haiyue Wang @ 2024-05-07  2:49 UTC (permalink / raw)
  To: bpf
  Cc: Haiyue Wang, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, open list

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(-)

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);
-- 
2.43.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v1] bpf,arena: Rename the kfunc set variable
  2024-05-07  2:49 [PATCH bpf-next v1] bpf,arena: Rename the kfunc set variable Haiyue Wang
@ 2024-05-07 14:36 ` Alexei Starovoitov
  2024-05-07 16:43   ` Andrii Nakryiko
  0 siblings, 1 reply; 6+ messages in thread
From: Alexei Starovoitov @ 2024-05-07 14:36 UTC (permalink / raw)
  To: Haiyue Wang
  Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	open list

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v1] bpf,arena: Rename the kfunc set variable
  2024-05-07 14:36 ` Alexei Starovoitov
@ 2024-05-07 16:43   ` Andrii Nakryiko
  2024-05-07 20:41     ` Alexei Starovoitov
  0 siblings, 1 reply; 6+ messages in thread
From: Andrii Nakryiko @ 2024-05-07 16:43 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Haiyue Wang, bpf, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, open list

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v1] bpf,arena: Rename the kfunc set variable
  2024-05-07 16:43   ` Andrii Nakryiko
@ 2024-05-07 20:41     ` Alexei Starovoitov
  2024-05-07 21:20       ` Andrii Nakryiko
  0 siblings, 1 reply; 6+ messages in thread
From: Alexei Starovoitov @ 2024-05-07 20:41 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Haiyue Wang, bpf, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, open list

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v1] bpf,arena: Rename the kfunc set variable
  2024-05-07 20:41     ` Alexei Starovoitov
@ 2024-05-07 21:20       ` Andrii Nakryiko
  2024-05-08  0:49         ` Wang, Haiyue
  0 siblings, 1 reply; 6+ messages in thread
From: Andrii Nakryiko @ 2024-05-07 21:20 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Haiyue Wang, bpf, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, open list

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH bpf-next v1] bpf,arena: Rename the kfunc set variable
  2024-05-07 21:20       ` Andrii Nakryiko
@ 2024-05-08  0:49         ` Wang, Haiyue
  0 siblings, 0 replies; 6+ messages in thread
From: Wang, Haiyue @ 2024-05-08  0:49 UTC (permalink / raw)
  To: Andrii Nakryiko, Alexei Starovoitov
  Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	open list

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-08  0:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-07  2:49 [PATCH bpf-next v1] bpf,arena: Rename the kfunc set variable Haiyue Wang
2024-05-07 14:36 ` Alexei Starovoitov
2024-05-07 16:43   ` Andrii Nakryiko
2024-05-07 20:41     ` Alexei Starovoitov
2024-05-07 21:20       ` Andrii Nakryiko
2024-05-08  0:49         ` Wang, Haiyue

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.