Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save likewhatevs/2e564240279b452b8cddb0b1ee2ade90 to your computer and use it in GitHub Desktop.
Save likewhatevs/2e564240279b452b8cddb0b1ee2ade90 to your computer and use it in GitHub Desktop.
❯ cargo build --release -p scx_layered
warning: /home/patso/repos/scx/rust/scx_rustland_core/Cargo.toml: unused manifest key: lib.include
warning: /home/patso/repos/scx/Cargo.toml: unused manifest key: profile.release-fast.debuginfo
warning: /home/patso/repos/scx/Cargo.toml: unused manifest key: profile.release-fast.target-cpu
Finished `release` profile [optimized] target(s) in 0.04s
patso in 🌐 gentoo in scx on ξ‚  layered-match-layer-fix [$!] is πŸ“¦ v1.0.11 via 🐍 v3.13.3 via πŸ¦€ v1.86.0
❯ sudo ./target/release/scx_layered --run-example
19:07:46 [INFO] Topology awareness not specified, selecting enabled based on hardware
19:07:46 [INFO] CPUs: online/possible=32/32 nr_cores=16
19:07:46 [INFO] Kernel does not support queued wakeup optimization
19:07:46 [WARN] libbpf: extern (kcfg) 'CONFIG_CC_VERSION_TEXT': long string '"x86_64-pc-linux-gnu-gcc (Gentoo 14.2.1_p20241221 p7) 14.2.1 20241221"' of (68 bytes) truncated to 63 bytes
19:07:46 [WARN] libbpf: prog 'layered_runnable': BPF program load failed: Invalid argument
19:07:46 [WARN] libbpf: prog 'layered_runnable': -- BEGIN PROG LOAD LOG --
Global function layered_runnable() doesn't return scalar. Only those are supported.
0: R1=ctx() R10=fp0
; void BPF_STRUCT_OPS(layered_runnable, struct task_struct *p, u64 enq_flags) @ main.bpf.c:2401
0: (79) r2 = *(u64 *)(r1 +8) ; R1=ctx() R2_w=scalar()
1: (7b) *(u64 *)(r10 -56) = r2 ; R2_w=scalar(id=1) R10=fp0 fp-56_w=scalar(id=1)
2: (79) r7 = *(u64 *)(r1 +0)
func 'runnable' arg0 has btf_id 172 type STRUCT 'task_struct'
3: R1=ctx() R7_w=trusted_ptr_task_struct()
; u64 now = scx_bpf_now(); @ main.bpf.c:2404
3: (18) r1 = 0xffffffffa24243d0 ; R1_w=rdonly_mem(sz=0)
5: (15) if r1 == 0x0 goto pc+2 ; R1_w=rdonly_mem(sz=0)
6: (85) call scx_bpf_now#129482 ; R0_w=scalar()
7: (05) goto pc+1
9: (bf) r8 = r0 ; R0=scalar(id=2) R8_w=scalar(id=2)
10: (b7) r6 = 0 ; R6_w=0
; return bpf_task_storage_get(&task_ctxs, p, 0, 0); @ main.bpf.c:521
11: (18) r1 = 0xffff8dff137df800 ; R1_w=map_ptr(map=task_ctxs,ks=4,vs=200)
13: (bf) r2 = r7 ; R2_w=trusted_ptr_task_struct() R7=trusted_ptr_task_struct()
14: (b7) r3 = 0 ; R3_w=0
15: (b7) r4 = 0 ; R4_w=0
16: (85) call bpf_task_storage_get#156 ; R0_w=map_value_or_null(id=3,map=task_ctxs,ks=4,vs=200)
17: (bf) r9 = r0 ; R0_w=map_value_or_null(id=3,map=task_ctxs,ks=4,vs=200) R9_w=map_value_or_null(id=3,map=task_ctxs,ks=4,vs=200)
; if (!taskc) @ main.bpf.c:528
18: (55) if r9 != 0x0 goto pc+6 25: R0_w=map_value(map=task_ctxs,ks=4,vs=200) R6_w=0 R7=trusted_ptr_task_struct() R8_w=scalar(id=2) R9_w=map_value(map=task_ctxs,ks=4,vs=200) R10=fp0 fp-56=scalar(id=1)
; taskc->runnable_at = now; @ main.bpf.c:2409
25: (7b) *(u64 *)(r9 +128) = r8 ; R8_w=scalar(id=2) R9_w=map_value(map=task_ctxs,ks=4,vs=200)
; if (!taskc->refresh_layer) @ main.bpf.c:2185
26: (71) r1 = *(u8 *)(r9 +16) ; R1_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0; 0xff)) R9_w=map_value(map=task_ctxs,ks=4,vs=200)
27: (56) if w1 != 0x1 goto pc+145 ; R1_w=1
28: (b4) w1 = 0 ; R1_w=0
; taskc->refresh_layer = false; @ main.bpf.c:2187
29: (73) *(u8 *)(r9 +16) = r1 ; R1_w=0 R9_w=map_value(map=task_ctxs,ks=4,vs=200)
; taskc->layer_refresh_seq = layer_refresh_seq_avgruntime; @ main.bpf.c:2188
30: (18) r1 = 0xffffb49339df5290 ; R1_w=map_value(map=bpf_bpf.bss,ks=4,vs=84882144,off=0x50f3290)
32: (79) r1 = *(u64 *)(r1 +0) ; R1_w=scalar()
33: (7b) *(u64 *)(r9 +192) = r1 ; R1_w=scalar() R9_w=map_value(map=task_ctxs,ks=4,vs=200)
; if (!(cgrp_path = format_cgrp_path(p->cgroups->dfl_cgrp))) @ main.bpf.c:2190
34: (79) r1 = *(u64 *)(r7 +3904) ; R1_w=rcu_ptr_css_set() R7=trusted_ptr_task_struct()
35: (79) r1 = *(u64 *)(r1 +128) ; R1=rcu_ptr_cgroup()
36: (85) call pc+244
caller:
R6=0 R7=trusted_ptr_task_struct() R8=scalar(id=2) R9=map_value(map=task_ctxs,ks=4,vs=200) R10=fp0 fp-56=scalar(id=1)
callee:
frame1: R1=rcu_ptr_cgroup() R10=fp0
281: frame1: R1=rcu_ptr_cgroup() R10=fp0
; __hidden char *format_cgrp_path(struct cgroup *cgrp) @ util.bpf.c:43
281: (bf) r7 = r1 ; frame1: R1=rcu_ptr_cgroup() R7_w=rcu_ptr_cgroup()
282: (b4) w1 = 0 ; frame1: R1_w=0
; u32 zero = 0; @ util.bpf.c:45
283: (63) *(u32 *)(r10 -4) = r1 ; frame1: R1_w=0 R10=fp0 fp-8=0000????
284: (bf) r2 = r10 ; frame1: R2_w=fp0 R10=fp0
285: (07) r2 += -4 ; frame1: R2_w=fp-4
; char *path = bpf_map_lookup_elem(&cgrp_path_bufs, &zero); @ util.bpf.c:46
286: (18) r1 = 0xffff8dff13819000 ; frame1: R1_w=map_ptr(map=cgrp_path_bufs,ks=4,vs=8192)
288: (85) call bpf_map_lookup_elem#1 ; frame1: R0=map_value(map=cgrp_path_bufs,ks=4,vs=8192)
289: (bf) r6 = r0 ; frame1: R0=map_value(map=cgrp_path_bufs,ks=4,vs=8192) R6_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192)
; if (!path) { @ util.bpf.c:49
290: (55) if r6 != 0x0 goto pc+7 ; frame1: R6_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192)
; scx_bpf_error("cgrp_path_buf lookup failed"); @ util.bpf.c:50
298: (bf) r9 = r7 ; frame1: R7=rcu_ptr_cgroup() R9_w=rcu_ptr_cgroup()
; max_level = cgrp->level; @ util.bpf.c:54
299: (61) r1 = *(u32 *)(r7 +216) ; frame1: R1_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R7=rcu_ptr_cgroup()
300: (bc) w3 = w1 ; frame1: R1_w=scalar(id=4,smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R3_w=scalar(id=4,smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
301: (63) *(u32 *)(r10 -40) = r1 ; frame1: R1_w=scalar(id=4,smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R10=fp0 fp-40=????scalar(id=4,smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
; if (max_level > 32) @ util.bpf.c:55
302: (a6) if w1 < 0x20 goto pc+1 ; frame1: R1_w=scalar(id=4,smin=umin=umin32=32,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
303: (b4) w3 = 32 ; frame1: R3=32
; bpf_for(level, 1, max_level + 1) { @ util.bpf.c:58
304: (04) w3 += 1 ; frame1: R3_w=33
305: (bf) r8 = r10 ; frame1: R8_w=fp0 R10=fp0
306: (07) r8 += -16 ; frame1: R8_w=fp-16
307: (bf) r1 = r8 ; frame1: R1_w=fp-16 R8_w=fp-16
308: (b4) w2 = 1 ; frame1: R2_w=1
309: (85) call bpf_iter_num_new#77774 ; frame1: R0_w=scalar() fp-16_w=iter_num(ref_id=5,state=active,depth=0) refs=5
310: (bf) r1 = r8 ; frame1: R1=fp-16 R8=fp-16 refs=5
311: (85) call bpf_iter_num_next#77776 ; frame1: R0_w=0 fp-16=iter_num(ref_id=5,state=drained,depth=0) refs=5
312: (15) if r0 == 0x0 goto pc+70 ; frame1: R0_w=0 refs=5
; path[len++] = '/'; @ util.bpf.c:62
383: (bf) r1 = r10 ; frame1: R1_w=fp0 R10=fp0 refs=5
384: (07) r1 += -16 ; frame1: R1_w=fp-16 refs=5
; bpf_for(level, 1, max_level + 1) { @ util.bpf.c:58
385: (85) call bpf_iter_num_destroy#77772 ; frame1:
386: (b4) w7 = 0 ; frame1: R7_w=0
; path[len] = '/'; @ util.bpf.c:83
387: (bc) w1 = w7 ; frame1: R1_w=0 R7_w=0
388: (bf) r2 = r6 ; frame1: R2_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192) R6=map_value(map=cgrp_path_bufs,ks=4,vs=8192)
389: (0f) r2 += r1 ; frame1: R1_w=0 R2_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192)
390: (b4) w1 = 0 ; frame1: R1_w=0
; path[len + 1] = '\0'; @ util.bpf.c:84
391: (73) *(u8 *)(r2 +1) = r1 ; frame1: R1_w=0 R2_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192)
392: (b4) w1 = 47 ; frame1: R1_w=47
; path[len] = '/'; @ util.bpf.c:83
393: (73) *(u8 *)(r2 +0) = r1 ; frame1: R1_w=47 R2_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192)
394: (05) goto pc+19
; } @ util.bpf.c:87
414: (bf) r0 = r6 ; frame1: R0_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192) R6=map_value(map=cgrp_path_bufs,ks=4,vs=8192)
415: (95) exit
returning from callee:
frame1: R0_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192) R1=47 R2=map_value(map=cgrp_path_bufs,ks=4,vs=8192) R6=map_value(map=cgrp_path_bufs,ks=4,vs=8192) R7=0 R8=fp-16 R9=rcu_ptr_cgroup() R10=fp0 fp-8=0000???? fp-40=????scalar(id=4,smin=umin=umin32=32,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
to caller at 37:
R0_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192) R6=0 R7=trusted_ptr_task_struct() R8=scalar(id=2) R9=map_value(map=task_ctxs,ks=4,vs=200) R10=fp0 fp-56=scalar(id=1)
; if (!(cgrp_path = format_cgrp_path(p->cgroups->dfl_cgrp))) @ main.bpf.c:2190
37: (7b) *(u64 *)(r10 -48) = r0 ; R0_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192) R10=fp0 fp-48_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192)
38: (15) if r0 == 0x0 goto pc+134 ; R0_w=map_value(map=cgrp_path_bufs,ks=4,vs=8192)
39: (7b) *(u64 *)(r10 -64) = r9 ; R9=map_value(map=task_ctxs,ks=4,vs=200) R10=fp0 fp-64_w=map_value(map=task_ctxs,ks=4,vs=200)
; if (taskc->layer_id >= 0 && taskc->layer_id < nr_layers) @ main.bpf.c:2193
40: (61) r1 = *(u32 *)(r9 +8) ; R1_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R9=map_value(map=task_ctxs,ks=4,vs=200)
41: (18) r6 = 0xffffb48db94a9008 ; R6_w=map_value(map=bpf_bpf.rodata,ks=4,vs=11456,off=8)
43: (61) r2 = *(u32 *)(r6 +0) ; R2=4 R6=map_value(map=bpf_bpf.rodata,ks=4,vs=11456,off=8)
44: (3e) if w1 >= w2 goto pc+7 ; R1=scalar(smin=smin32=0,smax=umax=smax32=umax32=3,var_off=(0x0; 0x3)) R2=4
; __sync_fetch_and_add(&layers[taskc->layer_id].nr_tasks, -1); @ main.bpf.c:2194
45: (27) r1 *= 5305128 ; R1_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=0xf2d978,var_off=(0x0; 0xf3ff78))
46: (18) r2 = 0xffffb49334d02010 ; R2_w=map_value(map=bpf_bpf.bss,ks=4,vs=84882144,off=16)
48: (0f) r2 += r1 ; R1_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=0xf2d978,var_off=(0x0; 0xf3ff78)) R2_w=map_value(map=bpf_bpf.bss,ks=4,vs=84882144,off=16,smin=smin32=0,smax=umax=smax32=umax32=0xf2d978,var_off=(0x0; 0xf3ff78))
49: (07) r2 += 5304664 ; R2_w=map_value(map=bpf_bpf.bss,ks=4,vs=84882144,off=0x50f168,smin=smin32=0,smax=umax=smax32=umax32=0xf2d978,var_off=(0x0; 0xf3ff78))
50: (b7) r1 = -1 ; R1_w=-1
51: (db) lock *(u64 *)(r2 +0) += r1 ; R1_w=-1 R2_w=map_value(map=bpf_bpf.bss,ks=4,vs=84882144,off=0x50f168,smin=smin32=0,smax=umax=smax32=umax32=0xf2d978,var_off=(0x0; 0xf3ff78))
; bpf_for(layer_id, 0, nr_layers) { @ main.bpf.c:2196
52: (61) r3 = *(u32 *)(r6 +0) ; R3_w=4 R6=map_value(map=bpf_bpf.rodata,ks=4,vs=11456,off=8)
53: (bf) r1 = r10 ; R1_w=fp0 R10=fp0
54: (07) r1 += -40 ; R1_w=fp-40
55: (b4) w2 = 0 ; R2_w=0
56: (85) call bpf_iter_num_new#77774 ; R0=scalar() fp-40=iter_num(ref_id=7,state=active,depth=0) refs=7
57: (bf) r1 = r10 ; R1_w=fp0 R10=fp0 refs=7
58: (07) r1 += -40 ; R1=fp-40 refs=7
59: (85) call bpf_iter_num_next#77776 60: R0=rdonly_mem(id=8,ref_obj_id=7,sz=4) R6=map_value(map=bpf_bpf.rodata,ks=4,vs=11456,off=8) R7=trusted_ptr_task_struct() R8=scalar(id=2) R9=map_value(map=task_ctxs,ks=4,vs=200) R10=fp0 fp-40=iter_num(ref_id=7,state=active,depth=1) fp-48=map_value(map=cgrp_path_bufs,ks=4,vs=8192) fp-56=scalar(id=1) fp-64=map_value(map=task_ctxs,ks=4,vs=200) refs=7
; bpf_for(layer_id, 0, nr_layers) { @ main.bpf.c:2196
60: (15) if r0 == 0x0 goto pc+43 ; R0=rdonly_mem(id=8,ref_obj_id=7,sz=4) refs=7
61: (61) r8 = *(u32 *)(r0 +0) ; R0=rdonly_mem(id=8,ref_obj_id=7,sz=4) R8_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) refs=7
62: (bf) r9 = r8 ; R8_w=scalar(id=15,smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R9_w=scalar(id=15,smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) refs=7
63: (67) r9 <<= 32 ; R9_w=scalar(smax=0x7fffffff00000000,umax=0xffffffff00000000,smin32=0,smax32=umax32=0,var_off=(0x0; 0xffffffff00000000)) refs=7
64: (c7) r9 s>>= 32 ; R9_w=scalar(smin=0xffffffff80000000,smax=0x7fffffff) refs=7
65: (61) r1 = *(u32 *)(r6 +0) ; R1_w=4 R6=map_value(map=bpf_bpf.rodata,ks=4,vs=11456,off=8) refs=7
66: (3d) if r9 >= r1 goto pc+37 ; R1_w=4 R9_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=3,var_off=(0x0; 0x3)) refs=7
; if (p && match_layer(layer_id, p, cgrp_path) == 0) { @ main.bpf.c:2197
67: (15) if r7 == 0x0 goto pc+83 ; R7=trusted_ptr_task_struct() refs=7
68: (bc) w1 = w8 ; R1_w=scalar(id=15,smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R8_w=scalar(id=15,smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) refs=7
69: (bf) r2 = r7 ; R2_w=trusted_ptr_task_struct() R7=trusted_ptr_task_struct() refs=7
70: (79) r3 = *(u64 *)(r10 -48) ; R3=map_value(map=cgrp_path_bufs,ks=4,vs=8192) R10=fp0 fp-48=map_value(map=cgrp_path_bufs,ks=4,vs=8192) refs=7
71: (85) call pc+344
access beyond struct thread_info at off 0 size 9664
Caller passes invalid args into func#2 ('match_layer')
processed 268 insns (limit 1000000) max_states_per_insn 1 total_states 26 peak_states 26 mark_read 11
-- END PROG LOAD LOG --
19:07:46 [WARN] libbpf: prog 'layered_runnable': failed to load: -22
19:07:46 [WARN] libbpf: failed to load object 'bpf_bpf'
19:07:46 [WARN] libbpf: failed to load BPF skeleton 'bpf_bpf': -22
Error: Failed to load BPF program
Caused by:
Invalid argument (os error 22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment