Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run 9-runqlat.bpf.c error #5190

Open
TanYuzhen opened this issue Jan 17, 2025 · 0 comments
Open

Run 9-runqlat.bpf.c error #5190

TanYuzhen opened this issue Jan 17, 2025 · 0 comments

Comments

@TanYuzhen
Copy link

TanYuzhen commented Jan 17, 2025

Loading BPF program...
libbpf: prog 'sched_switch': BPF program load failed: -EINVAL
libbpf: prog 'sched_switch': -- BEGIN PROG LOAD LOG --
0: R1=ctx() R10=fp0
; int BPF_PROG(sched_switch, bool preempt, struct task_struct *prev, struct task_struct *next)
0: (79) r2 = *(u64 *)(r1 +16)
func 'sched_switch' arg2 has btf_id 269 type STRUCT 'task_struct'
1: R1=ctx() R2_w=trusted_ptr_task_struct()
1: (79) r1 = *(u64 *)(r1 +8)
func 'sched_switch' arg1 has btf_id 269 type STRUCT 'task_struct'
2: R1_w=trusted_ptr_task_struct()
; return handle_switch(preempt, prev, next);
2: (85) call pc+2
caller:
 R10=fp0
callee:
 frame1: R1_w=trusted_ptr_task_struct() R2_w=trusted_ptr_task_struct() R10=fp0
5: frame1: R1_w=trusted_ptr_task_struct() R2_w=trusted_ptr_task_struct() R10=fp0
; static int handle_switch(bool preempt, struct task_struct *prev, struct task_struct *next)
5: (bf) r6 = r2                       ; frame1: R2_w=trusted_ptr_task_struct() R6_w=trusted_ptr_task_struct()
6: (bf) r7 = r1                       ; frame1: R1_w=trusted_ptr_task_struct() R7_w=trusted_ptr_task_struct()
; if (filter_cg && !bpf_current_task_under_cgroup(&cgroup_map, 0))
7: (18) r1 = 0xffff9d0e0238a000       ; frame1: R1_w=map_value(map=runqlat.rodata,ks=4,vs=12)
9: (71) r1 = *(u8 *)(r1 +0)           ; frame1: R1_w=0
; if (filter_cg && !bpf_current_task_under_cgroup(&cgroup_map, 0))
10: (16) if w1 == 0x0 goto pc+5       ; frame1: R1_w=0
; if (filter_cg && !bpf_current_task_under_cgroup(&cgroup_map, 0))
16: (b7) r1 = 1                       ; frame1: R1_w=1
; if (bpf_core_field_exists(t->__state))
17: (16) if w1 == 0x0 goto pc+10      ; frame1: R1_w=1
18: (b7) r1 = 24                      ; frame1: R1_w=24
19: (bf) r3 = r7                      ; frame1: R3_w=trusted_ptr_task_struct() R7=trusted_ptr_task_struct()
20: (0f) r3 += r1                     ; frame1: R1_w=24 R3_w=trusted_ptr_task_struct(off=24)
21: (bf) r1 = r10                     ; frame1: R1_w=fp0 R10=fp0
; 
22: (07) r1 += -16                    ; frame1: R1_w=fp-16
; return BPF_CORE_READ(t, __state);
23: (b4) w2 = 4                       ; frame1: R2_w=4
24: (85) call bpf_probe_read_kernel#113       ; frame1: R0=scalar() fp-16=????mmmm
; return BPF_CORE_READ(t, __state);
25: (61) r1 = *(u32 *)(r10 -16)       ; frame1: R1_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R10=fp0 fp-16=????mmmm
; if (get_task_state(prev) == TASK_RUNNING)
26: (55) if r1 != 0x0 goto pc+44      ; frame1: R1_w=0
27: (05) goto pc+9
; if (get_task_state(prev) == TASK_RUNNING)
37: (b7) r1 = 2468                    ; frame1: R1_w=2468
38: (bf) r3 = r7                      ; frame1: R3_w=trusted_ptr_task_struct() R7=trusted_ptr_task_struct()
39: (0f) r3 += r1                     ; frame1: R1_w=2468 R3_w=trusted_ptr_task_struct(off=2468)
40: (bf) r1 = r10                     ; frame1: R1_w=fp0 R10=fp0
; 
41: (07) r1 += -16                    ; frame1: R1_w=fp-16
; trace_enqueue(BPF_CORE_READ(prev, tgid), BPF_CORE_READ(prev, pid));
42: (b4) w2 = 4                       ; frame1: R2_w=4
43: (85) call bpf_probe_read_kernel#113       ; frame1: R0=scalar() fp-16=????mmmm
44: (b7) r1 = 2464                    ; frame1: R1_w=2464
45: (0f) r7 += r1                     ; frame1: R1_w=2464 R7_w=trusted_ptr_task_struct(off=2464)
; trace_enqueue(BPF_CORE_READ(prev, tgid), BPF_CORE_READ(prev, pid));
46: (61) r8 = *(u32 *)(r10 -16)       ; frame1: R8_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R10=fp0 fp-16=????mmmm
47: (bf) r1 = r10                     ; frame1: R1_w=fp0 R10=fp0
; 
48: (07) r1 += -16                    ; frame1: R1_w=fp-16
; trace_enqueue(BPF_CORE_READ(prev, tgid), BPF_CORE_READ(prev, pid));
49: (b4) w2 = 4                       ; frame1: R2_w=4
50: (bf) r3 = r7                      ; frame1: R3_w=trusted_ptr_task_struct(off=2464) R7_w=trusted_ptr_task_struct(off=2464)
51: (85) call bpf_probe_read_kernel#113       ; frame1: R0_w=scalar() fp-16=????mmmm
; trace_enqueue(BPF_CORE_READ(prev, tgid), BPF_CORE_READ(prev, pid));
52: (61) r1 = *(u32 *)(r10 -16)       ; frame1: R1_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R10=fp0 fp-16=????mmmm
53: (63) *(u32 *)(r10 -20) = r1       ; frame1: R1_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R10=fp0 fp-24=mmmm????
; if (!pid)
54: (16) if w1 == 0x0 goto pc+16      ; frame1: R1_w=scalar(smin=umin=umin32=1,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
; if (targ_tgid && targ_tgid != tgid)
55: (18) r1 = 0xffff9d0e0238a008      ; frame1: R1_w=map_value(map=runqlat.rodata,ks=4,vs=12,off=8)
57: (61) r2 = *(u32 *)(r1 +0)         ; frame1: R1=map_value(map=runqlat.rodata,ks=4,vs=12,off=8) R2=0
; if (targ_tgid && targ_tgid != tgid)
58: (16) if w2 == 0x0 goto pc+2       ; frame1: R2=0
; ts = bpf_ktime_get_ns();
61: (85) call bpf_ktime_get_ns#5      ; frame1: R0_w=scalar()
; ts = bpf_ktime_get_ns();
62: (7b) *(u64 *)(r10 -16) = r0       ; frame1: R0_w=scalar() R10=fp0 fp-16_w=mmmmmmmm
63: (bf) r2 = r10                     ; frame1: R2_w=fp0 R10=fp0
; ts = bpf_ktime_get_ns();
64: (07) r2 += -20                    ; frame1: R2_w=fp-20
65: (bf) r3 = r10                     ; frame1: R3_w=fp0 R10=fp0
66: (07) r3 += -16                    ; frame1: R3_w=fp-16
; bpf_map_update_elem(&start, &pid, &ts, BPF_ANY);
67: (18) r1 = 0xffff8da68ce89c00      ; frame1: R1_w=map_ptr(map=start,ks=4,vs=8)
69: (b7) r4 = 0                       ; frame1: R4_w=0
70: (85) call bpf_map_update_elem#2   ; frame1: R0=scalar()
71: (b7) r1 = 2464                    ; frame1: R1_w=2464
72: (bf) r3 = r6                      ; frame1: R3_w=trusted_ptr_task_struct() R6=trusted_ptr_task_struct()
73: (0f) r3 += r1                     ; frame1: R1_w=2464 R3_w=trusted_ptr_task_struct(off=2464)
74: (bf) r7 = r10                     ; frame1: R7_w=fp0 R10=fp0
; pid = BPF_CORE_READ(next, pid);
75: (07) r7 += -20                    ; frame1: R7_w=fp-20
76: (bf) r1 = r7                      ; frame1: R1_w=fp-20 R7_w=fp-20
77: (b4) w2 = 4                       ; frame1: R2_w=4
78: (85) call bpf_probe_read_kernel#113       ; frame1: R0_w=scalar() fp-24=mmmm????
; tsp = bpf_map_lookup_elem(&start, &pid);
79: (18) r1 = 0xffff8da68ce89c00      ; frame1: R1_w=map_ptr(map=start,ks=4,vs=8)
81: (bf) r2 = r7                      ; frame1: R2_w=fp-20 R7_w=fp-20
82: (85) call bpf_map_lookup_elem#1   ; frame1: R0=map_value_or_null(id=1,map=start,ks=4,vs=8)
83: (bf) r8 = r0                      ; frame1: R0=map_value_or_null(id=1,map=start,ks=4,vs=8) R8_w=map_value_or_null(id=1,map=start,ks=4,vs=8)
; if (!tsp)
84: (15) if r8 == 0x0 goto pc+129     ; frame1: R8_w=map_value(map=start,ks=4,vs=8)
; delta = bpf_ktime_get_ns() - *tsp;
85: (85) call bpf_ktime_get_ns#5      ; frame1: R0_w=scalar()
86: (bf) r7 = r0                      ; frame1: R0_w=scalar(id=2) R7_w=scalar(id=2)
; delta = bpf_ktime_get_ns() - *tsp;
87: (79) r1 = *(u64 *)(r8 +0)         ; frame1: R1_w=scalar() R8_w=map_value(map=start,ks=4,vs=8)
; delta = bpf_ktime_get_ns() - *tsp;
88: (1f) r7 -= r1                     ; frame1: R1_w=scalar() R7_w=scalar()
; if (delta < 0)
89: (c5) if r7 s< 0x0 goto pc+119     ; frame1: R7_w=scalar(smin=0,umax=0x7fffffffffffffff,var_off=(0x0; 0x7fffffffffffffff))
; if (targ_per_process)
90: (18) r1 = 0xffff9d0e0238a001      ; frame1: R1_w=map_value(map=runqlat.rodata,ks=4,vs=12,off=1)
92: (71) r1 = *(u8 *)(r1 +0)          ; frame1: R1=0
; if (targ_per_process)
93: (16) if w1 == 0x0 goto pc+8       ; frame1: R1=0
; else if (targ_per_thread)
102: (18) r1 = 0xffff9d0e0238a002     ; frame1: R1_w=map_value(map=runqlat.rodata,ks=4,vs=12,off=2)
104: (71) r1 = *(u8 *)(r1 +0)         ; frame1: R1_w=0
; else if (targ_per_thread)
105: (16) if w1 == 0x0 goto pc+109    ; frame1: R1_w=0
; else if (targ_per_pidns)
215: (18) r1 = 0xffff9d0e0238a003     ; frame1: R1_w=map_value(map=runqlat.rodata,ks=4,vs=12,off=3)
217: (71) r1 = *(u8 *)(r1 +0)         ; frame1: R1_w=0
; else if (targ_per_pidns)
218: (16) if w1 == 0x0 goto pc+29     ; frame1: R1_w=0
; inum = BPF_CORE_READ(upid.ns, ns.inum);
248: (b4) w1 = -1                     ; frame1: R1_w=0xffffffff
249: (05) goto pc-143
; 
107: (63) *(u32 *)(r10 -24) = r1      ; frame1: R1=0xffffffff R10=fp0 fp-24=mmmm0xffffffff
108: (bf) r2 = r10                    ; frame1: R2_w=fp0 R10=fp0
; 
109: (07) r2 += -24                   ; frame1: R2_w=fp-24
; val = bpf_map_lookup_elem(map, key);
110: (18) r1 = 0xffff8da68ce89000     ; frame1: R1_w=map_ptr(map=hists,ks=4,vs=120)
112: (85) call bpf_map_lookup_elem#1          ; frame1: R0_w=map_value_or_null(id=3,map=hists,ks=4,vs=120)
113: (bf) r8 = r0                     ; frame1: R0_w=map_value_or_null(id=3,map=hists,ks=4,vs=120) R8_w=map_value_or_null(id=3,map=hists,ks=4,vs=120)
; if (val)
114: (55) if r8 != 0x0 goto pc+17     ; frame1: R8_w=0
115: (bf) r2 = r10                    ; frame1: R2_w=fp0 R10=fp0
; err = bpf_map_update_elem(map, key, init, BPF_NOEXIST);
116: (07) r2 += -24                   ; frame1: R2_w=fp-24
117: (18) r1 = 0xffff8da68ce89000     ; frame1: R1_w=map_ptr(map=hists,ks=4,vs=120)
119: (18) r3 = 0xffff8da58c334310     ; frame1: R3_w=map_value(map=runqlat.bss,ks=4,vs=120)
121: (b7) r4 = 1                      ; frame1: R4_w=1
122: (85) call bpf_map_update_elem#2          ; frame1: R0=scalar()
; if (err && err != -EEXIST)
123: (15) if r0 == 0x0 goto pc+1      ; frame1: R0=scalar(umin=1)
124: (55) if r0 != 0xffffffef goto pc+84      ; frame1: R0=-17
125: (bf) r2 = r10                    ; frame1: R2_w=fp0 R10=fp0
; return bpf_map_lookup_elem(map, key);
126: (07) r2 += -24                   ; frame1: R2_w=fp-24
127: (18) r1 = 0xffff8da68ce89000     ; frame1: R1_w=map_ptr(map=hists,ks=4,vs=120)
129: (85) call bpf_map_lookup_elem#1          ; frame1: R0_w=map_value_or_null(id=4,map=hists,ks=4,vs=120)
130: (bf) r8 = r0                     ; frame1: R0_w=map_value_or_null(id=4,map=hists,ks=4,vs=120) R8_w=map_value_or_null(id=4,map=hists,ks=4,vs=120)
; if (!histp)
131: (15) if r8 == 0x0 goto pc+77     ; frame1: R8_w=map_value(map=hists,ks=4,vs=120)
; if (!histp->comm[0])
132: (71) r1 = *(u8 *)(r8 +104)       ; frame1: R1_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0; 0xff)) R8=map_value(map=hists,ks=4,vs=120)
; if (!histp->comm[0])
133: (56) if w1 != 0x0 goto pc+7      ; frame1: R1_w=0
134: (bf) r1 = r8                     ; frame1: R1_w=map_value(map=hists,ks=4,vs=120) R8=map_value(map=hists,ks=4,vs=120)
135: (07) r1 += 104                   ; frame1: R1_w=map_value(map=hists,ks=4,vs=120,off=104)
136: (b7) r2 = 3008                   ; frame1: R2_w=3008
137: (0f) r6 += r2                    ; frame1: R2_w=3008 R6_w=trusted_ptr_task_struct(off=3008)
; bpf_probe_read_kernel_str(&histp->comm, sizeof(histp->comm),
138: (b4) w2 = 16                     ; frame1: R2_w=16
139: (bf) r3 = r6                     ; frame1: R3_w=trusted_ptr_task_struct(off=3008) R6_w=trusted_ptr_task_struct(off=3008)
140: (85) call bpf_probe_read_kernel_str#115          ; frame1: R0=scalar(smin=smin32=-4095,smax=smax32=16)
; if (targ_ms)
141: (18) r1 = 0xffff9d0e0238a004     ; frame1: R1_w=map_value(map=runqlat.rodata,ks=4,vs=12,off=4)
143: (71) r2 = *(u8 *)(r1 +0)         ; frame1: R1_w=map_value(map=runqlat.rodata,ks=4,vs=12,off=4) R2_w=0
144: (b7) r1 = 1000                   ; frame1: R1_w=1000
145: (16) if w2 == 0x0 goto pc+1      ; frame1: R2_w=0
; 
147: (3f) r7 /= r1                    ; frame1: R1_w=1000 R7_w=scalar()
; u32 hi = v >> 32;
148: (bf) r2 = r7                     ; frame1: R2_w=scalar(id=5) R7_w=scalar(id=5)
149: (77) r2 >>= 32                   ; frame1: R2_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
; if (hi)
150: (16) if w2 == 0x0 goto pc+27 178: frame1: R0=scalar(smin=smin32=-4095,smax=smax32=16) R1=1000 R2=0 R6=trusted_ptr_task_struct(off=3008) R7=scalar(id=5) R8=map_value(map=hists,ks=4,vs=120) R10=fp0 fp-16=mmmmmmmm fp-24=mmmmmmmm
178: (b4) w2 = 1                      ; frame1: R2_w=1
179: (b4) w3 = 1                      ; frame1: R3_w=1
; return log2(v);
180: (26) if w7 > 0xffff goto pc+1    ; frame1: R7=scalar(id=5,smax=0x7fffffff0000ffff,umax=0xffffffff0000ffff,smin32=0,smax32=umax32=0xffff,var_off=(0x0; 0xffffffff0000ffff))
181: (b4) w3 = 0                      ; frame1: R3_w=0
; r = (v > 0xFFFF) << 4; v >>= r;
182: (64) w3 <<= 4                    ; frame1: R3_w=0
; r = (v > 0xFFFF) << 4; v >>= r;
183: (7c) w7 >>= w3                   ; frame1: R3_w=0 R7_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=0xffff,var_off=(0x0; 0xffff))
184: (b4) w1 = 1                      ; frame1: R1_w=1
185: (26) if w7 > 0xff goto pc+1      ; frame1: R7_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0; 0xff))
186: (b4) w1 = 0                      ; frame1: R1=0
; shift = (v > 0xFF) << 3; v >>= shift; r |= shift;
187: (64) w1 <<= 3                    ; frame1: R1_w=0
; shift = (v > 0xFF) << 3; v >>= shift; r |= shift;
188: (7c) w7 >>= w1                   ; frame1: R1_w=0 R7_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0; 0xff))
; shift = (v > 0xFF) << 3; v >>= shift; r |= shift;
189: (4c) w1 |= w3                    ; frame1: R1_w=0 R3=0
190: (b4) w3 = 1                      ; frame1: R3_w=1
; shift = (v > 0xFF) << 3; v >>= shift; r |= shift;
191: (26) if w7 > 0xf goto pc+1       ; frame1: R7_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=15,var_off=(0x0; 0xf))
192: (b4) w3 = 0                      ; frame1: R3_w=0
; shift = (v > 0xF) << 2; v >>= shift; r |= shift;
193: (64) w3 <<= 2                    ; frame1: R3_w=0
; shift = (v > 0xF) << 2; v >>= shift; r |= shift;
194: (4c) w1 |= w3                    ; frame1: R1_w=0 R3_w=0
; shift = (v > 0xF) << 2; v >>= shift; r |= shift;
195: (7c) w7 >>= w3                   ; frame1: R3_w=0 R7_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=15,var_off=(0x0; 0xf))
196: (26) if w7 > 0x3 goto pc+1       ; frame1: R7_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=3,var_off=(0x0; 0x3))
197: (b4) w2 = 0                      ; frame1: R2=0
; shift = (v > 0x3) << 1; v >>= shift; r |= shift;
198: (64) w2 <<= 1                    ; frame1: R2_w=0
; shift = (v > 0x3) << 1; v >>= shift; r |= shift;
199: (4c) w1 |= w2                    ; frame1: R1_w=0 R2_w=0
; shift = (v > 0x3) << 1; v >>= shift; r |= shift;
200: (7c) w7 >>= w2                   ; frame1: R2_w=0 R7_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=3,var_off=(0x0; 0x3))
; r |= (v >> 1);
201: (74) w7 >>= 1                    ; frame1: R7_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=1,var_off=(0x0; 0x1))
; r |= (v >> 1);
202: (4c) w1 |= w7                    ; frame1: R1_w=scalar() R7_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=1,var_off=(0x0; 0x1))
; if (slot >= MAX_SLOTS)
203: (a6) if w1 < 0x19 goto pc+1 205: frame1: R0=scalar(smin=smin32=-4095,smax=smax32=16) R1=scalar(smax=0x7fffffff00000018,umax=0xffffffff00000018,smin32=0,smax32=umax32=24,var_off=(0x0; 0xffffffff0000001f)) R2=0 R3=0 R6=trusted_ptr_task_struct(off=3008) R7=scalar(smin=smin32=0,smax=umax=smax32=umax32=1,var_off=(0x0; 0x1)) R8=map_value(map=hists,ks=4,vs=120) R10=fp0 fp-16=mmmmmmmm fp-24=mmmmmmmm
; __sync_fetch_and_add(&histp->slots[slot], 1);
205: (67) r1 <<= 2                    ; frame1: R1_w=scalar(smax=0x7ffffffc00000060,umax=0xfffffffc00000060,smin32=0,smax32=umax32=96,var_off=(0x0; 0xfffffffc0000007c))
206: (0f) r8 += r1
math between map_value pointer and register with unbounded min value is not allowed
processed 382 insns (limit 1000000) max_states_per_insn 4 total_states 32 peak_states 28 mark_read 5
-- END PROG LOAD LOG --
libbpf: prog 'sched_switch': failed to load: -EINVAL
libbpf: failed to load object 'runqlat.bpf.o'
Failed to load BPF object: -22

When I load the program, it's show that the slot is unbounded.
How can I fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant