* [RFC PATCH] perf stat: Separate bperf from bpf_profiler
@ 2023-04-12 18:23 Dmitrii Dolgov
2023-04-21 20:56 ` Dmitry Dolgov
0 siblings, 1 reply; 5+ messages in thread
From: Dmitrii Dolgov @ 2023-04-12 18:23 UTC (permalink / raw)
To: linux-perf-users, acme, mingo, jolsa, namhyung, irogers; +Cc: Dmitrii Dolgov
It seems that perf stat -b <prog id> doesn't produce any results:
$ perf stat -e cycles -b 4 -I 10000 -vvv
Control descriptor is not initialized
cycles: 0 0 0
time counts unit events
10.007641640 <not supported> cycles
Looks like this happens because fentry/fexit progs are getting loaded, but the
corresponding perf event is not enabled and not added into the events bpf map.
I think there is some mixing up between two type of bpf support, one for bperf
and one for bpf_profiler. Both are identified via evsel__is_bpf, based on which
perf events are enabled, but for the latter (bpf_profiler) a perf event is
required. Using evsel__is_bperf to check only bperf produces expected results:
$ perf stat -e cycles -b 4 -I 10000 -vvv
Control descriptor is not initialized
------------------------------------------------------------
perf_event_attr:
size 136
sample_type IDENTIFIER
read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
disabled 1
exclude_guest 1
------------------------------------------------------------
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 3
------------------------------------------------------------
[...perf_event_attr for other CPUs...]
------------------------------------------------------------
cycles: 309426 169009 169009
time counts unit events
10.010091271 309426 cycles
The final numbers correspond (at least in the level of magnitude) to the
same metric obtained via bpftool.
Signed-off-by: Dmitrii Dolgov <9erthalion6@gmail.com>
---
tools/perf/builtin-stat.c | 4 ++--
tools/perf/util/evsel.h | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index d3cbee7460f..23b8d684ca6 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -712,7 +712,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
counter->reset_group = false;
if (bpf_counter__load(counter, &target))
return -1;
- if (!evsel__is_bpf(counter))
+ if (!(evsel__is_bperf(counter)))
all_counters_use_bpf = false;
}
@@ -728,7 +728,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
if (counter->reset_group || counter->errored)
continue;
- if (evsel__is_bpf(counter))
+ if (evsel__is_bperf(counter))
continue;
try_again:
if (create_perf_stat_counter(counter, &stat_config, &target,
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 68072ec655c..f0aa17dcf3d 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -269,6 +269,11 @@ static inline bool evsel__is_bpf(struct evsel *evsel)
return evsel->bpf_counter_ops != NULL;
}
+static inline bool evsel__is_bperf(struct evsel *evsel)
+{
+ return evsel->bpf_counter_ops != NULL && list_empty(&evsel->bpf_counter_list);
+}
+
#define EVSEL__MAX_ALIASES 8
extern const char *const evsel__hw_cache[PERF_COUNT_HW_CACHE_MAX][EVSEL__MAX_ALIASES];
--
2.32.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC PATCH] perf stat: Separate bperf from bpf_profiler
2023-04-12 18:23 [RFC PATCH] perf stat: Separate bperf from bpf_profiler Dmitrii Dolgov
@ 2023-04-21 20:56 ` Dmitry Dolgov
2023-04-29 1:44 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Dolgov @ 2023-04-21 20:56 UTC (permalink / raw)
To: linux-perf-users, acme, mingo, jolsa, namhyung, irogers
> On Wed, Apr 12, 2023 at 08:23:16PM +0200, Dmitrii Dolgov wrote:
> It seems that perf stat -b <prog id> doesn't produce any results:
>
> $ perf stat -e cycles -b 4 -I 10000 -vvv
> Control descriptor is not initialized
> cycles: 0 0 0
> time counts unit events
> 10.007641640 <not supported> cycles
>
> Looks like this happens because fentry/fexit progs are getting loaded, but the
> corresponding perf event is not enabled and not added into the events bpf map.
> I think there is some mixing up between two type of bpf support, one for bperf
> and one for bpf_profiler. Both are identified via evsel__is_bpf, based on which
> perf events are enabled, but for the latter (bpf_profiler) a perf event is
> required. Using evsel__is_bperf to check only bperf produces expected results:
Any thoughts on this? I would appreciate clarifications if I'm missing
something.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH] perf stat: Separate bperf from bpf_profiler
2023-04-21 20:56 ` Dmitry Dolgov
@ 2023-04-29 1:44 ` Arnaldo Carvalho de Melo
2023-05-05 2:01 ` Song Liu
0 siblings, 1 reply; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-04-29 1:44 UTC (permalink / raw)
To: Namhyung Kim, Song Liu
Cc: Dmitry Dolgov, linux-perf-users, Linux Kernel Mailing List,
mingo, jolsa, namhyung, irogers
Em Fri, Apr 21, 2023 at 10:56:10PM +0200, Dmitry Dolgov escreveu:
> > On Wed, Apr 12, 2023 at 08:23:16PM +0200, Dmitrii Dolgov wrote:
> > It seems that perf stat -b <prog id> doesn't produce any results:
> >
> > $ perf stat -e cycles -b 4 -I 10000 -vvv
> > Control descriptor is not initialized
> > cycles: 0 0 0
> > time counts unit events
> > 10.007641640 <not supported> cycles
> >
> > Looks like this happens because fentry/fexit progs are getting loaded, but the
> > corresponding perf event is not enabled and not added into the events bpf map.
> > I think there is some mixing up between two type of bpf support, one for bperf
> > and one for bpf_profiler. Both are identified via evsel__is_bpf, based on which
> > perf events are enabled, but for the latter (bpf_profiler) a perf event is
> > required. Using evsel__is_bperf to check only bperf produces expected results:
>
> Any thoughts on this? I would appreciate clarifications if I'm missing
> something.
Namhyung, Song, can you please take a look at this?
- Arnaldo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH] perf stat: Separate bperf from bpf_profiler
2023-04-29 1:44 ` Arnaldo Carvalho de Melo
@ 2023-05-05 2:01 ` Song Liu
2023-05-05 20:32 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 5+ messages in thread
From: Song Liu @ 2023-05-05 2:01 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Namhyung Kim, Song Liu, Dmitry Dolgov, linux-perf-users,
Linux Kernel Mailing List, mingo, jolsa, irogers
On Fri, Apr 28, 2023 at 6:44 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Fri, Apr 21, 2023 at 10:56:10PM +0200, Dmitry Dolgov escreveu:
> > > On Wed, Apr 12, 2023 at 08:23:16PM +0200, Dmitrii Dolgov wrote:
> > > It seems that perf stat -b <prog id> doesn't produce any results:
> > >
> > > $ perf stat -e cycles -b 4 -I 10000 -vvv
> > > Control descriptor is not initialized
> > > cycles: 0 0 0
> > > time counts unit events
> > > 10.007641640 <not supported> cycles
> > >
> > > Looks like this happens because fentry/fexit progs are getting loaded, but the
> > > corresponding perf event is not enabled and not added into the events bpf map.
> > > I think there is some mixing up between two type of bpf support, one for bperf
> > > and one for bpf_profiler. Both are identified via evsel__is_bpf, based on which
> > > perf events are enabled, but for the latter (bpf_profiler) a perf event is
> > > required. Using evsel__is_bperf to check only bperf produces expected results:
> >
> > Any thoughts on this? I would appreciate clarifications if I'm missing
> > something.
>
> Namhyung, Song, can you please take a look at this?
Sorry for the late response. The fix looks good to me and worked well
in my test.
Reviewed-and-tested-by: Song Liu <song@kernel.org>
I guess we also need:
Fixes: 112cb56164bc2 ("perf stat: Introduce config stat.bpf-counter-events")
Thanks for the fix!
Song
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH] perf stat: Separate bperf from bpf_profiler
2023-05-05 2:01 ` Song Liu
@ 2023-05-05 20:32 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-05-05 20:32 UTC (permalink / raw)
To: Dmitry Dolgov, Song Liu
Cc: Namhyung Kim, Song Liu, linux-perf-users,
Linux Kernel Mailing List, mingo, jolsa, irogers
Em Thu, May 04, 2023 at 07:01:04PM -0700, Song Liu escreveu:
> On Fri, Apr 28, 2023 at 6:44 PM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > Em Fri, Apr 21, 2023 at 10:56:10PM +0200, Dmitry Dolgov escreveu:
> > > > On Wed, Apr 12, 2023 at 08:23:16PM +0200, Dmitrii Dolgov wrote:
> > > > It seems that perf stat -b <prog id> doesn't produce any results:
> > > > $ perf stat -e cycles -b 4 -I 10000 -vvv
> > > > Control descriptor is not initialized
> > > > cycles: 0 0 0
> > > > time counts unit events
> > > > 10.007641640 <not supported> cycles
> > > > Looks like this happens because fentry/fexit progs are getting loaded, but the
> > > > corresponding perf event is not enabled and not added into the events bpf map.
> > > > I think there is some mixing up between two type of bpf support, one for bperf
> > > > and one for bpf_profiler. Both are identified via evsel__is_bpf, based on which
> > > > perf events are enabled, but for the latter (bpf_profiler) a perf event is
> > > > required. Using evsel__is_bperf to check only bperf produces expected results:
> > > Any thoughts on this? I would appreciate clarifications if I'm missing
> > > something.
> > Namhyung, Song, can you please take a look at this?
> Sorry for the late response. The fix looks good to me and worked well
> in my test.
> Reviewed-and-tested-by: Song Liu <song@kernel.org>
> I guess we also need:
> Fixes: 112cb56164bc2 ("perf stat: Introduce config stat.bpf-counter-events")
Thanks a lot, applied, and this is relevant in the current situation,
where we're trying to have Linux v6.4 perf tools building BPF skels by
default.
- Arnaldo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-05-05 20:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12 18:23 [RFC PATCH] perf stat: Separate bperf from bpf_profiler Dmitrii Dolgov
2023-04-21 20:56 ` Dmitry Dolgov
2023-04-29 1:44 ` Arnaldo Carvalho de Melo
2023-05-05 2:01 ` Song Liu
2023-05-05 20:32 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.