* [PATCH] bpf: export btf_find_by_name_kind and bpf_base_func_proto
@ 2024-07-24 3:19 Ming Lei
2024-07-24 4:43 ` Kui-Feng Lee
0 siblings, 1 reply; 7+ messages in thread
From: Ming Lei @ 2024-07-24 3:19 UTC (permalink / raw)
To: bpf, ast, martin.lau, song, andrii, drosen, kuifeng
Cc: sinquersw, thinker.li, Ming Lei, Benjamin Tissoires, Jiri Kosina
Export btf_find_by_name_kind and bpf_base_func_proto, so that kernel
module can use them.
Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
Without this change, hid-bpf can't be built as module.
Cc: Benjamin Tissoires <bentiss@kernel.org>
Cc: Jiri Kosina <jikos@kernel.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
kernel/bpf/btf.c | 1 +
kernel/bpf/helpers.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index d5019c4454d6..fdc4c0c1829d 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -567,6 +567,7 @@ s32 btf_find_by_name_kind(const struct btf *btf, const char *name, u8 kind)
return -ENOENT;
}
+EXPORT_SYMBOL_GPL(btf_find_by_name_kind);
s32 bpf_find_btf_id(const char *name, u32 kind, struct btf **btf_p)
{
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index b5f0adae8293..18d1a76f96d2 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2033,6 +2033,7 @@ bpf_base_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
return NULL;
}
}
+EXPORT_SYMBOL_GPL(bpf_base_func_proto);
void bpf_list_head_free(const struct btf_field *field, void *list_head,
struct bpf_spin_lock *spin_lock)
--
2.45.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] bpf: export btf_find_by_name_kind and bpf_base_func_proto
2024-07-24 3:19 [PATCH] bpf: export btf_find_by_name_kind and bpf_base_func_proto Ming Lei
@ 2024-07-24 4:43 ` Kui-Feng Lee
2024-07-24 9:13 ` Ming Lei
0 siblings, 1 reply; 7+ messages in thread
From: Kui-Feng Lee @ 2024-07-24 4:43 UTC (permalink / raw)
To: Ming Lei, bpf, ast, martin.lau, song, andrii, drosen, kuifeng
Cc: thinker.li, Benjamin Tissoires, Jiri Kosina
On 7/23/24 20:19, Ming Lei wrote:
> Export btf_find_by_name_kind and bpf_base_func_proto, so that kernel
> module can use them.
>
> Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
>
> Without this change, hid-bpf can't be built as module.
Could you give me more context?
Give me a link of an example code or something?
Or explain the use case?
Thanks!
>
> Cc: Benjamin Tissoires <bentiss@kernel.org>
> Cc: Jiri Kosina <jikos@kernel.org>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> kernel/bpf/btf.c | 1 +
> kernel/bpf/helpers.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index d5019c4454d6..fdc4c0c1829d 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -567,6 +567,7 @@ s32 btf_find_by_name_kind(const struct btf *btf, const char *name, u8 kind)
>
> return -ENOENT;
> }
> +EXPORT_SYMBOL_GPL(btf_find_by_name_kind);
>
> s32 bpf_find_btf_id(const char *name, u32 kind, struct btf **btf_p)
> {
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index b5f0adae8293..18d1a76f96d2 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -2033,6 +2033,7 @@ bpf_base_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
> return NULL;
> }
> }
> +EXPORT_SYMBOL_GPL(bpf_base_func_proto);
>
> void bpf_list_head_free(const struct btf_field *field, void *list_head,
> struct bpf_spin_lock *spin_lock)
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] bpf: export btf_find_by_name_kind and bpf_base_func_proto
2024-07-24 4:43 ` Kui-Feng Lee
@ 2024-07-24 9:13 ` Ming Lei
2024-07-26 3:20 ` Yonghong Song
0 siblings, 1 reply; 7+ messages in thread
From: Ming Lei @ 2024-07-24 9:13 UTC (permalink / raw)
To: Kui-Feng Lee
Cc: bpf, ast, martin.lau, song, andrii, drosen, kuifeng, thinker.li,
Benjamin Tissoires, Jiri Kosina
On Tue, Jul 23, 2024 at 09:43:12PM -0700, Kui-Feng Lee wrote:
>
>
> On 7/23/24 20:19, Ming Lei wrote:
> > Export btf_find_by_name_kind and bpf_base_func_proto, so that kernel
> > module can use them.
> >
> > Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
> >
> > Without this change, hid-bpf can't be built as module.
>
> Could you give me more context?
> Give me a link of an example code or something?
> Or explain the use case?
The merged patchset "Registrating struct_ops types from modules" is
trying to allow module to register struct_ops, which often needs
bpf_base_func_proto()(for allowing generic helpers available in
prog) and btf_find_by_name_kind() (for implementing .btf_struct_access).
One example is hid-bpf, which is a driver and supposed to build as module,
but it can't be done because the two APIs aren't exported.
I am working on ublk bpf support, which needs bpf_base_func_proto() at
least, and might require btf_find_by_name_kind() in future.
Thanks,
Ming
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] bpf: export btf_find_by_name_kind and bpf_base_func_proto
2024-07-24 9:13 ` Ming Lei
@ 2024-07-26 3:20 ` Yonghong Song
2024-07-26 3:45 ` Ming Lei
0 siblings, 1 reply; 7+ messages in thread
From: Yonghong Song @ 2024-07-26 3:20 UTC (permalink / raw)
To: Ming Lei, Kui-Feng Lee
Cc: bpf, ast, martin.lau, song, andrii, drosen, kuifeng, thinker.li,
Benjamin Tissoires, Jiri Kosina
On 7/24/24 2:13 AM, Ming Lei wrote:
> On Tue, Jul 23, 2024 at 09:43:12PM -0700, Kui-Feng Lee wrote:
>>
>> On 7/23/24 20:19, Ming Lei wrote:
>>> Export btf_find_by_name_kind and bpf_base_func_proto, so that kernel
>>> module can use them.
>>>
>>> Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
>>>
>>> Without this change, hid-bpf can't be built as module.
>> Could you give me more context?
>> Give me a link of an example code or something?
>> Or explain the use case?
> The merged patchset "Registrating struct_ops types from modules" is
> trying to allow module to register struct_ops, which often needs
> bpf_base_func_proto()(for allowing generic helpers available in
> prog) and btf_find_by_name_kind() (for implementing .btf_struct_access).
>
> One example is hid-bpf, which is a driver and supposed to build as module,
> but it can't be done because the two APIs aren't exported.
Could you give more specific examples about where these two APIs are
used in hid-bpf?
>
> I am working on ublk bpf support, which needs bpf_base_func_proto() at
> least, and might require btf_find_by_name_kind() in future.
>
>
> Thanks,
> Ming
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] bpf: export btf_find_by_name_kind and bpf_base_func_proto
2024-07-26 3:20 ` Yonghong Song
@ 2024-07-26 3:45 ` Ming Lei
2024-07-26 5:39 ` Yonghong Song
0 siblings, 1 reply; 7+ messages in thread
From: Ming Lei @ 2024-07-26 3:45 UTC (permalink / raw)
To: Yonghong Song
Cc: Kui-Feng Lee, bpf, ast, martin.lau, song, andrii, drosen, kuifeng,
thinker.li, Benjamin Tissoires, Jiri Kosina
On Fri, Jul 26, 2024 at 11:21 AM Yonghong Song <yonghong.song@linux.dev> wrote:
>
>
> On 7/24/24 2:13 AM, Ming Lei wrote:
> > On Tue, Jul 23, 2024 at 09:43:12PM -0700, Kui-Feng Lee wrote:
> >>
> >> On 7/23/24 20:19, Ming Lei wrote:
> >>> Export btf_find_by_name_kind and bpf_base_func_proto, so that kernel
> >>> module can use them.
> >>>
> >>> Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
> >>>
> >>> Without this change, hid-bpf can't be built as module.
> >> Could you give me more context?
> >> Give me a link of an example code or something?
> >> Or explain the use case?
> > The merged patchset "Registrating struct_ops types from modules" is
> > trying to allow module to register struct_ops, which often needs
> > bpf_base_func_proto()(for allowing generic helpers available in
> > prog) and btf_find_by_name_kind() (for implementing .btf_struct_access).
> >
> > One example is hid-bpf, which is a driver and supposed to build as module,
> > but it can't be done because the two APIs aren't exported.
>
> Could you give more specific examples about where these two APIs are
> used in hid-bpf?
Sure, hid-bpf struct_ops has been merged to linus tree already.
However, it can't be built as module because the two APIs aren't exported:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/bpf/hid_bpf_struct_ops.c
Thanks,
Ming
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] bpf: export btf_find_by_name_kind and bpf_base_func_proto
2024-07-26 3:45 ` Ming Lei
@ 2024-07-26 5:39 ` Yonghong Song
2024-07-26 11:52 ` Ming Lei
0 siblings, 1 reply; 7+ messages in thread
From: Yonghong Song @ 2024-07-26 5:39 UTC (permalink / raw)
To: Ming Lei
Cc: Kui-Feng Lee, bpf, ast, martin.lau, song, andrii, drosen, kuifeng,
thinker.li, Benjamin Tissoires, Jiri Kosina
On 7/25/24 8:45 PM, Ming Lei wrote:
> On Fri, Jul 26, 2024 at 11:21 AM Yonghong Song <yonghong.song@linux.dev> wrote:
>>
>> On 7/24/24 2:13 AM, Ming Lei wrote:
>>> On Tue, Jul 23, 2024 at 09:43:12PM -0700, Kui-Feng Lee wrote:
>>>> On 7/23/24 20:19, Ming Lei wrote:
>>>>> Export btf_find_by_name_kind and bpf_base_func_proto, so that kernel
>>>>> module can use them.
>>>>>
>>>>> Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
>>>>>
>>>>> Without this change, hid-bpf can't be built as module.
>>>> Could you give me more context?
>>>> Give me a link of an example code or something?
>>>> Or explain the use case?
>>> The merged patchset "Registrating struct_ops types from modules" is
>>> trying to allow module to register struct_ops, which often needs
>>> bpf_base_func_proto()(for allowing generic helpers available in
>>> prog) and btf_find_by_name_kind() (for implementing .btf_struct_access).
>>>
>>> One example is hid-bpf, which is a driver and supposed to build as module,
>>> but it can't be done because the two APIs aren't exported.
>> Could you give more specific examples about where these two APIs are
>> used in hid-bpf?
> Sure, hid-bpf struct_ops has been merged to linus tree already.
>
> However, it can't be built as module because the two APIs aren't exported:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/bpf/hid_bpf_struct_ops.c
Okay, From the above hid_bpf_struct_ops.c, I do see bpf_base_func_proto() and
btf_find_by_name_kind() are used.
Your change looks good to me. Please add more details in the commit message and resubmit.
Your subject
[PATCH] bpf: export btf_find_by_name_kind and bpf_base_func_proto
please change to
[PATCH bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto
The above 'bpf-next' ensures CI to test your patch.
>
> Thanks,
> Ming
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] bpf: export btf_find_by_name_kind and bpf_base_func_proto
2024-07-26 5:39 ` Yonghong Song
@ 2024-07-26 11:52 ` Ming Lei
0 siblings, 0 replies; 7+ messages in thread
From: Ming Lei @ 2024-07-26 11:52 UTC (permalink / raw)
To: Yonghong Song
Cc: Kui-Feng Lee, bpf, ast, martin.lau, song, andrii, drosen, kuifeng,
thinker.li, Benjamin Tissoires, Jiri Kosina
On Fri, Jul 26, 2024 at 1:40 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>
>
> On 7/25/24 8:45 PM, Ming Lei wrote:
> > On Fri, Jul 26, 2024 at 11:21 AM Yonghong Song <yonghong.song@linux.dev> wrote:
> >>
> >> On 7/24/24 2:13 AM, Ming Lei wrote:
> >>> On Tue, Jul 23, 2024 at 09:43:12PM -0700, Kui-Feng Lee wrote:
> >>>> On 7/23/24 20:19, Ming Lei wrote:
> >>>>> Export btf_find_by_name_kind and bpf_base_func_proto, so that kernel
> >>>>> module can use them.
> >>>>>
> >>>>> Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
> >>>>>
> >>>>> Without this change, hid-bpf can't be built as module.
> >>>> Could you give me more context?
> >>>> Give me a link of an example code or something?
> >>>> Or explain the use case?
> >>> The merged patchset "Registrating struct_ops types from modules" is
> >>> trying to allow module to register struct_ops, which often needs
> >>> bpf_base_func_proto()(for allowing generic helpers available in
> >>> prog) and btf_find_by_name_kind() (for implementing .btf_struct_access).
> >>>
> >>> One example is hid-bpf, which is a driver and supposed to build as module,
> >>> but it can't be done because the two APIs aren't exported.
> >> Could you give more specific examples about where these two APIs are
> >> used in hid-bpf?
> > Sure, hid-bpf struct_ops has been merged to linus tree already.
> >
> > However, it can't be built as module because the two APIs aren't exported:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/bpf/hid_bpf_struct_ops.c
>
> Okay, From the above hid_bpf_struct_ops.c, I do see bpf_base_func_proto() and
> btf_find_by_name_kind() are used.
>
> Your change looks good to me. Please add more details in the commit message and resubmit.
> Your subject
> [PATCH] bpf: export btf_find_by_name_kind and bpf_base_func_proto
> please change to
> [PATCH bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto
>
> The above 'bpf-next' ensures CI to test your patch.
OK, I will follow the above and post v2, and thanks for the review!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-07-26 11:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-24 3:19 [PATCH] bpf: export btf_find_by_name_kind and bpf_base_func_proto Ming Lei
2024-07-24 4:43 ` Kui-Feng Lee
2024-07-24 9:13 ` Ming Lei
2024-07-26 3:20 ` Yonghong Song
2024-07-26 3:45 ` Ming Lei
2024-07-26 5:39 ` Yonghong Song
2024-07-26 11:52 ` Ming Lei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox