Re: [PATCH v2 5/5] samples/bpf: example of get selected PMU counter value

Alexei Starovoitov
2015-07-23T01:16:12Z

On 7/22/15 1:09 AM, Kaixu Xia wrote:
> +SEC("kprobe/sys_write")
> +int bpf_prog1(struct pt_regs *ctx)
> +{
> + u64 count;
> + u32 key = bpf_get_smp_processor_id();
> + char fmt[] = "bpf count: CPU-%d %llu\n";
> +
> + count = bpf_perf_event_read(&my_map, &key);
> + bpf_trace_printk(fmt, sizeof(fmt), key, count);
> +
> + return 0;
> +}

overall the whole thing looks much better, but since you can print
anything, print some sensible string here instead of 'bpf count'.

Thanks!