* [PATCH] sched_ext: Fix the incorrect bpf_list kfunc API in common.bpf.h.
@ 2025-02-12 7:19 Chuyi Zhou
2025-02-12 7:30 ` Chuyi Zhou
2025-02-13 16:48 ` Tejun Heo
0 siblings, 2 replies; 3+ messages in thread
From: Chuyi Zhou @ 2025-02-12 7:19 UTC (permalink / raw)
To: tj, void, arighi, changwoo; +Cc: linux-kernel, Chuyi Zhou
Now BPF only supports bpf_list_push_{front,back}_impl kfunc, not bpf_list_
push_{front,back}.
This patch fix this issue. Without this patch, if we use bpf_list kfunc
in scx, the BPF verifier would complain:
libbpf: extern (func ksym) 'bpf_list_push_back': not found in kernel or
module BTFs
libbpf: failed to load object 'scx_foo'
libbpf: failed to load BPF skeleton 'scx_foo': -EINVAL
With this patch, the bpf list kfunc will work as expected.
Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
---
tools/sched_ext/include/scx/common.bpf.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/include/scx/common.bpf.h
index d72b60a0c582..7849405614b1 100644
--- a/tools/sched_ext/include/scx/common.bpf.h
+++ b/tools/sched_ext/include/scx/common.bpf.h
@@ -270,8 +270,16 @@ void bpf_obj_drop_impl(void *kptr, void *meta) __ksym;
#define bpf_obj_new(type) ((type *)bpf_obj_new_impl(bpf_core_type_id_local(type), NULL))
#define bpf_obj_drop(kptr) bpf_obj_drop_impl(kptr, NULL)
-void bpf_list_push_front(struct bpf_list_head *head, struct bpf_list_node *node) __ksym;
-void bpf_list_push_back(struct bpf_list_head *head, struct bpf_list_node *node) __ksym;
+int bpf_list_push_front_impl(struct bpf_list_head *head,
+ struct bpf_list_node *node,
+ void *meta, __u64 off) __ksym;
+#define bpf_list_push_front(head, node) bpf_list_push_front_impl(head, node, NULL, 0)
+
+int bpf_list_push_back_impl(struct bpf_list_head *head,
+ struct bpf_list_node *node,
+ void *meta, __u64 off) __ksym;
+#define bpf_list_push_back(head, node) bpf_list_push_back_impl(head, node, NULL, 0)
+
struct bpf_list_node *bpf_list_pop_front(struct bpf_list_head *head) __ksym;
struct bpf_list_node *bpf_list_pop_back(struct bpf_list_head *head) __ksym;
struct bpf_rb_node *bpf_rbtree_remove(struct bpf_rb_root *root,
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sched_ext: Fix the incorrect bpf_list kfunc API in common.bpf.h.
2025-02-12 7:19 [PATCH] sched_ext: Fix the incorrect bpf_list kfunc API in common.bpf.h Chuyi Zhou
@ 2025-02-12 7:30 ` Chuyi Zhou
2025-02-13 16:48 ` Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Chuyi Zhou @ 2025-02-12 7:30 UTC (permalink / raw)
To: tj, void, arighi, changwoo; +Cc: linux-kernel
在 2025/2/12 15:19, Chuyi Zhou 写道:
> Now BPF only supports bpf_list_push_{front,back}_impl kfunc, not bpf_list_
> push_{front,back}.
>
> This patch fix this issue. Without this patch, if we use bpf_list kfunc
> in scx, the BPF verifier would complain:
>
> libbpf: extern (func ksym) 'bpf_list_push_back': not found in kernel or
> module BTFs
> libbpf: failed to load object 'scx_foo'
> libbpf: failed to load BPF skeleton 'scx_foo': -EINVAL
>
> With this patch, the bpf list kfunc will work as expected.
>
Sorry, I missed the Fixes tag.
Fixes: 2a52ca7c98960 ("sched_ext: Add scx_simple and scx_example_qmap
example schedulers")
> Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
> ---
> tools/sched_ext/include/scx/common.bpf.h | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/include/scx/common.bpf.h
> index d72b60a0c582..7849405614b1 100644
> --- a/tools/sched_ext/include/scx/common.bpf.h
> +++ b/tools/sched_ext/include/scx/common.bpf.h
> @@ -270,8 +270,16 @@ void bpf_obj_drop_impl(void *kptr, void *meta) __ksym;
> #define bpf_obj_new(type) ((type *)bpf_obj_new_impl(bpf_core_type_id_local(type), NULL))
> #define bpf_obj_drop(kptr) bpf_obj_drop_impl(kptr, NULL)
>
> -void bpf_list_push_front(struct bpf_list_head *head, struct bpf_list_node *node) __ksym;
> -void bpf_list_push_back(struct bpf_list_head *head, struct bpf_list_node *node) __ksym;
> +int bpf_list_push_front_impl(struct bpf_list_head *head,
> + struct bpf_list_node *node,
> + void *meta, __u64 off) __ksym;
> +#define bpf_list_push_front(head, node) bpf_list_push_front_impl(head, node, NULL, 0)
> +
> +int bpf_list_push_back_impl(struct bpf_list_head *head,
> + struct bpf_list_node *node,
> + void *meta, __u64 off) __ksym;
> +#define bpf_list_push_back(head, node) bpf_list_push_back_impl(head, node, NULL, 0)
> +
> struct bpf_list_node *bpf_list_pop_front(struct bpf_list_head *head) __ksym;
> struct bpf_list_node *bpf_list_pop_back(struct bpf_list_head *head) __ksym;
> struct bpf_rb_node *bpf_rbtree_remove(struct bpf_rb_root *root,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sched_ext: Fix the incorrect bpf_list kfunc API in common.bpf.h.
2025-02-12 7:19 [PATCH] sched_ext: Fix the incorrect bpf_list kfunc API in common.bpf.h Chuyi Zhou
2025-02-12 7:30 ` Chuyi Zhou
@ 2025-02-13 16:48 ` Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2025-02-13 16:48 UTC (permalink / raw)
To: Chuyi Zhou; +Cc: void, arighi, changwoo, linux-kernel
On Wed, Feb 12, 2025 at 03:19:36PM +0800, Chuyi Zhou wrote:
> Now BPF only supports bpf_list_push_{front,back}_impl kfunc, not bpf_list_
> push_{front,back}.
>
> This patch fix this issue. Without this patch, if we use bpf_list kfunc
> in scx, the BPF verifier would complain:
>
> libbpf: extern (func ksym) 'bpf_list_push_back': not found in kernel or
> module BTFs
> libbpf: failed to load object 'scx_foo'
> libbpf: failed to load BPF skeleton 'scx_foo': -EINVAL
>
> With this patch, the bpf list kfunc will work as expected.
>
> Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
Applied to sched_ext/for-6.14-fixes.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-13 16:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-12 7:19 [PATCH] sched_ext: Fix the incorrect bpf_list kfunc API in common.bpf.h Chuyi Zhou
2025-02-12 7:30 ` Chuyi Zhou
2025-02-13 16:48 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®