Skip to content

Commit fdaedba

Browse files
committed
sched_ext: Rename scx_kfunc_set_sleepable to unlocked and relocate
Sleepables don't need to be in its own kfunc set as each is tagged with KF_SLEEPABLE. Rename to scx_kfunc_set_unlocked indicating that rq lock is not held and relocate right above the any set. This will be used to add kfuncs that are allowed to be called from SYSCALL but not TRACING. No functional changes intended. Signed-off-by: Tejun Heo <[email protected]> Acked-by: David Vernet <[email protected]>
1 parent 3ac3527 commit fdaedba

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

kernel/sched/ext.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5802,35 +5802,6 @@ void __init init_sched_ext_class(void)
58025802

58035803
__bpf_kfunc_start_defs();
58045804

5805-
/**
5806-
* scx_bpf_create_dsq - Create a custom DSQ
5807-
* @dsq_id: DSQ to create
5808-
* @node: NUMA node to allocate from
5809-
*
5810-
* Create a custom DSQ identified by @dsq_id. Can be called from any sleepable
5811-
* scx callback, and any BPF_PROG_TYPE_SYSCALL prog.
5812-
*/
5813-
__bpf_kfunc s32 scx_bpf_create_dsq(u64 dsq_id, s32 node)
5814-
{
5815-
if (unlikely(node >= (int)nr_node_ids ||
5816-
(node < 0 && node != NUMA_NO_NODE)))
5817-
return -EINVAL;
5818-
return PTR_ERR_OR_ZERO(create_dsq(dsq_id, node));
5819-
}
5820-
5821-
__bpf_kfunc_end_defs();
5822-
5823-
BTF_KFUNCS_START(scx_kfunc_ids_sleepable)
5824-
BTF_ID_FLAGS(func, scx_bpf_create_dsq, KF_SLEEPABLE)
5825-
BTF_KFUNCS_END(scx_kfunc_ids_sleepable)
5826-
5827-
static const struct btf_kfunc_id_set scx_kfunc_set_sleepable = {
5828-
.owner = THIS_MODULE,
5829-
.set = &scx_kfunc_ids_sleepable,
5830-
};
5831-
5832-
__bpf_kfunc_start_defs();
5833-
58345805
/**
58355806
* scx_bpf_select_cpu_dfl - The default implementation of ops.select_cpu()
58365807
* @p: task_struct to select a CPU for
@@ -6173,6 +6144,35 @@ static const struct btf_kfunc_id_set scx_kfunc_set_cpu_release = {
61736144

61746145
__bpf_kfunc_start_defs();
61756146

6147+
/**
6148+
* scx_bpf_create_dsq - Create a custom DSQ
6149+
* @dsq_id: DSQ to create
6150+
* @node: NUMA node to allocate from
6151+
*
6152+
* Create a custom DSQ identified by @dsq_id. Can be called from any sleepable
6153+
* scx callback, and any BPF_PROG_TYPE_SYSCALL prog.
6154+
*/
6155+
__bpf_kfunc s32 scx_bpf_create_dsq(u64 dsq_id, s32 node)
6156+
{
6157+
if (unlikely(node >= (int)nr_node_ids ||
6158+
(node < 0 && node != NUMA_NO_NODE)))
6159+
return -EINVAL;
6160+
return PTR_ERR_OR_ZERO(create_dsq(dsq_id, node));
6161+
}
6162+
6163+
__bpf_kfunc_end_defs();
6164+
6165+
BTF_KFUNCS_START(scx_kfunc_ids_unlocked)
6166+
BTF_ID_FLAGS(func, scx_bpf_create_dsq, KF_SLEEPABLE)
6167+
BTF_KFUNCS_END(scx_kfunc_ids_unlocked)
6168+
6169+
static const struct btf_kfunc_id_set scx_kfunc_set_unlocked = {
6170+
.owner = THIS_MODULE,
6171+
.set = &scx_kfunc_ids_unlocked,
6172+
};
6173+
6174+
__bpf_kfunc_start_defs();
6175+
61766176
/**
61776177
* scx_bpf_kick_cpu - Trigger reschedule on a CPU
61786178
* @cpu: cpu to kick
@@ -6907,17 +6907,17 @@ static int __init scx_init(void)
69076907
* check using scx_kf_allowed().
69086908
*/
69096909
if ((ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
6910-
&scx_kfunc_set_sleepable)) ||
6911-
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL,
6912-
&scx_kfunc_set_sleepable)) ||
6913-
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
69146910
&scx_kfunc_set_select_cpu)) ||
69156911
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
69166912
&scx_kfunc_set_enqueue_dispatch)) ||
69176913
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
69186914
&scx_kfunc_set_dispatch)) ||
69196915
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
69206916
&scx_kfunc_set_cpu_release)) ||
6917+
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
6918+
&scx_kfunc_set_unlocked)) ||
6919+
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL,
6920+
&scx_kfunc_set_unlocked)) ||
69216921
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
69226922
&scx_kfunc_set_any)) ||
69236923
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING,

0 commit comments

Comments
 (0)