* [PATCH bpf-next] bpf: Don't use idx variable when registering kfunc dtors
@ 2022-11-23 13:52 David Vernet
2022-11-23 15:14 ` Yonghong Song
2022-11-23 20:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: David Vernet @ 2022-11-23 13:52 UTC (permalink / raw)
To: bpf
Cc: ast, andrii, daniel, martin.lau, yhs, song, sdf, john.fastabend,
kpsingh, jolsa, haoluo, tj, kernel-team, linux-kernel,
kernel test robot
In commit fda01efc6160 ("bpf: Enable cgroups to be used as kptrs"), I
added an 'int idx' variable to kfunc_init() which was meant to
dynamically set the index of the btf id entries of the
'generic_dtor_ids' array. This was done to make the code slightly less
brittle as the struct cgroup * kptr kfuncs such as bpf_cgroup_aquire()
are compiled out if CONFIG_CGROUPS is not defined. This, however, causes
an lkp build warning:
>> kernel/bpf/helpers.c:2005:40: warning: multiple unsequenced
modifications to 'idx' [-Wunsequenced]
.btf_id = generic_dtor_ids[idx++],
Fix the warning by just hard-coding the indices.
Fixes: fda01efc6160 ("bpf: Enable cgroups to be used as kptrs")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: David Vernet <void@manifault.com>
---
kernel/bpf/helpers.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index e4e9db301db5..da2681ebb7c3 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2019,16 +2019,16 @@ static const struct btf_kfunc_id_set common_kfunc_set = {
static int __init kfunc_init(void)
{
- int ret, idx = 0;
+ int ret;
const struct btf_id_dtor_kfunc generic_dtors[] = {
{
- .btf_id = generic_dtor_ids[idx++],
- .kfunc_btf_id = generic_dtor_ids[idx++]
+ .btf_id = generic_dtor_ids[0],
+ .kfunc_btf_id = generic_dtor_ids[1]
},
#ifdef CONFIG_CGROUPS
{
- .btf_id = generic_dtor_ids[idx++],
- .kfunc_btf_id = generic_dtor_ids[idx++]
+ .btf_id = generic_dtor_ids[2],
+ .kfunc_btf_id = generic_dtor_ids[3]
},
#endif
};
--
2.38.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: Don't use idx variable when registering kfunc dtors
2022-11-23 13:52 [PATCH bpf-next] bpf: Don't use idx variable when registering kfunc dtors David Vernet
@ 2022-11-23 15:14 ` Yonghong Song
2022-11-23 20:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Yonghong Song @ 2022-11-23 15:14 UTC (permalink / raw)
To: David Vernet, bpf
Cc: ast, andrii, daniel, martin.lau, yhs, song, sdf, john.fastabend,
kpsingh, jolsa, haoluo, tj, kernel-team, linux-kernel,
kernel test robot
On 11/23/22 5:52 AM, David Vernet wrote:
> In commit fda01efc6160 ("bpf: Enable cgroups to be used as kptrs"), I
> added an 'int idx' variable to kfunc_init() which was meant to
> dynamically set the index of the btf id entries of the
> 'generic_dtor_ids' array. This was done to make the code slightly less
> brittle as the struct cgroup * kptr kfuncs such as bpf_cgroup_aquire()
> are compiled out if CONFIG_CGROUPS is not defined. This, however, causes
> an lkp build warning:
>
>>> kernel/bpf/helpers.c:2005:40: warning: multiple unsequenced
> modifications to 'idx' [-Wunsequenced]
> .btf_id = generic_dtor_ids[idx++],
>
> Fix the warning by just hard-coding the indices.
>
> Fixes: fda01efc6160 ("bpf: Enable cgroups to be used as kptrs")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: David Vernet <void@manifault.com>
I hit the same issue with clang build and used the same workaround below.
Acked-by: Yonghong Song <yhs@fb.com>
> ---
> kernel/bpf/helpers.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index e4e9db301db5..da2681ebb7c3 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -2019,16 +2019,16 @@ static const struct btf_kfunc_id_set common_kfunc_set = {
>
> static int __init kfunc_init(void)
> {
> - int ret, idx = 0;
> + int ret;
> const struct btf_id_dtor_kfunc generic_dtors[] = {
> {
> - .btf_id = generic_dtor_ids[idx++],
> - .kfunc_btf_id = generic_dtor_ids[idx++]
> + .btf_id = generic_dtor_ids[0],
> + .kfunc_btf_id = generic_dtor_ids[1]
> },
> #ifdef CONFIG_CGROUPS
> {
> - .btf_id = generic_dtor_ids[idx++],
> - .kfunc_btf_id = generic_dtor_ids[idx++]
> + .btf_id = generic_dtor_ids[2],
> + .kfunc_btf_id = generic_dtor_ids[3]
> },
> #endif
> };
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: Don't use idx variable when registering kfunc dtors
2022-11-23 13:52 [PATCH bpf-next] bpf: Don't use idx variable when registering kfunc dtors David Vernet
2022-11-23 15:14 ` Yonghong Song
@ 2022-11-23 20:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-23 20:00 UTC (permalink / raw)
To: David Vernet
Cc: bpf, ast, andrii, daniel, martin.lau, yhs, song, sdf,
john.fastabend, kpsingh, jolsa, haoluo, tj, kernel-team,
linux-kernel, lkp
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Wed, 23 Nov 2022 07:52:53 -0600 you wrote:
> In commit fda01efc6160 ("bpf: Enable cgroups to be used as kptrs"), I
> added an 'int idx' variable to kfunc_init() which was meant to
> dynamically set the index of the btf id entries of the
> 'generic_dtor_ids' array. This was done to make the code slightly less
> brittle as the struct cgroup * kptr kfuncs such as bpf_cgroup_aquire()
> are compiled out if CONFIG_CGROUPS is not defined. This, however, causes
> an lkp build warning:
>
> [...]
Here is the summary with links:
- [bpf-next] bpf: Don't use idx variable when registering kfunc dtors
https://git.kernel.org/bpf/bpf-next/c/2fcc6081a7bf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-23 20:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 13:52 [PATCH bpf-next] bpf: Don't use idx variable when registering kfunc dtors David Vernet
2022-11-23 15:14 ` Yonghong Song
2022-11-23 20:00 ` patchwork-bot+netdevbpf
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.