bpf: export btf_find_by_name_kind and bpf_base_func_proto
PATCH v2 1/1 bpf: export btf_find_by_name_kind and bpf_base_func_proto
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.
---
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(+)
kernel/bpf/btf.c +1 -0
@@ -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) {
kernel/bpf/helpers.c +1 -0
@@ -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)
Signature · 1 line
2.42.0
Quoted 10 lines · Ming Lei
Almost all existed
struct_opsusers(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_kindandbpf_base_func_proto, so that any kernel module can use them given bpf community is supporting to registerstruct_opsin module, see the patchset "Registratingstruct_opstypes from modules"[1], which is merged to v6.9.
Quoted 4 lines
Cc Yonghong Song <[email protected]>Cc Benjamin Tissoires <[email protected]>Cc Jiri Kosina <[email protected]>Signed-off-by Ming Lei <[email protected]>
Quoted 40 lines · Ming Lei
Almost all existed
struct_opsusers(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_kindandbpf_base_func_proto, so that any kernel module can use them given bpf community is supporting to registerstruct_opsin module, see the patchset "Registratingstruct_opstypes from modules"[1], which is merged to v6.9.Cc Yonghong Song <[email protected]>Cc Benjamin Tissoires <[email protected]>Cc Jiri Kosina <[email protected]>Signed-off-by Ming Lei <[email protected]>---
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(+)kernel/bpf/btf.c +1
-0@@ -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) {kernel/bpf/helpers.c +0
-0
kernel/bpf/helpers.c bpf_base_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) · line 2039
Quoted 7 lines
kernel/bpf/helpers.c +1
-0@@ -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)
Martin KaFai Lau
reviewerQuoted 4 lines · Ming Lei
Almost all existed
struct_opsusers(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?
Quoted 5 lines
Export
btf_find_by_name_kindandbpf_base_func_proto, so that any kernel module can use them given bpf community is supporting to registerstruct_opsin module, see the patchset "Registratingstruct_opstypes from modules"[1], which is merged to v6.9.
Quoted 9 lines · Martin KaFai Lau
Quoted 4 lines · Ming Lei
Almost all existed
struct_opsusers(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
Martin KaFai Lau
reviewerQuoted 8 lines · Ming Lei
Quoted 7 lines · Martin KaFai Lau
Quoted 4 lines · Ming Lei
Almost all existed
struct_opsusers(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.
Quoted 8 lines
Quoted 2 lines
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_BPFyet, and it can be thought as onestruct_opsmodule prep patch.The issue itself is observed when I write ublk-bpf since ublk is one module and
struct_opsis 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.