From: Jiri Olsa <jolsa@redhat.com>
To: Song Liu <songliubraving@fb.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
Kernel Team <Kernel-team@fb.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"mingo@redhat.com" <mingo@redhat.com>,
"acme@kernel.org" <acme@kernel.org>,
"mark.rutland@arm.com" <mark.rutland@arm.com>,
"alexander.shishkin@linux.intel.com"
<alexander.shishkin@linux.intel.com>,
"namhyung@kernel.org" <namhyung@kernel.org>
Subject: Re: [PATCH v2 2/2] perf-stat: enable counting events for BPF programs
Date: Wed, 9 Dec 2020 16:55:52 +0100 [thread overview]
Message-ID: <20201209155552.GC69683@krava> (raw)
In-Reply-To: <C94864E9-CE05-4AEA-A986-731BFC0C95FF@fb.com>
On Tue, Dec 08, 2020 at 01:36:57AM +0000, Song Liu wrote:
SNIP
> > SNIP
> >
> >> +static int bpf_program_profiler__read(struct evsel *evsel)
> >> +{
> >> + int num_cpu = evsel__nr_cpus(evsel);
> >> + struct bpf_perf_event_value values[num_cpu];
> >> + struct bpf_counter *counter;
> >> + int reading_map_fd;
> >> + __u32 key = 0;
> >> + int err, cpu;
> >> +
> >> + if (list_empty(&evsel->bpf_counter_list))
> >> + return -EAGAIN;
> >> +
> >> + for (cpu = 0; cpu < num_cpu; cpu++) {
> >> + perf_counts(evsel->counts, cpu, 0)->val = 0;
> >> + perf_counts(evsel->counts, cpu, 0)->ena = 0;
> >> + perf_counts(evsel->counts, cpu, 0)->run = 0;
> >> + }
> >> + list_for_each_entry(counter, &evsel->bpf_counter_list, list) {
> >> + struct bpf_prog_profiler_bpf *skel = counter->skel;
> >> +
> >> + reading_map_fd = bpf_map__fd(skel->maps.accum_readings);
> >> +
> >> + err = bpf_map_lookup_elem(reading_map_fd, &key, values);
> >> + if (err) {
> >> + fprintf(stderr, "failed to read value\n");
> >> + return err;
> >> + }
> >> +
> >> + for (cpu = 0; cpu < num_cpu; cpu++) {
> >> + perf_counts(evsel->counts, cpu, 0)->val += values[cpu].counter;
> >> + perf_counts(evsel->counts, cpu, 0)->ena += values[cpu].enabled;
> >> + perf_counts(evsel->counts, cpu, 0)->run += values[cpu].running;
> >> + }
> >
> > so we sum everything up for all provided bpf IDs,
> > should we count/display them separately?
>
> I think that's the default behavior with --pid x,y,z or --cpu a,b,c.
> Do we need to separate them?
ah right, and we have --per-thread that splits the output
for specified pids
I think we should add something like that for bpf, so we
could see stats for specific programs
it's ok to do this as a follow up patch in future
thanks,
jirka
prev parent reply other threads:[~2020-12-09 15:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-04 6:13 [PATCH v2 0/2] Introduce perf-stat -b for BPF programs Song Liu
2020-12-04 6:13 ` [PATCH v2 1/2] perf: support build BPF skeletons with perf Song Liu
2020-12-07 20:25 ` Jiri Olsa
2020-12-08 0:59 ` Song Liu
2020-12-04 6:13 ` [PATCH v2 2/2] perf-stat: enable counting events for BPF programs Song Liu
2020-12-07 22:07 ` Jiri Olsa
2020-12-08 1:36 ` Song Liu
2020-12-08 10:24 ` Jiri Olsa
2020-12-08 18:16 ` Song Liu
2020-12-09 15:55 ` Jiri Olsa [this message]
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=20201209155552.GC69683@krava \
--to=jolsa@redhat.com \
--cc=Kernel-team@fb.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.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;
as well as URLs for NNTP newsgroup(s).