From: Jiri Olsa <jolsa@redhat.com>
To: Song Liu <songliubraving@fb.com>
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
namhyung@kernel.org
Subject: Re: [RFC 2/2] perf-stat: enable counting events for BPF programs
Date: Tue, 24 Nov 2020 20:51:08 +0100 [thread overview]
Message-ID: <20201124195108.GB2164284@krava> (raw)
In-Reply-To: <20201119045046.1491106-3-songliubraving@fb.com>
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
next prev parent reply other threads:[~2020-11-24 19:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-19 4:50 [RFC 0/2] Introduce perf-stat -b for BPF programs Song Liu
2020-11-19 4:50 ` [RFC 1/2] perf: support build BPF skeletons with perf Song Liu
2020-11-22 23:27 ` Jiri Olsa
2020-11-24 23:47 ` Song Liu
2020-11-25 16:38 ` Jiri Olsa
2020-11-22 23:32 ` Jiri Olsa
2020-11-24 23:51 ` Song Liu
2020-11-22 23:35 ` Jiri Olsa
2020-11-24 23:52 ` Song Liu
2020-11-25 16:40 ` Jiri Olsa
2020-11-24 19:51 ` Jiri Olsa
2020-11-24 23:59 ` Song Liu
2020-11-24 19:51 ` Jiri Olsa
2020-11-24 23:53 ` Song Liu
2020-11-19 4:50 ` [RFC 2/2] perf-stat: enable counting events for BPF programs Song Liu
2020-11-23 23:47 ` Jiri Olsa
2020-11-24 23:31 ` Song Liu
2020-11-25 16:42 ` Jiri Olsa
2020-11-24 19:51 ` Jiri Olsa [this message]
2020-11-24 23:43 ` Song Liu
2020-11-25 0:02 ` Song Liu
2020-11-25 16:43 ` Jiri Olsa
2020-11-19 14:52 ` [RFC 0/2] Introduce perf-stat -b " Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201124195108.GB2164284@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=songliubraving@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox