From: Yonghong Song <yhs@meta.com>
To: David Vernet <void@manifault.com>, bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
martin.lau@linux.dev, yhs@fb.com, song@kernel.org,
sdf@google.com, john.fastabend@gmail.com, kpsingh@kernel.org,
jolsa@kernel.org, haoluo@google.com, tj@kernel.org,
kernel-team@fb.com, linux-kernel@vger.kernel.org,
kernel test robot <lkp@intel.com>
Subject: Re: [PATCH bpf-next] bpf: Don't use idx variable when registering kfunc dtors
Date: Wed, 23 Nov 2022 07:14:04 -0800 [thread overview]
Message-ID: <0cfe0b93-9f35-bdca-96af-f11593832037@meta.com> (raw)
In-Reply-To: <20221123135253.637525-1-void@manifault.com>
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
> };
next prev parent reply other threads:[~2022-11-23 15:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-23 13:52 David Vernet
2022-11-23 15:14 ` Yonghong Song [this message]
2022-11-23 20:00 ` patchwork-bot+netdevbpf
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=0cfe0b93-9f35-bdca-96af-f11593832037@meta.com \
--to=yhs@meta.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=martin.lau@linux.dev \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=tj@kernel.org \
--cc=void@manifault.com \
--cc=yhs@fb.com \
/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
all inboxes | Powered by JetHome®