Skip to content

libbpf-tools: filelife: Fix problem when using perf-buffer#5432

Merged
ekyooo merged 1 commit intoiovisor:masterfrom
Rtoax:patch-106-filelife-fallback-perf_buffer
Dec 11, 2025
Merged

libbpf-tools: filelife: Fix problem when using perf-buffer#5432
ekyooo merged 1 commit intoiovisor:masterfrom
Rtoax:patch-106-filelife-fallback-perf_buffer

Conversation

@Rtoax
Copy link
Contributor

@Rtoax Rtoax commented Dec 4, 2025

@ekyooo When ring buffers are not supported, will fallback to perf-buffer. The map type is set for the perf buffer in bpf_buffer__new(). This setting must be done before the BPF program is loaded. Otherwise, BPF_MAP_TYPE_RINGBUF will be used in bpf_perf_event_output(), resulting in the following error message:

; return bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, buf, size); @ compat.bpf.h:46
136: (79) r1 = *(u64 *)(r10 -40)      ; R1_w=ctx() R10=fp0 fp-40=ctx()
137: (18) r2 = 0xffff8bd101623c00     ; R2_w=map_ptr(map=events,ks=0,vs=0)
139: (18) r3 = 0xffffffff             ; R3_w=0xffffffff
141: (bf) r4 = r7                     ; R4_w=map_value(map=heap,ks=4,vs=10240) R7=map_value(map=heap,ks=4,vs=10240)
142: (b7) r5 = 8200                   ; R5_w=8200
143: (85) call bpf_perf_event_output#25
cannot pass map_type 27 into func bpf_perf_event_output#25

map_type 27 is BPF_MAP_TYPE_RINGBUF.

At the same time, I also moved the notification message (Tracing...) to after all steps were successful.

When ring buffers are not supported, will fallback to perf-buffer. The
map type is set for the perf buffer in `bpf_buffer__new()`. This setting
must be done before the BPF program is loaded. Otherwise,
`BPF_MAP_TYPE_RINGBUF` will be used in `bpf_perf_event_output()`,
resulting in the following error message:

    ; return bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, buf, size); @ compat.bpf.h:46
    136: (79) r1 = *(u64 *)(r10 -40)      ; R1_w=ctx() R10=fp0 fp-40=ctx()
    137: (18) r2 = 0xffff8bd101623c00     ; R2_w=map_ptr(map=events,ks=0,vs=0)
    139: (18) r3 = 0xffffffff             ; R3_w=0xffffffff
    141: (bf) r4 = r7                     ; R4_w=map_value(map=heap,ks=4,vs=10240) R7=map_value(map=heap,ks=4,vs=10240)
    142: (b7) r5 = 8200                   ; R5_w=8200
    143: (85) call bpf_perf_event_output#25
    cannot pass map_type 27 into func bpf_perf_event_output#25

map_type 27 is BPF_MAP_TYPE_RINGBUF.

At the same time, I also moved the notification message (Tracing...) to
after all steps were successful.

Signed-off-by: Rong Tao <rongtao@cestc.cn>
Copy link
Collaborator

@ekyooo ekyooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks

@ekyooo ekyooo merged commit ec8415b into iovisor:master Dec 11, 2025
1 of 12 checks passed
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

Successfully merging this pull request may close these issues.

2 participants