On 2025/2/26 14:46, Andrea Righi wrote:
On Tue, Feb 25, 2025 at 09:24:27PM -0800, Alexei Starovoitov wrote:
On Fri, Feb 14, 2025 at 12:13 PM Juntong Deng <juntong.deng@xxxxxxxxxxx> wrote:
+static int scx_kfunc_ids_ops_context_filter(const struct bpf_prog *prog, u32 kfunc_id)
+{
+ u32 moff, flags;
+
+ if (!btf_id_set8_contains(&scx_kfunc_ids_ops_context, kfunc_id))
+ return 0;
+
+ if (prog->type == BPF_PROG_TYPE_SYSCALL &&
+ btf_id_set8_contains(&scx_kfunc_ids_unlocked, kfunc_id))
+ return 0;
+
+ if (prog->type == BPF_PROG_TYPE_STRUCT_OPS &&
+ prog->aux->st_ops != &bpf_sched_ext_ops)
+ return 0;
+
+ /* prog->type == BPF_PROG_TYPE_STRUCT_OPS && prog->aux->st_ops == &bpf_sched_ext_ops*/
+
+ moff = prog->aux->attach_st_ops_member_off;
+ flags = scx_ops_context_flags[SCX_MOFF_IDX(moff)];
+
+ if ((flags & SCX_OPS_KF_UNLOCKED) &&
+ btf_id_set8_contains(&scx_kfunc_ids_unlocked, kfunc_id))
+ return 0;
+
+ if ((flags & SCX_OPS_KF_CPU_RELEASE) &&
+ btf_id_set8_contains(&scx_kfunc_ids_cpu_release, kfunc_id))
+ return 0;
+
+ if ((flags & SCX_OPS_KF_DISPATCH) &&
+ btf_id_set8_contains(&scx_kfunc_ids_dispatch, kfunc_id))
+ return 0;
+
+ if ((flags & SCX_OPS_KF_ENQUEUE) &&
+ btf_id_set8_contains(&scx_kfunc_ids_enqueue_dispatch, kfunc_id))
+ return 0;
+
+ if ((flags & SCX_OPS_KF_SELECT_CPU) &&
+ btf_id_set8_contains(&scx_kfunc_ids_select_cpu, kfunc_id))
+ return 0;
+
+ return -EACCES;
+}
This looks great.
Very good cleanup and run-time speed up.
Please resend without RFC tag, so sched-ext folks can review.
From bpf pov, pls add my Ack to patch 1 when you respin.
The set can probably target sched-ext tree too.
Thanks for this work Juntong! I'll do a more detailed review later (with
this one or the next patch set without the RFC).
Just a heads up, if you decide to target the sched-ext tree, you may want
to consider sched_ext/for-6.15, since we moved some code around (no big
changes, but some functions are now in ext_idle.c):
https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git/log/?h=for-6.15
Thanks!
-Andrea
Thanks for telling me this information.
I have sent the version 3 patch series [0], targeting
sched_ext/for-6.15.
[0]:
https://lore.kernel.org/bpf/AM6PR03MB50806070E3D56208DDB8131699C22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/T/#u