Skip to content

Commit d2a7a7b

Browse files
committed
Tiny sched-ext improvements
1 parent f29e75f commit d2a7a7b

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ limactl shell hello-ebpf
8989
sudo -s PATH=$PATH
9090
```
9191

92-
The scheduler examples require a patched 6.11 kernel with the scheduler extensions, you can get it from
92+
The scheduler examples require a 6.12+ kernel (install on ubuntu via the [mainline](https://github.com/bkw777/mainline) tool)
93+
or a patched 6.11 kernel with the scheduler extensions, you can get it from
9394
[here](https://launchpad.net/~arighi/+archive/ubuntu/sched-ext-unstable).
9495
You might also be able to run [CachyOS](https://cachyos.org/) and install a patched kernel from there.
9596

bpf/src/main/java/me/bechberger/ebpf/bpf/BPFJ.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ public static void bpf_probe_read_kernel_str(char[] dest, String source) {
125125
throw new MethodIsBPFRelatedFunction();
126126
}
127127

128+
/**
129+
* Read the source string from the kernel and write it to the destination
130+
* @see BPFHelpers#bpf_probe_read_kernel_str(Ptr, int, Ptr)
131+
*/
132+
@BuiltinBPFFunction("bpf_probe_read_kernel_str($arg1, sizeof($arg1), $arg2)")
133+
@NotUsableInJava
134+
public static void bpf_probe_read_kernel_str(String dest, char[] source) {
135+
throw new MethodIsBPFRelatedFunction();
136+
}
137+
128138
/**
129139
* Read the source string from the kernel and write it to the destination
130140
* @see BPFHelpers#bpf_probe_read_kernel_str(Ptr, int, Ptr)

bpf/src/main/java/me/bechberger/ebpf/bpf/Scheduler.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
.disable = (void *)simple_disable,
132132
.stopping = (void *)simple_stopping,
133133
.dequeue = (void *)simple_dequeue,
134-
.tick = (void *)sched_tick,
134+
.tick = (void *)simple_tick,
135135
.flags = SCX_OPS_ENQ_LAST | SCX_OPS_KEEP_BUILTIN_IDLE,
136136
.name = "__property_sched_name");
137137
"""
@@ -407,7 +407,7 @@ default void stopping(Ptr<TaskDefinitions.task_struct> p, boolean runnable) {
407407
* scheduling position not being updated across a priority change.
408408
*/
409409
@BPFFunction(
410-
headerTemplate = "void BPF_STRUCT_OPS(simple_dequeue, struct task_struct *p, u64 deq_flags)",
410+
headerTemplate = "int BPF_STRUCT_OPS(simple_dequeue, struct task_struct *p, u64 deq_flags)",
411411
addDefinition = false
412412
)
413413
default void dequeue(Ptr<TaskDefinitions.task_struct> p, @Unsigned long deq_flags) {
@@ -422,7 +422,12 @@ default void dequeue(Ptr<TaskDefinitions.task_struct> p, @Unsigned long deq_flag
422422
* executing an SCX task. Setting {@code p->scx.slice} to 0 will trigger an
423423
* immediate dispatch cycle on the CPU.
424424
*/
425-
void tick(Ptr<TaskDefinitions.task_struct> p);
425+
@BPFFunction(
426+
headerTemplate = "int BPF_STRUCT_OPS(simple_tick, struct task_struct *p)",
427+
addDefinition = false)
428+
default void tick(Ptr<TaskDefinitions.task_struct> p) {
429+
return;
430+
}
426431

427432
final int SCHED_EXT_UAPI_ID = 7;
428433

0 commit comments

Comments
 (0)