Skip to content

Commit 4a30dea

Browse files
committed
Sync struct_ops kfunc-call test with sched_ext ABI update
igned-off-by: Cong Wang <cwang@multikernel.io>
1 parent 0fdef1d commit 4a30dea

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

tests/test_struct_ops.ml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,9 +1382,9 @@ let test_sched_ext_ops_btf_definition () =
13821382
let test_struct_ops_can_call_kernel_functions () =
13831383
let program = {|
13841384
// Declare external kernel functions (kfuncs)
1385-
extern scx_bpf_select_cpu_dfl(p: *u8, prev_cpu: i32, wake_flags: u64, direct: *bool) -> i32
1386-
extern scx_bpf_dsq_insert(p: *u8, dsq_id: u64, slice: u64, enq_flags: u64) -> void
1387-
extern scx_bpf_consume(dsq_id: u64, cpu: i32, flags: u64) -> i32
1385+
extern scx_bpf_select_cpu_dfl(p: *task_struct, prev_cpu: i32, wake_flags: u64, is_idle: *bool) -> i32
1386+
extern scx_bpf_dsq_insert(p: *task_struct, dsq_id: u64, slice: u64, enq_flags: u64) -> void
1387+
extern scx_bpf_dsq_move_to_local(dsq_id: u64) -> bool
13881388

13891389
// Kernel enum constants
13901390
enum scx_dsq_id_flags {
@@ -1395,21 +1395,21 @@ let test_struct_ops_can_call_kernel_functions () =
13951395

13961396
@struct_ops("sched_ext_ops")
13971397
impl simple_scheduler {
1398-
fn select_cpu(p: *u8, prev_cpu: i32, wake_flags: u64) -> i32 {
1399-
var direct: bool = false
1398+
fn select_cpu(p: *task_struct, prev_cpu: i32, wake_flags: u64) -> i32 {
1399+
var is_idle: bool = false
14001400
// This should be allowed - struct_ops functions run in kernel context
1401-
var cpu = scx_bpf_select_cpu_dfl(p, prev_cpu, wake_flags, &direct)
1402-
1403-
if (direct == true) {
1401+
var cpu = scx_bpf_select_cpu_dfl(p, prev_cpu, wake_flags, &is_idle)
1402+
1403+
if (is_idle == true) {
14041404
scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, 0)
14051405
}
1406-
1406+
14071407
return cpu
14081408
}
1409-
1410-
fn dispatch(cpu: i32, prev: *u8) -> void {
1409+
1410+
fn dispatch(cpu: i32, prev: *task_struct) -> void {
14111411
// This should also be allowed - calling kernel function from struct_ops
1412-
if (scx_bpf_consume(SCX_DSQ_GLOBAL, cpu, 0) == 0) {
1412+
if (!scx_bpf_dsq_move_to_local(SCX_DSQ_GLOBAL)) {
14131413
// No tasks available
14141414
}
14151415
}

0 commit comments

Comments
 (0)