This needs support in bcc. I had a patch laying around that I never finished, you can find the partial support here: https://github.com/iovisor/bcc/tree/perf-counter
It shouldn't be too hard to finalize that, let me see what I can do. On Mon, Jul 25, 2016 at 4:11 PM, riya khanna via iovisor-dev < [email protected]> wrote: > 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 >
_______________________________________________ iovisor-dev mailing list [email protected] https://lists.iovisor.org/mailman/listinfo/iovisor-dev
