Commit fdaedba2 authored by Tejun Heo's avatar Tejun Heo

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: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarDavid Vernet <void@manifault.com>
parent 3ac35279
...@@ -5802,35 +5802,6 @@ void __init init_sched_ext_class(void) ...@@ -5802,35 +5802,6 @@ void __init init_sched_ext_class(void)
__bpf_kfunc_start_defs(); __bpf_kfunc_start_defs();
/**
* scx_bpf_create_dsq - Create a custom DSQ
* @dsq_id: DSQ to create
* @node: NUMA node to allocate from
*
* Create a custom DSQ identified by @dsq_id. Can be called from any sleepable
* scx callback, and any BPF_PROG_TYPE_SYSCALL prog.
*/
__bpf_kfunc s32 scx_bpf_create_dsq(u64 dsq_id, s32 node)
{
if (unlikely(node >= (int)nr_node_ids ||
(node < 0 && node != NUMA_NO_NODE)))
return -EINVAL;
return PTR_ERR_OR_ZERO(create_dsq(dsq_id, node));
}
__bpf_kfunc_end_defs();
BTF_KFUNCS_START(scx_kfunc_ids_sleepable)
BTF_ID_FLAGS(func, scx_bpf_create_dsq, KF_SLEEPABLE)
BTF_KFUNCS_END(scx_kfunc_ids_sleepable)
static const struct btf_kfunc_id_set scx_kfunc_set_sleepable = {
.owner = THIS_MODULE,
.set = &scx_kfunc_ids_sleepable,
};
__bpf_kfunc_start_defs();
/** /**
* scx_bpf_select_cpu_dfl - The default implementation of ops.select_cpu() * scx_bpf_select_cpu_dfl - The default implementation of ops.select_cpu()
* @p: task_struct to select a CPU for * @p: task_struct to select a CPU for
...@@ -6173,6 +6144,35 @@ static const struct btf_kfunc_id_set scx_kfunc_set_cpu_release = { ...@@ -6173,6 +6144,35 @@ static const struct btf_kfunc_id_set scx_kfunc_set_cpu_release = {
__bpf_kfunc_start_defs(); __bpf_kfunc_start_defs();
/**
* scx_bpf_create_dsq - Create a custom DSQ
* @dsq_id: DSQ to create
* @node: NUMA node to allocate from
*
* Create a custom DSQ identified by @dsq_id. Can be called from any sleepable
* scx callback, and any BPF_PROG_TYPE_SYSCALL prog.
*/
__bpf_kfunc s32 scx_bpf_create_dsq(u64 dsq_id, s32 node)
{
if (unlikely(node >= (int)nr_node_ids ||
(node < 0 && node != NUMA_NO_NODE)))
return -EINVAL;
return PTR_ERR_OR_ZERO(create_dsq(dsq_id, node));
}
__bpf_kfunc_end_defs();
BTF_KFUNCS_START(scx_kfunc_ids_unlocked)
BTF_ID_FLAGS(func, scx_bpf_create_dsq, KF_SLEEPABLE)
BTF_KFUNCS_END(scx_kfunc_ids_unlocked)
static const struct btf_kfunc_id_set scx_kfunc_set_unlocked = {
.owner = THIS_MODULE,
.set = &scx_kfunc_ids_unlocked,
};
__bpf_kfunc_start_defs();
/** /**
* scx_bpf_kick_cpu - Trigger reschedule on a CPU * scx_bpf_kick_cpu - Trigger reschedule on a CPU
* @cpu: cpu to kick * @cpu: cpu to kick
...@@ -6907,10 +6907,6 @@ static int __init scx_init(void) ...@@ -6907,10 +6907,6 @@ static int __init scx_init(void)
* check using scx_kf_allowed(). * check using scx_kf_allowed().
*/ */
if ((ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, if ((ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
&scx_kfunc_set_sleepable)) ||
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL,
&scx_kfunc_set_sleepable)) ||
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
&scx_kfunc_set_select_cpu)) || &scx_kfunc_set_select_cpu)) ||
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, (ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
&scx_kfunc_set_enqueue_dispatch)) || &scx_kfunc_set_enqueue_dispatch)) ||
...@@ -6918,6 +6914,10 @@ static int __init scx_init(void) ...@@ -6918,6 +6914,10 @@ static int __init scx_init(void)
&scx_kfunc_set_dispatch)) || &scx_kfunc_set_dispatch)) ||
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, (ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
&scx_kfunc_set_cpu_release)) || &scx_kfunc_set_cpu_release)) ||
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
&scx_kfunc_set_unlocked)) ||
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL,
&scx_kfunc_set_unlocked)) ||
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, (ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
&scx_kfunc_set_any)) || &scx_kfunc_set_any)) ||
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, (ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment