From: Jiri Olsa <olsajiri@gmail.com>
To: Daniel Xu <dxu@dxuuu.xyz>
Cc: benjamin.tissoires@redhat.com, hawk@kernel.org,
edumazet@google.com, alexandre.torgue@foss.st.com,
ebiggers@kernel.org, tj@kernel.org, rostedt@goodmis.org,
shuah@kernel.org, martin.lau@linux.dev, ast@kernel.org,
fw@strlen.de, kuba@kernel.org, pablo@netfilter.org,
jikos@kernel.org, john.fastabend@gmail.com,
mcoquelin.stm32@gmail.com, mhiramat@kernel.org,
yonghong.song@linux.dev, Herbert Xu <herbert@gondor.apana.org.au>,
dsahern@kernel.org, hannes@cmpxchg.org, lizefan.x@bytedance.com,
pabeni@redhat.com, steffen.klassert@secunet.com,
daniel@iogearbox.net, tytso@mit.edu, andrii@kernel.org,
davem@davemloft.net, kadlec@netfilter.org, song@kernel.org,
alexei.starovoitov@gmail.com, olsajiri@gmail.com,
quentin@isovalent.com, alan.maguire@oracle.com, memxor@gmail.com,
kpsingh@kernel.org, sdf@google.com, haoluo@google.com,
mathieu.desnoyers@efficios.com, mykolal@fb.com,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
fsverity@lists.linux.dev, bpf@vger.kernel.org,
cgroups@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, linux-kselftest@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH bpf-next 2/2] bpf: treewide: Annotate BPF kfuncs in BTF
Date: Thu, 4 Jan 2024 12:41:51 +0100 [thread overview]
Message-ID: <ZZaZf_8RuX2xqZGf@krava> (raw)
In-Reply-To: <68d5598e5708dfe3370406cd5c946565ca4b50f1.1704324602.git.dxu@dxuuu.xyz>
On Wed, Jan 03, 2024 at 04:31:56PM -0700, Daniel Xu wrote:
SNIP
> diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h
> index 88f914579fa1..771e29762a2d 100644
> --- a/include/linux/btf_ids.h
> +++ b/include/linux/btf_ids.h
> @@ -8,6 +8,9 @@ struct btf_id_set {
> u32 ids[];
> };
>
> +/* This flag implies BTF_SET8 holds kfunc(s) */
> +#define BTF_SET8_KFUNC (1 << 0)
> +
> struct btf_id_set8 {
> u32 cnt;
> u32 flags;
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 51e8b4bee0c8..b8ba00a4179f 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -7769,6 +7769,9 @@ static int __register_btf_kfunc_id_set(enum btf_kfunc_hook hook,
> struct btf *btf;
> int ret, i;
>
> + /* All kfuncs need to be tagged as such in BTF */
> + WARN_ON(!(kset->set->flags & BTF_SET8_KFUNC));
__register_btf_kfunc_id_set gets called also from the 'hooks' path:
bpf_mptcp_kfunc_init
register_btf_fmodret_id_set
__register_btf_kfunc_id_set
so it will hit the warn.. it should be probably in the register_btf_kfunc_id_set ?
also given that we can have modules calling register_btf_kfunc_id_set,
should we just return error instead of the warn?
SNIP
> diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> index 91907b321f91..32972334cd50 100644
> --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> @@ -341,7 +341,7 @@ static struct bin_attribute bin_attr_bpf_testmod_file __ro_after_init = {
> .write = bpf_testmod_test_write,
> };
>
> -BTF_SET8_START(bpf_testmod_common_kfunc_ids)
> +BTF_SET8_START(bpf_testmod_common_kfunc_ids, BTF_SET8_KFUNC)
> BTF_ID_FLAGS(func, bpf_iter_testmod_seq_new, KF_ITER_NEW)
> BTF_ID_FLAGS(func, bpf_iter_testmod_seq_next, KF_ITER_NEXT | KF_RET_NULL)
> BTF_ID_FLAGS(func, bpf_iter_testmod_seq_destroy, KF_ITER_DESTROY)
we need to change also bpf_testmod_check_kfunc_ids set
jirka
> --
> 2.42.1
>
next prev parent reply other threads:[~2024-01-04 11:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-03 23:31 [PATCH bpf-next 0/2] Annotate kfuncs in .BTF_ids section Daniel Xu
2024-01-03 23:31 ` [PATCH bpf-next 2/2] bpf: treewide: Annotate BPF kfuncs in BTF Daniel Xu
2024-01-04 11:41 ` Jiri Olsa [this message]
2024-01-05 1:17 ` Daniel Xu
2024-01-05 2:37 ` Daniel Xu
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=ZZaZf_8RuX2xqZGf@krava \
--to=olsajiri@gmail.com \
--cc=alan.maguire@oracle.com \
--cc=alexandre.torgue@foss.st.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=benjamin.tissoires@redhat.com \
--cc=bpf@vger.kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=coreteam@netfilter.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=dxu@dxuuu.xyz \
--cc=ebiggers@kernel.org \
--cc=edumazet@google.com \
--cc=fsverity@lists.linux.dev \
--cc=fw@strlen.de \
--cc=hannes@cmpxchg.org \
--cc=haoluo@google.com \
--cc=hawk@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=jikos@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kadlec@netfilter.org \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=martin.lau@linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=memxor@gmail.com \
--cc=mhiramat@kernel.org \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=quentin@isovalent.com \
--cc=rostedt@goodmis.org \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=tj@kernel.org \
--cc=tytso@mit.edu \
--cc=yonghong.song@linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).