lkml.org 
[lkml]   [2020]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC 2/2] perf-stat: enable counting events for BPF programs
On Wed, Nov 18, 2020 at 08:50:46PM -0800, Song Liu wrote:

SNIP

> +static int bpf_program_profiler__install_pe(struct evsel *evsel, int cpu,
> + int fd)
> +{
> + struct bpf_prog_profiler_bpf *skel = evsel->bpf_counter.skel;
> +
> + return bpf_map_update_elem(bpf_map__fd(skel->maps.events),
> + &cpu, &fd, BPF_ANY);
> +}
> +
> +struct bpf_counter_ops bpf_program_profiler_ops = {
> + .load = bpf_program_profiler__load,
> + .enable = bpf_program_profiler__enable,
> + .read = bpf_program_profiler__read,
> + .destroy = bpf_program_profiler__destroy,
> + .install_pe = bpf_program_profiler__install_pe,
> +};

hum, what's the point of this ops? you plan some other ops?
we could just define stat callbacks right?

> +SEC("fentry/XXX")
> +int BPF_PROG(fentry_XXX)
> +{
> + u32 key = bpf_get_smp_processor_id();
> + struct bpf_perf_event_value reading;
> + struct bpf_perf_event_value *ptr;
> + u32 zero = 0;
> + long err;
> +
> + /* look up before reading, to reduce error */
> + ptr = bpf_map_lookup_elem(&fentry_readings, &zero);
> + if (!ptr)
> + return 0;
> +
> + err = bpf_perf_event_read_value(&events, key, &reading,
> + sizeof(reading));
> + if (err)
> + return 0;
> +
> + *ptr = reading;
> + return 0;
> +}

so currently it's one extra bpf program for each event,
but it seems bad for multiple events stat.. could we
just have one program that would read and process all events?

thanks,
jirka

\
 
 \ /
  Last update: 2020-11-24 20:53    [W:0.212 / U:1.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site