Hi,
I'm trying to read perf counters using bpf. However, adding
BPF_PERF_ARRAY reports error:
bpf: Invalid argument
unrecognized bpf_ld_imm64 inns
Is there an example/sample to read perf counters that I can follow?
The code below is what I'm trying to execute.
Thanks,
Riya
# load BPF program
bpf_text = """
#include <uapi/linux/ptrace.h>
BPF_PERF_ARRAY(my_map, 32);
int start_counting(struct pt_regs *ctx) {
if (!PT_REGS_PARM1(ctx))
return 0;
u64 count;
u32 key = bpf_get_smp_processor_id();
count = bpf_perf_event_read(&my_map, key);
bpf_trace_printk("CPU-%d %llu", key, count);
return 0;
}
"""