So I fixed the error above by using "count = my_map.perf_read(key);" as opposed to "count = bpf_perf_event_read(&my_map, key);". However, how do I selectively enable counters (e.g. instructions, cache misses, etc.)?
Thanks, Riya On Mon, Jul 25, 2016 at 9:58 AM, riya khanna <[email protected]> wrote: > 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; > > } > > """ _______________________________________________ iovisor-dev mailing list [email protected] https://lists.iovisor.org/mailman/listinfo/iovisor-dev
