bpf: export btf_find_by_name_kind and bpf_base_func_proto
PATCH 1/1 bpf: export btf_find_by_name_kind and bpf_base_func_proto
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.
--- 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.45.2
Quoted 6 lines · Ming Lei
Export
btf_find_by_name_kindandbpf_base_func_proto, so that kernel module can use them.Almost all existed
struct_opsusers(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!
Quoted 33 lines
Cc Benjamin Tissoires <[email protected]>Cc Jiri Kosina <[email protected]>Signed-off-by Ming Lei <[email protected]>--- 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)
Quoted 6 lines · Kui-Feng Lee
Quoted 3 lines · Ming Lei
Export
btf_find_by_name_kindandbpf_base_func_proto, so that kernel module can use them.
Quoted 7 lines
Quoted 3 lines
Almost all existed
struct_opsusers(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
Yonghong Song
reviewerQuoted 12 lines · Ming Lei
Quoted 11 lines · Kui-Feng Lee
Quoted 6 lines · Ming Lei
Export
btf_find_by_name_kindandbpf_base_func_proto, so that kernel module can use them.Almost all existed
struct_opsusers(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?
Quoted 7 lines
The merged patchset "Registrating
struct_opstypes from modules" is trying to allow module to registerstruct_ops, which often needs bpf_base_func_proto()(for allowing generic helpers available in prog) andbtf_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?
Quoted 9 lines
I am working on ublk bpf support, which needs
bpf_base_func_proto()at least, and might requirebtf_find_by_name_kind()in future.Thanks,
Ming
Quoted 20 lines · Yonghong Song
Quoted 17 lines · Ming Lei
Quoted 11 lines · Kui-Feng Lee
Quoted 6 lines · Ming Lei
Export
btf_find_by_name_kindandbpf_base_func_proto, so that kernel module can use them.Almost all existed
struct_opsusers(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_opstypes from modules" is trying to allow module to registerstruct_ops, which often needs bpf_base_func_proto()(for allowing generic helpers available in prog) andbtf_find_by_name_kind()(for implementing .btf_struct_access).
Quoted 5 lines
Quoted 2 lines
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:
Thanks,
Ming
Yonghong Song
reviewerQuoted 21 lines · Ming Lei
Quoted 20 lines · Yonghong Song
Quoted 18 lines · Ming Lei
Quoted 10 lines · Kui-Feng Lee
Quoted 6 lines · Ming Lei
Export
btf_find_by_name_kindandbpf_base_func_proto, so that kernel module can use them.Almost all existed
struct_opsusers(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_opstypes from modules" is trying to allow module to registerstruct_ops, which often needs bpf_base_func_proto()(for allowing generic helpers available in prog) andbtf_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.
Quoted 7 lines
Quoted 2 lines
Could you give more specific examples about where these two APIs are used in hid-bpf?
Sure, hid-bpf
struct_opshas been merged to linus tree already.However, it can't be built as module because the two APIs aren't exported:
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.
Quoted 4 lines
Thanks,
Ming
Quoted 35 lines · Yonghong Song
Quoted 21 lines · Ming Lei
Quoted 20 lines · Yonghong Song
Quoted 18 lines · Ming Lei
Quoted 10 lines · Kui-Feng Lee
Quoted 6 lines · Ming Lei
Export
btf_find_by_name_kindandbpf_base_func_proto, so that kernel module can use them.Almost all existed
struct_opsusers(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_opstypes from modules" is trying to allow module to registerstruct_ops, which often needs bpf_base_func_proto()(for allowing generic helpers available in prog) andbtf_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.
Quoted 7 lines
Quoted 2 lines
Could you give more specific examples about where these two APIs are used in hid-bpf?
Sure, hid-bpf
struct_opshas been merged to linus tree already.However, it can't be built as module because the two APIs aren't exported:
Okay, From the above
hid_bpf_struct_ops.c, I do seebpf_base_func_proto()andbtf_find_by_name_kind()are used.
Quoted 7 lines
Your change looks good to me. Please add more details in the commit message and resubmit. Your subject
[PATCH] bpf: exportbtf_find_by_name_kindandbpf_base_func_proto
please change to
[PATCH bpf-next] bpf: exportbtf_find_by_name_kindandbpf_base_func_protoThe above 'bpf-next' ensures CI to test your patch.
OK, I will follow the above and post v2, and thanks for the review!