On Thu, Feb 27, 2025 at 1:32 PM Tejun Heo <tj@xxxxxxxxxx> wrote: > > Hello, > > On Thu, Feb 27, 2025 at 09:23:20PM +0000, Juntong Deng wrote: > > > > + if (prog->type == BPF_PROG_TYPE_STRUCT_OPS && > > > > + prog->aux->st_ops != &bpf_sched_ext_ops) > > > > + return 0; > > > > > > Why can't other struct_ops progs call scx_kfunc_ids_unlocked kfuncs? > > > > > > > Return 0 means allowed. So kfuncs in scx_kfunc_ids_unlocked can be > > called by other struct_ops programs. > > Hmm... would that mean a non-sched_ext bpf prog would be able to call e.g. > scx_bpf_dsq_insert()? Not as far as I can tell. scx_kfunc_ids_unlocked[] doesn't include scx_bpf_dsq_insert. It's part of scx_kfunc_ids_enqueue_dispatch[]. So this bit in patch 3 enables it: + if ((flags & SCX_OPS_KF_ENQUEUE) && + btf_id_set8_contains(&scx_kfunc_ids_enqueue_dispatch, kfunc_id)) and in patch 2: + [SCX_OP_IDX(enqueue)] = SCX_OPS_KF_ENQUEUE, So scx_bpf_dsq_insert() kfunc can only be called out of enqueue() sched-ext hook. So the restriction is still the same. afaict.