Skip to content

Commit 8a56f32

Browse files
authored
Merge pull request raspberrypi#14 from sched-ext/auto_detach
Add proper support for auto-detach in sched_ext
2 parents 7130c7d + 37316dd commit 8a56f32

8 files changed

+26
-7
lines changed

kernel/sched/ext.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3555,6 +3555,23 @@ static int bpf_scx_init(struct btf *btf)
35553555
return 0;
35563556
}
35573557

3558+
static int bpf_scx_update(void *kdata, void *old_kdata)
3559+
{
3560+
/*
3561+
* sched_ext does not support updating the actively-loaded BPF
3562+
* scheduler, as registering a BPF scheduler can always fail if the
3563+
* scheduler returns an error code for e.g. ops.init(),
3564+
* ops.prep_enable(), etc. Similarly, we can always race with
3565+
* unregistration happening elsewhere, such as with sysrq.
3566+
*/
3567+
return -EOPNOTSUPP;
3568+
}
3569+
3570+
static int bpf_scx_validate(void *kdata)
3571+
{
3572+
return 0;
3573+
}
3574+
35583575
/* "extern" to avoid sparse warning, only used in this file */
35593576
extern struct bpf_struct_ops bpf_sched_ext_ops;
35603577

@@ -3565,6 +3582,8 @@ struct bpf_struct_ops bpf_sched_ext_ops = {
35653582
.check_member = bpf_scx_check_member,
35663583
.init_member = bpf_scx_init_member,
35673584
.init = bpf_scx_init,
3585+
.update = bpf_scx_update,
3586+
.validate = bpf_scx_validate,
35683587
.name = "sched_ext_ops",
35693588
};
35703589

tools/sched_ext/atropos/src/bpf/atropos.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ void BPF_STRUCT_OPS(atropos_exit, struct scx_exit_info *ei)
723723
exit_type = ei->type;
724724
}
725725

726-
SEC(".struct_ops")
726+
SEC(".struct_ops.link")
727727
struct sched_ext_ops atropos = {
728728
.select_cpu = (void *)atropos_select_cpu,
729729
.enqueue = (void *)atropos_enqueue,

tools/sched_ext/scx_example_central.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void BPF_STRUCT_OPS(central_exit, struct scx_exit_info *ei)
314314
uei_record(&uei, ei);
315315
}
316316

317-
SEC(".struct_ops")
317+
SEC(".struct_ops.link")
318318
struct sched_ext_ops central_ops = {
319319
/*
320320
* We are offloading all scheduling decisions to the central CPU and

tools/sched_ext/scx_example_flatcg.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ void BPF_STRUCT_OPS(fcg_exit, struct scx_exit_info *ei)
853853
uei_record(&uei, ei);
854854
}
855855

856-
SEC(".struct_ops")
856+
SEC(".struct_ops.link")
857857
struct sched_ext_ops flatcg_ops = {
858858
.enqueue = (void *)fcg_enqueue,
859859
.dispatch = (void *)fcg_dispatch,

tools/sched_ext/scx_example_pair.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ void BPF_STRUCT_OPS(pair_exit, struct scx_exit_info *ei)
613613
uei_record(&uei, ei);
614614
}
615615

616-
SEC(".struct_ops")
616+
SEC(".struct_ops.link")
617617
struct sched_ext_ops pair_ops = {
618618
.enqueue = (void *)pair_enqueue,
619619
.dispatch = (void *)pair_dispatch,

tools/sched_ext/scx_example_qmap.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ void BPF_STRUCT_OPS(qmap_exit, struct scx_exit_info *ei)
384384
uei_record(&uei, ei);
385385
}
386386

387-
SEC(".struct_ops")
387+
SEC(".struct_ops.link")
388388
struct sched_ext_ops qmap_ops = {
389389
.select_cpu = (void *)qmap_select_cpu,
390390
.enqueue = (void *)qmap_enqueue,

tools/sched_ext/scx_example_simple.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void BPF_STRUCT_OPS(simple_exit, struct scx_exit_info *ei)
117117
uei_record(&uei, ei);
118118
}
119119

120-
SEC(".struct_ops")
120+
SEC(".struct_ops.link")
121121
struct sched_ext_ops simple_ops = {
122122
.enqueue = (void *)simple_enqueue,
123123
.running = (void *)simple_running,

tools/sched_ext/scx_example_userland.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void BPF_STRUCT_OPS(userland_exit, struct scx_exit_info *ei)
249249
uei_record(&uei, ei);
250250
}
251251

252-
SEC(".struct_ops")
252+
SEC(".struct_ops.link")
253253
struct sched_ext_ops userland_ops = {
254254
.select_cpu = (void *)userland_select_cpu,
255255
.enqueue = (void *)userland_enqueue,

0 commit comments

Comments
 (0)