Skip to content

Commit

Permalink
Tiny sched-ext improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
parttimenerd committed Jan 16, 2025
1 parent f29e75f commit d2a7a7b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ limactl shell hello-ebpf
sudo -s PATH=$PATH
```

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

Expand Down
10 changes: 10 additions & 0 deletions bpf/src/main/java/me/bechberger/ebpf/bpf/BPFJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ public static void bpf_probe_read_kernel_str(char[] dest, String source) {
throw new MethodIsBPFRelatedFunction();
}

/**
* Read the source string from the kernel and write it to the destination
* @see BPFHelpers#bpf_probe_read_kernel_str(Ptr, int, Ptr)
*/
@BuiltinBPFFunction("bpf_probe_read_kernel_str($arg1, sizeof($arg1), $arg2)")
@NotUsableInJava
public static void bpf_probe_read_kernel_str(String dest, char[] source) {
throw new MethodIsBPFRelatedFunction();
}

/**
* Read the source string from the kernel and write it to the destination
* @see BPFHelpers#bpf_probe_read_kernel_str(Ptr, int, Ptr)
Expand Down
11 changes: 8 additions & 3 deletions bpf/src/main/java/me/bechberger/ebpf/bpf/Scheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
.disable = (void *)simple_disable,
.stopping = (void *)simple_stopping,
.dequeue = (void *)simple_dequeue,
.tick = (void *)sched_tick,
.tick = (void *)simple_tick,
.flags = SCX_OPS_ENQ_LAST | SCX_OPS_KEEP_BUILTIN_IDLE,
.name = "__property_sched_name");
"""
Expand Down Expand Up @@ -407,7 +407,7 @@ default void stopping(Ptr<TaskDefinitions.task_struct> p, boolean runnable) {
* scheduling position not being updated across a priority change.
*/
@BPFFunction(
headerTemplate = "void BPF_STRUCT_OPS(simple_dequeue, struct task_struct *p, u64 deq_flags)",
headerTemplate = "int BPF_STRUCT_OPS(simple_dequeue, struct task_struct *p, u64 deq_flags)",
addDefinition = false
)
default void dequeue(Ptr<TaskDefinitions.task_struct> p, @Unsigned long deq_flags) {
Expand All @@ -422,7 +422,12 @@ default void dequeue(Ptr<TaskDefinitions.task_struct> p, @Unsigned long deq_flag
* executing an SCX task. Setting {@code p->scx.slice} to 0 will trigger an
* immediate dispatch cycle on the CPU.
*/
void tick(Ptr<TaskDefinitions.task_struct> p);
@BPFFunction(
headerTemplate = "int BPF_STRUCT_OPS(simple_tick, struct task_struct *p)",
addDefinition = false)
default void tick(Ptr<TaskDefinitions.task_struct> p) {
return;
}

final int SCHED_EXT_UAPI_ID = 7;

Expand Down

0 comments on commit d2a7a7b

Please sign in to comment.