From: Jiri Olsa <jolsa@redhat.com>
To: Song Liu <song@kernel.org>
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
acme@kernel.org, acme@redhat.com, namhyung@kernel.org,
jolsa@kernel.org, songliubraving@fb.com
Subject: Re: [PATCH v2 3/3] perf-stat: introduce config stat.bpf-counter-events
Date: Thu, 8 Apr 2021 13:47:31 +0200 [thread overview]
Message-ID: <YG7tU/mVxQZLNCYL@krava> (raw)
In-Reply-To: <20210407003601.619158-4-song@kernel.org>
On Tue, Apr 06, 2021 at 05:36:01PM -0700, Song Liu 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. This is limited to hardware events in
> evsel__hw_names.
>
> 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
>
so if we are mixing events now, how about uing modifier for bpf counters,
instead of configuring .perfconfig list we could use:
perf stat -e instructions:b,cs
thoughts?
the change below adds 'b' modifier and sets 'evsel::bpf_counter',
feel free to use it
jirka
---
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index ca52581f1b17..c55e4e58d1dc 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -82,6 +82,7 @@ struct evsel {
bool auto_merge_stats;
bool collect_stat;
bool weak_group;
+ bool bpf_counter;
int bpf_fd;
struct bpf_object *bpf_obj;
};
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 9ecb45bea948..b5850f1ea90b 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1801,6 +1801,7 @@ struct event_modifier {
int pinned;
int weak;
int exclusive;
+ int bpf_counter;
};
static int get_event_modifier(struct event_modifier *mod, char *str,
@@ -1821,6 +1822,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
int exclude = eu | ek | eh;
int exclude_GH = evsel ? evsel->exclude_GH : 0;
int weak = 0;
+ int bpf_counter = 0;
memset(mod, 0, sizeof(*mod));
@@ -1864,6 +1866,8 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
exclusive = 1;
} else if (*str == 'W') {
weak = 1;
+ } else if (*str == 'b') {
+ bpf_counter = 1;
} else
break;
@@ -1895,6 +1899,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
mod->sample_read = sample_read;
mod->pinned = pinned;
mod->weak = weak;
+ mod->bpf_counter = bpf_counter;
mod->exclusive = exclusive;
return 0;
@@ -1909,7 +1914,7 @@ static int check_modifier(char *str)
char *p = str;
/* The sizeof includes 0 byte as well. */
- if (strlen(str) > (sizeof("ukhGHpppPSDIWe") - 1))
+ if (strlen(str) > (sizeof("ukhGHpppPSDIWeb") - 1))
return -1;
while (*p) {
@@ -1950,6 +1955,7 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add)
evsel->sample_read = mod.sample_read;
evsel->precise_max = mod.precise_max;
evsel->weak_group = mod.weak;
+ evsel->bpf_counter = mod.bpf_counter;
if (evsel__is_group_leader(evsel)) {
evsel->core.attr.pinned = mod.pinned;
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 0b36285a9435..fb8646cc3e83 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -210,7 +210,7 @@ name_tag [\'][a-zA-Z_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=]*[\']
name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
drv_cfg_term [a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
/* If you add a modifier you need to update check_modifier() */
-modifier_event [ukhpPGHSDIWe]+
+modifier_event [ukhpPGHSDIWeb]+
modifier_bp [rwx]{1,3}
%%
next prev parent reply other threads:[~2021-04-08 11:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-07 0:35 [PATCH v2 0/3] perf util: bpf perf improvements Song Liu
2021-04-07 0:35 ` [PATCH v2 1/3] perf util: move bpf_perf definitions to a libperf header Song Liu
2021-04-07 0:36 ` [PATCH v2 2/3] perf bpf: check perf_attr_map is compatible with the perf binary Song Liu
2021-04-07 0:36 ` [PATCH v2 3/3] perf-stat: introduce config stat.bpf-counter-events Song Liu
2021-04-08 11:47 ` Jiri Olsa [this message]
2021-04-08 16:39 ` Song Liu
2021-04-08 17:19 ` Arnaldo Carvalho de Melo
2021-04-08 17:20 ` Jiri Olsa
2021-04-08 17:28 ` Song Liu
2021-04-08 17:45 ` Jiri Olsa
2021-04-08 18:08 ` Song Liu
2021-04-08 18:24 ` Jiri Olsa
2021-04-08 18:50 ` Arnaldo Carvalho de Melo
2021-04-08 19:41 ` Song Liu
2021-04-08 19:46 ` 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=YG7tU/mVxQZLNCYL@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@fb.com \
--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
all inboxes | Powered by JetHome®