Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Add proper support for auto-detach in sched_ext #14

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions kernel/sched/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -3555,6 +3555,23 @@ static int bpf_scx_init(struct btf *btf)
return 0;
}

static int bpf_scx_update(void *kdata, void *old_kdata)
{
/*
* sched_ext does not support updating the actively-loaded BPF
* scheduler, as registering a BPF scheduler can always fail if the
* scheduler returns an error code for e.g. ops.init(),
* ops.prep_enable(), etc. Similarly, we can always race with
* unregistration happening elsewhere, such as with sysrq.
*/
return -EOPNOTSUPP;
}

static int bpf_scx_validate(void *kdata)
{
return 0;
}

/* "extern" to avoid sparse warning, only used in this file */
extern struct bpf_struct_ops bpf_sched_ext_ops;

Expand All @@ -3565,6 +3582,8 @@ struct bpf_struct_ops bpf_sched_ext_ops = {
.check_member = bpf_scx_check_member,
.init_member = bpf_scx_init_member,
.init = bpf_scx_init,
.update = bpf_scx_update,
.validate = bpf_scx_validate,
.name = "sched_ext_ops",
};

Expand Down
2 changes: 1 addition & 1 deletion tools/sched_ext/atropos/src/bpf/atropos.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ void BPF_STRUCT_OPS(atropos_exit, struct scx_exit_info *ei)
exit_type = ei->type;
}

SEC(".struct_ops")
SEC(".struct_ops.link")
struct sched_ext_ops atropos = {
.select_cpu = (void *)atropos_select_cpu,
.enqueue = (void *)atropos_enqueue,
Expand Down
2 changes: 1 addition & 1 deletion tools/sched_ext/scx_example_central.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void BPF_STRUCT_OPS(central_exit, struct scx_exit_info *ei)
uei_record(&uei, ei);
}

SEC(".struct_ops")
SEC(".struct_ops.link")
struct sched_ext_ops central_ops = {
/*
* We are offloading all scheduling decisions to the central CPU and
Expand Down
2 changes: 1 addition & 1 deletion tools/sched_ext/scx_example_flatcg.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ void BPF_STRUCT_OPS(fcg_exit, struct scx_exit_info *ei)
uei_record(&uei, ei);
}

SEC(".struct_ops")
SEC(".struct_ops.link")
struct sched_ext_ops flatcg_ops = {
.enqueue = (void *)fcg_enqueue,
.dispatch = (void *)fcg_dispatch,
Expand Down
2 changes: 1 addition & 1 deletion tools/sched_ext/scx_example_pair.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ void BPF_STRUCT_OPS(pair_exit, struct scx_exit_info *ei)
uei_record(&uei, ei);
}

SEC(".struct_ops")
SEC(".struct_ops.link")
struct sched_ext_ops pair_ops = {
.enqueue = (void *)pair_enqueue,
.dispatch = (void *)pair_dispatch,
Expand Down
2 changes: 1 addition & 1 deletion tools/sched_ext/scx_example_qmap.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void BPF_STRUCT_OPS(qmap_exit, struct scx_exit_info *ei)
uei_record(&uei, ei);
}

SEC(".struct_ops")
SEC(".struct_ops.link")
struct sched_ext_ops qmap_ops = {
.select_cpu = (void *)qmap_select_cpu,
.enqueue = (void *)qmap_enqueue,
Expand Down
2 changes: 1 addition & 1 deletion tools/sched_ext/scx_example_simple.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void BPF_STRUCT_OPS(simple_exit, struct scx_exit_info *ei)
uei_record(&uei, ei);
}

SEC(".struct_ops")
SEC(".struct_ops.link")
struct sched_ext_ops simple_ops = {
.enqueue = (void *)simple_enqueue,
.running = (void *)simple_running,
Expand Down
2 changes: 1 addition & 1 deletion tools/sched_ext/scx_example_userland.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void BPF_STRUCT_OPS(userland_exit, struct scx_exit_info *ei)
uei_record(&uei, ei);
}

SEC(".struct_ops")
SEC(".struct_ops.link")
struct sched_ext_ops userland_ops = {
.select_cpu = (void *)userland_select_cpu,
.enqueue = (void *)userland_enqueue,
Expand Down