Skip to content

rsched fails to run in Debian #7

Description

@sudipm-mukherjee

I am trying to add rsched to Debian and the package is now in review to be included.
But while testing, I am seeing an error and it fails to run.

Starting rsched
libbpf: prog 'handle_sched_wakeup_btf': BPF program load failed: -EACCES
libbpf: prog 'handle_sched_wakeup_btf': -- BEGIN PROG LOAD LOG --
0: R1=ctx() R10=fp0
; int BPF_PROG(handle_sched_wakeup_btf, struct task_struct *p) @ rsched.bpf.c:831
0: (b7) r2 = 2704                     ; R2_w=2704
1: (79) r7 = *(u64 *)(r1 +0)
func 'sched_wakeup' arg0 has btf_id 114 type STRUCT 'task_struct'
2: R1=ctx() R7_w=trusted_ptr_task_struct()
2: (bf) r3 = r7                       ; R3_w=trusted_ptr_task_struct() R7_w=trusted_ptr_task_struct()
3: (0f) r3 += r2                      ; R2_w=2704 R3_w=trusted_ptr_task_struct(off=2704)
4: (bf) r1 = r10                      ; R1_w=fp0 R10=fp0
5: (07) r1 += -16                     ; R1_w=fp-16
; __u32 pid = BPF_CORE_READ(p, pid); @ rsched.bpf.c:388
6: (b7) r2 = 4                        ; R2_w=4
7: (85) call bpf_probe_read_kernel#113        ; R0_w=scalar() fp-16=????mmmm
; __u64 ts = bpf_ktime_get_ns(); @ rsched.bpf.c:390
8: (85) call bpf_ktime_get_ns#5       ; R0=scalar()
9: (bf) r6 = r0                       ; R0=scalar(id=1) R6_w=scalar(id=1)
; if (!task) @ core-helpers.h:104
10: (15) if r7 == 0x0 goto pc+99      ; R7=trusted_ptr_task_struct()
11: (b7) r1 = 1                       ; R1_w=1
; if (bpf_core_field_exists(task->thread_info)) { @ core-helpers.h:28
12: (15) if r1 == 0x0 goto pc+10      ; R1_w=1
13: (b7) r1 = 20                      ; R1_w=20
14: (bf) r3 = r7                      ; R3_w=trusted_ptr_task_struct() R7=trusted_ptr_task_struct()
15: (0f) r3 += r1                     ; R1_w=20 R3_w=trusted_ptr_task_struct(off=20)
16: (bf) r1 = r10                     ; R1_w=fp0 R10=fp0
17: (07) r1 += -8                     ; R1_w=fp-8
; cpu = BPF_CORE_READ(task, thread_info.cpu); @ core-helpers.h:29
18: (b7) r2 = 4                       ; R2_w=4
19: (85) call bpf_probe_read_kernel#113       ; R0=scalar() fp-8=????mmmm
20: (61) r2 = *(u32 *)(r10 -8)        ; R2_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R10=fp0 fp-8=????mmmm
21: (b7) r1 = 1024                    ; R1_w=1024
; if (cpu >= 0 && cpu < 1024) @ core-helpers.h:30
22: (2d) if r1 > r2 goto pc+31        ; R1_w=1024 R2_w=scalar(smin=umin=umin32=1024,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
23: (b7) r1 = 1                       ; R1_w=1
; if (bpf_core_field_exists(task->stack)) { @ core-helpers.h:35
24: (15) if r1 == 0x0 goto pc+18      ; R1_w=1
25: (b7) r1 = 32                      ; R1_w=32
26: (bf) r3 = r7                      ; R3_w=trusted_ptr_task_struct() R7=trusted_ptr_task_struct()
27: (0f) r3 += r1                     ; R1_w=32 R3_w=trusted_ptr_task_struct(off=32)
28: (bf) r1 = r10                     ; R1_w=fp0 R10=fp0
29: (07) r1 += -8                     ; R1_w=fp-8
; void *stack = BPF_CORE_READ(task, stack); @ core-helpers.h:36
30: (b7) r2 = 8                       ; R2_w=8
31: (85) call bpf_probe_read_kernel#113       ; R0=scalar() fp-8=mmmmmmmm
32: (79) r3 = *(u64 *)(r10 -8)        ; R3_w=scalar() R10=fp0 fp-8=mmmmmmmm
; if (stack) { @ core-helpers.h:37
33: (15) if r3 == 0x0 goto pc+9       ; R3_w=scalar(umin=1)
34: (b7) r1 = 20                      ; R1_w=20
35: (0f) r3 += r1                     ; R1_w=20 R3_w=scalar()
36: (bf) r1 = r10                     ; R1_w=fp0 R10=fp0
37: (07) r1 += -8                     ; R1_w=fp-8
; cpu = BPF_CORE_READ(ti, cpu); @ core-helpers.h:39
38: (b7) r2 = 4                       ; R2_w=4
39: (85) call bpf_probe_read_kernel#113       ; R0=scalar() fp-8=mmmmmmmm
40: (61) r2 = *(u32 *)(r10 -8)        ; R2_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R10=fp0 fp-8=mmmmmmmm
41: (b7) r1 = 1024                    ; R1_w=1024
42: (2d) if r1 > r2 goto pc+11        ; R1_w=1024 R2_w=scalar(smin=umin=umin32=1024,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
43: (b7) r1 = 0                       ; R1_w=0
; if (bpf_core_field_exists(((struct task_struct___a *)task)->cpu)) { @ core-helpers.h:46
44: (15) if r1 == 0x0 goto pc+65      ; R1_w=0
; if (pid) { @ rsched.bpf.c:419
110: (61) r1 = *(u32 *)(r10 -16)      ; R1_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff)) R10=fp0 fp-16=????mmmm
111: (15) if r1 == 0x0 goto pc+69     ; R1_w=scalar(smin=umin=umin32=1,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
112: (bf) r2 = r10                    ; R2_w=fp0 R10=fp0
113: (07) r2 += -16                   ; R2_w=fp-16
; __u64 *sleep_start = bpf_map_lookup_elem(&sleep_time, &pid); @ rsched.bpf.c:420
114: (18) r1 = 0xffff89468b25c000     ; R1_w=map_ptr(map=sleep_time,ks=4,vs=8)
116: (85) call bpf_map_lookup_elem#1          ; R0=map_value_or_null(id=2,map=sleep_time,ks=4,vs=8)
; if (sleep_start) { @ rsched.bpf.c:421
117: (15) if r0 == 0x0 goto pc+51     ; R0=map_value(map=sleep_time,ks=4,vs=8)
; __u64 sleep_duration = ts - *sleep_start; @ rsched.bpf.c:422
118: (79) r1 = *(u64 *)(r0 +0)        ; R0=map_value(map=sleep_time,ks=4,vs=8) R1_w=scalar()
119: (bf) r9 = r6                     ; R6=scalar(id=1) R9_w=scalar(id=1)
120: (1f) r9 -= r1                    ; R1_w=scalar() R9_w=scalar()
121: (18) r1 = 0x34630b89fff          ; R1_w=0x34630b89fff
; if (sleep_duration < 3600000000000ULL) { @ rsched.bpf.c:425
123: (2d) if r9 > r1 goto pc+40       ; R1_w=0x34630b89fff R9_w=scalar(smin=0,smax=umax=0x34630b89fff,var_off=(0x0; 0x3ffffffffff))
124: (bf) r2 = r10                    ; R2_w=fp0 R10=fp0
125: (07) r2 += -16                   ; R2_w=fp-16
; bpf_map_lookup_elem(&sleep_hists, &pid); @ rsched.bpf.c:427
126: (18) r1 = 0xffff89468b25cc00     ; R1_w=map_ptr(map=sleep_hists,ks=4,vs=272)
128: (85) call bpf_map_lookup_elem#1          ; R0=map_value_or_null(id=3,map=sleep_hists,ks=4,vs=272)
; if (!sleep_data) { @ rsched.bpf.c:428
129: (55) if r0 != 0x0 goto pc+23     ; R0=0
130: (bf) r8 = r10                    ; R8_w=fp0 R10=fp0
131: (07) r8 += -16                   ; R8_w=fp-16
; bpf_map_update_elem(&sleep_hists, &pid, @ rsched.bpf.c:430
132: (18) r1 = 0xffff89468b25cc00     ; R1_w=map_ptr(map=sleep_hists,ks=4,vs=272)
134: (bf) r2 = r8                     ; R2_w=fp-16 R8_w=fp-16
135: (18) r3 = 0xffff8946858e3218     ; R3_w=map_value(map=rsched_b.bss,ks=4,vs=2704,off=272)
137: (b7) r4 = 1                      ; R4_w=1
138: (85) call bpf_map_update_elem#2          ; R0=scalar()
; sleep_data = bpf_map_lookup_elem( @ rsched.bpf.c:433
139: (18) r1 = 0xffff89468b25cc00     ; R1_w=map_ptr(map=sleep_hists,ks=4,vs=272)
141: (bf) r2 = r8                     ; R2_w=fp-16 R8=fp-16
142: (85) call bpf_map_lookup_elem#1          ; R0_w=map_value_or_null(id=4,map=sleep_hists,ks=4,vs=272)
; if (sleep_data) { @ rsched.bpf.c:435
143: (15) if r0 == 0x0 goto pc+20     ; R0_w=map_value(map=sleep_hists,ks=4,vs=272)
144: (b7) r1 = 3248                   ; R1_w=3248
145: (0f) r7 += r1                    ; R1_w=3248 R7_w=trusted_ptr_task_struct(off=3248)
; read_task_comm(sleep_data->comm, @ rsched.bpf.c:436
146: (bf) r1 = r0                     ; R0_w=map_value(map=sleep_hists,ks=4,vs=272) R1_w=map_value(map=sleep_hists,ks=4,vs=272)
147: (07) r1 += 256                   ; R1_w=map_value(map=sleep_hists,ks=4,vs=272,off=256)
; bpf_probe_read_kernel_str(dst, TASK_COMM_LEN, task->comm); @ core-helpers.h:141
148: (b7) r2 = 16                     ; R2_w=16
149: (bf) r3 = r7                     ; R3_w=trusted_ptr_task_struct(off=3248) R7_w=trusted_ptr_task_struct(off=3248)
150: (bf) r7 = r0                     ; R0_w=map_value(map=sleep_hists,ks=4,vs=272) R7_w=map_value(map=sleep_hists,ks=4,vs=272)
151: (85) call bpf_probe_read_kernel_str#115          ; R0=scalar(smin=smin32=-4095,smax=smax32=16)
152: (bf) r0 = r7                     ; R0_w=map_value(map=sleep_hists,ks=4,vs=272) R7=map_value(map=sleep_hists,ks=4,vs=272)
; if (delay_us < LINEAR_THRESHOLD) { @ rsched.bpf.c:357
153: (25) if r9 > 0x7a11f goto pc+29          ; R9=scalar(smin=smin32=0,smax=umax=smax32=umax32=0x7a11f,var_off=(0x0; 0x7ffff))
; __u32 slot = delay_us / LINEAR_STEP; @ rsched.bpf.c:359
154: (67) r9 <<= 32                   ; R9_w=scalar(smin=smin32=0,smax=umax=0x7a11f00000000,smax32=umax32=0,var_off=(0x0; 0x7ffff00000000))
155: (77) r9 >>= 32                   ; R9_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=0x7a11f,var_off=(0x0; 0x7ffff))
156: (37) r9 /= 10000                 ; R9_w=scalar()
157: (bf) r2 = r9                     ; R2_w=scalar(id=5) R9_w=scalar(id=5)
; &sleep_data->hist @ rsched.bpf.c:445
158: (67) r2 <<= 32                   ; R2_w=scalar(smax=0x7fffffff00000000,umax=0xffffffff00000000,smin32=0,smax32=umax32=0,var_off=(0x0; 0xffffffff00000000))
159: (77) r2 >>= 32                   ; R2_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
160: (67) r2 <<= 2                    ; R2_w=scalar(smin=0,smax=umax=0x3fffffffc,smax32=0x7ffffffc,umax32=0xfffffffc,var_off=(0x0; 0x3fffffffc))
161: (0f) r0 += r2                    ; R0_w=map_value(map=sleep_hists,ks=4,vs=272,smin=0,smax=umax=0x3fffffffc,smax32=0x7ffffffc,umax32=0xfffffffc,var_off=(0x0; 0x3fffffffc)) R2_w=scalar(smin=0,smax=umax=0x3fffffffc,smax32=0x7ffffffc,umax32=0xfffffffc,var_off=(0x0; 0x3fffffffc))
162: (b7) r1 = 1                      ; R1_w=1
; __sync_fetch_and_add( @ rsched.bpf.c:444
163: (c3) lock *(u32 *)(r0 +0) += r1
R0 unbounded memory access, make sure to bounds check any such access
processed 93 insns (limit 1000000) max_states_per_insn 0 total_states 8 peak_states 8 mark_read 5
-- END PROG LOAD LOG --
libbpf: prog 'handle_sched_wakeup_btf': failed to load: -EACCES
libbpf: failed to load object 'rsched_bpf'
libbpf: failed to load BPF skeleton 'rsched_bpf': -EACCES
Error: Permission denied (os error 13)

Any help to debug this issue will be really appreciated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions