Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched_ext: Add select_cpu kfuncs to scx_kfunc_ids_unlocked

select_cpu_from_kfunc() has an extra scx_kf_allowed_if_unlocked() branch
that accepts calls from unlocked contexts and takes task_rq_lock() itself
- a "callable from unlocked" property encoded in the kfunc body rather
than in set membership. That's fine while the runtime check is the
authoritative gate, but the upcoming verifier-time filter uses set
membership as the source of truth and needs it to reflect every context
the kfunc may be called from.

Add the three select_cpu kfuncs to scx_kfunc_ids_unlocked so their full
set of callable contexts is captured by set membership. This follows the
existing dual-set convention used by scx_bpf_dsq_move{,_vtime} and
scx_bpf_dsq_move_set_{slice,vtime}, which are members of both
scx_kfunc_ids_dispatch and scx_kfunc_ids_unlocked.

While at it, add brief comments on each duplicate BTF_ID_FLAGS block
(including the pre-existing dsq_move ones) explaining the dual
membership.

No runtime behavior change: the runtime check in select_cpu_from_kfunc()
remains the authoritative gate until it is removed along with the rest
of the scx_kf_mask enforcement in a follow-up.

v2: Clarify dispatch-set comment to name scx_bpf_dsq_move*() explicitly so it
doesn't appear to cover scx_bpf_sub_dispatch() (Andrea Righi).

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>

Tejun Heo a37e1343 9b5501d3

+10
+6
kernel/sched/ext.c
··· 8497 8497 BTF_ID_FLAGS(func, scx_bpf_dispatch_cancel, KF_IMPLICIT_ARGS) 8498 8498 BTF_ID_FLAGS(func, scx_bpf_dsq_move_to_local, KF_IMPLICIT_ARGS) 8499 8499 BTF_ID_FLAGS(func, scx_bpf_dsq_move_to_local___v2, KF_IMPLICIT_ARGS) 8500 + /* scx_bpf_dsq_move*() also in scx_kfunc_ids_unlocked: callable from unlocked contexts */ 8500 8501 BTF_ID_FLAGS(func, scx_bpf_dsq_move_set_slice, KF_RCU) 8501 8502 BTF_ID_FLAGS(func, scx_bpf_dsq_move_set_vtime, KF_RCU) 8502 8503 BTF_ID_FLAGS(func, scx_bpf_dsq_move, KF_RCU) ··· 8613 8612 8614 8613 BTF_KFUNCS_START(scx_kfunc_ids_unlocked) 8615 8614 BTF_ID_FLAGS(func, scx_bpf_create_dsq, KF_IMPLICIT_ARGS | KF_SLEEPABLE) 8615 + /* also in scx_kfunc_ids_dispatch: also callable from ops.dispatch() */ 8616 8616 BTF_ID_FLAGS(func, scx_bpf_dsq_move_set_slice, KF_RCU) 8617 8617 BTF_ID_FLAGS(func, scx_bpf_dsq_move_set_vtime, KF_RCU) 8618 8618 BTF_ID_FLAGS(func, scx_bpf_dsq_move, KF_RCU) 8619 8619 BTF_ID_FLAGS(func, scx_bpf_dsq_move_vtime, KF_RCU) 8620 + /* also in scx_kfunc_ids_select_cpu: also callable from ops.select_cpu()/ops.enqueue() */ 8621 + BTF_ID_FLAGS(func, __scx_bpf_select_cpu_and, KF_IMPLICIT_ARGS | KF_RCU) 8622 + BTF_ID_FLAGS(func, scx_bpf_select_cpu_and, KF_RCU) 8623 + BTF_ID_FLAGS(func, scx_bpf_select_cpu_dfl, KF_IMPLICIT_ARGS | KF_RCU) 8620 8624 BTF_KFUNCS_END(scx_kfunc_ids_unlocked) 8621 8625 8622 8626 static const struct btf_kfunc_id_set scx_kfunc_set_unlocked = {
+4
kernel/sched/ext_idle.c
··· 1482 1482 * contexts where @p's pi_lock state is unknown. Keep them out of 1483 1483 * BPF_PROG_TYPE_TRACING by registering them in their own set which is exposed 1484 1484 * only to STRUCT_OPS and SYSCALL programs. 1485 + * 1486 + * These kfuncs are also members of scx_kfunc_ids_unlocked (see ext.c) because 1487 + * they're callable from unlocked contexts in addition to ops.select_cpu() and 1488 + * ops.enqueue(). 1485 1489 */ 1486 1490 BTF_KFUNCS_START(scx_kfunc_ids_select_cpu) 1487 1491 BTF_ID_FLAGS(func, __scx_bpf_select_cpu_and, KF_IMPLICIT_ARGS | KF_RCU)