* [PATCH V2 bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto
@ 2024-07-26 12:59 Ming Lei
2024-07-26 14:26 ` Yonghong Song
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Ming Lei @ 2024-07-26 12:59 UTC (permalink / raw)
To: bpf, ast, martin.lau, song, andrii, drosen, kuifeng
Cc: sinquersw, thinker.li, Ming Lei, Yonghong Song,
Benjamin Tissoires, Jiri Kosina
Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
In-tree hid-bpf code(drivers/hid/bpf/hid_bpf_struct_ops.c) can't be built
as module because the two APIs aren't exported.
Export btf_find_by_name_kind and bpf_base_func_proto, so that any kernel
module can use them given bpf community is supporting to register
struct_ops in module, see the patchset "Registrating struct_ops types from
modules"[1], which is merged to v6.9.
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: Benjamin Tissoires <bentiss@kernel.org>
Cc: Jiri Kosina <jikos@kernel.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
V2:
- add more details in commit log (Yonghong)
- add 'bpf-next' in patch title (Yonghong)
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 520f49f422fe..519c6e5a57d5 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.42.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH V2 bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto
2024-07-26 12:59 [PATCH V2 bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto Ming Lei
@ 2024-07-26 14:26 ` Yonghong Song
2024-07-26 16:06 ` Kui-Feng Lee
2024-07-29 21:07 ` Martin KaFai Lau
2 siblings, 0 replies; 6+ messages in thread
From: Yonghong Song @ 2024-07-26 14:26 UTC (permalink / raw)
To: Ming Lei, bpf, ast, martin.lau, song, andrii, drosen, kuifeng
Cc: sinquersw, thinker.li, Benjamin Tissoires, Jiri Kosina
On 7/26/24 5:59 AM, Ming Lei wrote:
> Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
>
> In-tree hid-bpf code(drivers/hid/bpf/hid_bpf_struct_ops.c) can't be built
> as module because the two APIs aren't exported.
>
> Export btf_find_by_name_kind and bpf_base_func_proto, so that any kernel
> module can use them given bpf community is supporting to register
> struct_ops in module, see the patchset "Registrating struct_ops types from
> modules"[1], which is merged to v6.9.
>
> Cc: Yonghong Song <yonghong.song@linux.dev>
> Cc: Benjamin Tissoires <bentiss@kernel.org>
> Cc: Jiri Kosina <jikos@kernel.org>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V2 bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto
2024-07-26 12:59 [PATCH V2 bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto Ming Lei
2024-07-26 14:26 ` Yonghong Song
@ 2024-07-26 16:06 ` Kui-Feng Lee
2024-07-29 21:07 ` Martin KaFai Lau
2 siblings, 0 replies; 6+ messages in thread
From: Kui-Feng Lee @ 2024-07-26 16:06 UTC (permalink / raw)
To: Ming Lei, bpf, ast, martin.lau, song, andrii, drosen, kuifeng
Cc: thinker.li, Yonghong Song, Benjamin Tissoires, Jiri Kosina
On 7/26/24 05:59, Ming Lei wrote:
> Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
>
> In-tree hid-bpf code(drivers/hid/bpf/hid_bpf_struct_ops.c) can't be built
> as module because the two APIs aren't exported.
>
> Export btf_find_by_name_kind and bpf_base_func_proto, so that any kernel
> module can use them given bpf community is supporting to register
> struct_ops in module, see the patchset "Registrating struct_ops types from
> modules"[1], which is merged to v6.9.
>
> Cc: Yonghong Song <yonghong.song@linux.dev>
> Cc: Benjamin Tissoires <bentiss@kernel.org>
> Cc: Jiri Kosina <jikos@kernel.org>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> V2:
> - add more details in commit log (Yonghong)
> - add 'bpf-next' in patch title (Yonghong)
>
> 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 520f49f422fe..519c6e5a57d5 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)
Acked-by: Kui-Feng Lee <thinker.li@gmail.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V2 bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto
2024-07-26 12:59 [PATCH V2 bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto Ming Lei
2024-07-26 14:26 ` Yonghong Song
2024-07-26 16:06 ` Kui-Feng Lee
@ 2024-07-29 21:07 ` Martin KaFai Lau
2024-07-31 8:18 ` Ming Lei
2 siblings, 1 reply; 6+ messages in thread
From: Martin KaFai Lau @ 2024-07-29 21:07 UTC (permalink / raw)
To: Ming Lei
Cc: bpf, ast, song, andrii, drosen, kuifeng, sinquersw, thinker.li,
Yonghong Song, Benjamin Tissoires, Jiri Kosina
On 7/26/24 5:59 AM, Ming Lei wrote:
> Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
>
> In-tree hid-bpf code(drivers/hid/bpf/hid_bpf_struct_ops.c) can't be built
> as module because the two APIs aren't exported.
The patch looks fine. I don't see "config HID_BPF" can be built as a module now
though that could expose this issue. Did I miss something?
>
> Export btf_find_by_name_kind and bpf_base_func_proto, so that any kernel
> module can use them given bpf community is supporting to register
> struct_ops in module, see the patchset "Registrating struct_ops types from
> modules"[1], which is merged to v6.9.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V2 bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto
2024-07-29 21:07 ` Martin KaFai Lau
@ 2024-07-31 8:18 ` Ming Lei
2024-08-01 0:34 ` Martin KaFai Lau
0 siblings, 1 reply; 6+ messages in thread
From: Ming Lei @ 2024-07-31 8:18 UTC (permalink / raw)
To: Martin KaFai Lau
Cc: bpf, ast, song, andrii, drosen, kuifeng, sinquersw, thinker.li,
Yonghong Song, Benjamin Tissoires, Jiri Kosina
On Tue, Jul 30, 2024 at 5:07 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>
> On 7/26/24 5:59 AM, Ming Lei wrote:
> > Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
> >
> > In-tree hid-bpf code(drivers/hid/bpf/hid_bpf_struct_ops.c) can't be built
> > as module because the two APIs aren't exported.
>
> The patch looks fine. I don't see "config HID_BPF" can be built as a module now
> though that could expose this issue. Did I miss something?
Yeah, this patch doesn't try to change HID_BPF yet, and it can be thought
as one struct_ops module prep patch.
The issue itself is observed when I write ublk-bpf since ublk is one module
and struct_ops is allowed to be registered in the module.
Thanks,
Ming
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V2 bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto
2024-07-31 8:18 ` Ming Lei
@ 2024-08-01 0:34 ` Martin KaFai Lau
0 siblings, 0 replies; 6+ messages in thread
From: Martin KaFai Lau @ 2024-08-01 0:34 UTC (permalink / raw)
To: Ming Lei
Cc: bpf, ast, song, andrii, drosen, kuifeng, sinquersw, thinker.li,
Yonghong Song, Benjamin Tissoires, Jiri Kosina
On 7/31/24 1:18 AM, Ming Lei wrote:
> On Tue, Jul 30, 2024 at 5:07 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>>
>> On 7/26/24 5:59 AM, Ming Lei wrote:
>>> Almost all existed struct_ops users(hid, sched_ext, ...) need the two APIs.
>>>
>>> In-tree hid-bpf code(drivers/hid/bpf/hid_bpf_struct_ops.c) can't be built
>>> as module because the two APIs aren't exported.
>>
>> The patch looks fine. I don't see "config HID_BPF" can be built as a module now
>> though that could expose this issue. Did I miss something?
>
> Yeah, this patch doesn't try to change HID_BPF yet, and it can be thought
> as one struct_ops module prep patch.
>
> The issue itself is observed when I write ublk-bpf since ublk is one module
> and struct_ops is allowed to be registered in the module.
Good to hear struct_ops find another potential use case. The ublk-bpf
development cannot continue without building as kmod?
Instead of exporting it now and pending without a user, I will wait till the
first in-tree kmod use case comes up first.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-08-01 0:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-26 12:59 [PATCH V2 bpf-next] bpf: export btf_find_by_name_kind and bpf_base_func_proto Ming Lei
2024-07-26 14:26 ` Yonghong Song
2024-07-26 16:06 ` Kui-Feng Lee
2024-07-29 21:07 ` Martin KaFai Lau
2024-07-31 8:18 ` Ming Lei
2024-08-01 0:34 ` Martin KaFai Lau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox