Skip to content

Commit 7cd9a5d

Browse files
EricccTaiwanhtejun
authored andcommitted
sched_ext: Remove runtime kfunc mask enforcement
Now that scx_kfunc_context_filter enforces context-sensitive kfunc restrictions at BPF load time, the per-task runtime enforcement via scx_kf_mask is redundant. Remove it entirely: - Delete enum scx_kf_mask, the kf_mask field on sched_ext_entity, and the scx_kf_allow()/scx_kf_disallow()/scx_kf_allowed() helpers along with the higher_bits()/highest_bit() helpers they used. - Strip the @Mask parameter (and the BUILD_BUG_ON checks) from the SCX_CALL_OP[_RET]/SCX_CALL_OP_TASK[_RET]/SCX_CALL_OP_2TASKS_RET macros and update every call site. Reflow call sites that were wrapped only to fit the old 5-arg form and now collapse onto a single line under ~100 cols. - Remove the in-kfunc scx_kf_allowed() runtime checks from scx_dsq_insert_preamble(), scx_dsq_move(), scx_bpf_dispatch_nr_slots(), scx_bpf_dispatch_cancel(), scx_bpf_dsq_move_to_local___v2(), scx_bpf_sub_dispatch(), scx_bpf_reenqueue_local(), and the per-call guard inside select_cpu_from_kfunc(). scx_bpf_task_cgroup() and scx_kf_allowed_on_arg_tasks() were already cleaned up in the "drop redundant rq-locked check" patch. scx_kf_allowed_if_unlocked() was rewritten in the preceding "decouple" patch. No further changes to those helpers here. Co-developed-by: Juntong Deng <juntong.deng@outlook.com> Signed-off-by: Juntong Deng <juntong.deng@outlook.com> Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Andrea Righi <arighi@nvidia.com>
1 parent d1d3c1c commit 7cd9a5d

3 files changed

Lines changed: 58 additions & 218 deletions

File tree

include/linux/sched/ext.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -147,33 +147,6 @@ enum scx_ent_dsq_flags {
147147
SCX_TASK_DSQ_ON_PRIQ = 1 << 0, /* task is queued on the priority queue of a dsq */
148148
};
149149

150-
/*
151-
* Mask bits for scx_entity.kf_mask. Not all kfuncs can be called from
152-
* everywhere and the following bits track which kfunc sets are currently
153-
* allowed for %current. This simple per-task tracking works because SCX ops
154-
* nest in a limited way. BPF will likely implement a way to allow and disallow
155-
* kfuncs depending on the calling context which will replace this manual
156-
* mechanism. See scx_kf_allow().
157-
*/
158-
enum scx_kf_mask {
159-
SCX_KF_UNLOCKED = 0, /* sleepable and not rq locked */
160-
/* ENQUEUE and DISPATCH may be nested inside CPU_RELEASE */
161-
SCX_KF_CPU_RELEASE = 1 << 0, /* ops.cpu_release() */
162-
/*
163-
* ops.dispatch() may release rq lock temporarily and thus ENQUEUE and
164-
* SELECT_CPU may be nested inside. ops.dequeue (in REST) may also be
165-
* nested inside DISPATCH.
166-
*/
167-
SCX_KF_DISPATCH = 1 << 1, /* ops.dispatch() */
168-
SCX_KF_ENQUEUE = 1 << 2, /* ops.enqueue() and ops.select_cpu() */
169-
SCX_KF_SELECT_CPU = 1 << 3, /* ops.select_cpu() */
170-
SCX_KF_REST = 1 << 4, /* other rq-locked operations */
171-
172-
__SCX_KF_RQ_LOCKED = SCX_KF_CPU_RELEASE | SCX_KF_DISPATCH |
173-
SCX_KF_ENQUEUE | SCX_KF_SELECT_CPU | SCX_KF_REST,
174-
__SCX_KF_TERMINAL = SCX_KF_ENQUEUE | SCX_KF_SELECT_CPU | SCX_KF_REST,
175-
};
176-
177150
enum scx_dsq_lnode_flags {
178151
SCX_DSQ_LNODE_ITER_CURSOR = 1 << 0,
179152

@@ -221,7 +194,6 @@ struct sched_ext_entity {
221194
s32 sticky_cpu;
222195
s32 holding_cpu;
223196
s32 selected_cpu;
224-
u32 kf_mask; /* see scx_kf_mask above */
225197
struct task_struct *kf_tasks[2]; /* see SCX_CALL_OP_TASK() */
226198

227199
struct list_head runnable_node; /* rq->scx.runnable_list */

0 commit comments

Comments
 (0)