From: Jiri Olsa <jolsa@redhat.com>
To: Song Liu <songliubraving@fb.com>
Cc: Namhyung Kim <namhyung@kernel.org>, Song Liu <song@kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Kernel Team <Kernel-team@fb.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH v3 3/4] perf-stat: introduce config stat.bpf-counter-events
Date: Tue, 20 Apr 2021 19:30:43 +0200 [thread overview]
Message-ID: <YH8Pw4m0w6DuuEXo@krava> (raw)
In-Reply-To: <71CC9E29-ECBD-47DB-AE85-1477BF54C45D@fb.com>
On Mon, Apr 19, 2021 at 08:26:02PM +0000, Song Liu wrote:
>
>
> > On Apr 17, 2021, at 9:45 AM, Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > Hi Song,
> >
> > On Sat, Apr 17, 2021 at 7:13 AM Song Liu <song@kernel.org> wrote:
> >>
> >> Currently, to use BPF to aggregate perf event counters, the user uses
> >> --bpf-counters option. Enable "use bpf by default" events with a config
> >> option, stat.bpf-counter-events. Events with name in the option will use
> >> BPF.
> >>
> >> This also enables mixed BPF event and regular event in the same sesssion.
> >> For example:
> >>
> >> perf config stat.bpf-counter-events=instructions
> >> perf stat -e instructions,cs
> >>
> >> The second command will use BPF for "instructions" but not "cs".
> >>
> >> Signed-off-by: Song Liu <song@kernel.org>
> >> ---
> >> @@ -535,12 +549,13 @@ static int enable_counters(void)
> >> struct evsel *evsel;
> >> int err;
> >>
> >> - if (target__has_bpf(&target)) {
> >> - evlist__for_each_entry(evsel_list, evsel) {
> >> - err = bpf_counter__enable(evsel);
> >> - if (err)
> >> - return err;
> >> - }
> >> + evlist__for_each_entry(evsel_list, evsel) {
> >> + if (!evsel__is_bpf(evsel))
> >> + continue;
> >> +
> >> + err = bpf_counter__enable(evsel);
> >> + if (err)
> >> + return err;
> >
> > I just realized it doesn't have a disable counterpart.
>
> I guess it is not really necessary for perf-stat? It is probably good
> to have it though. How about we do it in a follow up patch?
good catch, should it at least do:
evsel->follower_skel->bss->enabled = 0;
because then the follower goes down only with perf process, right?
still doing the counts till the end..?
also while checking on that I realized we open the counters
in separate path for this in bperf_reload_leader_program by
calling evsel__open_per_cpu.. and we're missing all the
fallback code and setup from create_perf_stat_counter
I think we should at least call create_perf_stat_counter,
and also propagate error value if it fails
jirka
>
> [...]
>
> >> + if (!evsel__bpf_counter_events)
> >> + return false;
> >> +
> >> + ptr = strstr(evsel__bpf_counter_events, name);
> >> + name_len = strlen(name);
> >> +
> >> + /* check name matches a full token in evsel__bpf_counter_events */
> >> + match = (ptr != NULL) &&
> >> + ((ptr == evsel__bpf_counter_events) || (*(ptr - 1) == ',')) &&
> >> + ((*(ptr + name_len) == ',') || (*(ptr + name_len) == '\0'));
> >
> > I'm not sure we have an event name which is a substring of another.
> > Maybe it can retry if it fails to match.
>
> We have ref-cycles and cycles. And some raw events may be substring of others?
>
> Thanks,
> Song
>
> [...]
>
next prev parent reply other threads:[~2021-04-20 17:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-16 22:13 [PATCH v3 0/4] perf util: bpf perf improvements Song Liu
2021-04-16 22:13 ` [PATCH v3 1/4] perf util: move bpf_perf definitions to a libperf header Song Liu
2021-04-16 22:13 ` [PATCH v3 2/4] perf bpf: check perf_attr_map is compatible with the perf binary Song Liu
2021-04-16 22:13 ` [PATCH v3 3/4] perf-stat: introduce config stat.bpf-counter-events Song Liu
2021-04-17 16:45 ` Namhyung Kim
2021-04-19 20:26 ` Song Liu
2021-04-20 17:30 ` Jiri Olsa [this message]
2021-04-19 14:26 ` Jiri Olsa
2021-04-19 20:27 ` Song Liu
2021-04-16 22:13 ` [PATCH v3 4/4] perf-stat: introduce ':b' modifier Song Liu
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=YH8Pw4m0w6DuuEXo@krava \
--to=jolsa@redhat.com \
--cc=Kernel-team@fb.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=song@kernel.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