Re: [PATCH -next 1/2] perf stat: Increase perf_attr_map entries
From: Namhyung Kim
Date: Thu Sep 26 2024 - 00:16:43 EST
On Wed, Sep 25, 2024 at 01:55:22PM +0000, Tengda Wu wrote:
> bperf restricts the size of perf_attr_map's entries to 16, which
> cannot hold all events in many scenarios. A typical example is
> when the user specifies `-a -ddd` ([0]). And in other cases such as
> top-down analysis, which often requires a set of more than 16 PMUs
> to be collected simultaneously.
>
> Fix this by increase perf_attr_map entries to 100, and an event
> number check has been introduced when bperf__load() to ensure that
> users receive a more friendly prompt when the event limit is reached.
>
> [0] https://lore.kernel.org/all/20230104064402.1551516-3-namhyung@xxxxxxxxxx/
Apparently this patch was never applied. I don't know how much you need
but having too many events at the same time won't be very useful because
multiplexing could reduce the accuracy.
Thanks,
Namhyung
>
> Fixes: 7fac83aaf2ee ("perf stat: Introduce 'bperf' to share hardware PMCs with BPF")
> Signed-off-by: Tengda Wu <wutengda@xxxxxxxxxxxxxxx>
> ---
> tools/perf/util/bpf_counter.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c
> index 7a8af60e0f51..3346129c20cf 100644
> --- a/tools/perf/util/bpf_counter.c
> +++ b/tools/perf/util/bpf_counter.c
> @@ -28,7 +28,7 @@
> #include "bpf_skel/bperf_leader.skel.h"
> #include "bpf_skel/bperf_follower.skel.h"
>
> -#define ATTR_MAP_SIZE 16
> +#define ATTR_MAP_SIZE 100
>
> static inline void *u64_to_ptr(__u64 ptr)
> {
> @@ -451,6 +451,12 @@ static int bperf__load(struct evsel *evsel, struct target *target)
> enum bperf_filter_type filter_type;
> __u32 filter_entry_cnt, i;
>
> + if (evsel->evlist->core.nr_entries > ATTR_MAP_SIZE) {
> + pr_err("Too many events, please limit to %d or less\n",
> + ATTR_MAP_SIZE);
> + return -1;
> + }
> +
> if (bperf_check_target(evsel, target, &filter_type, &filter_entry_cnt))
> return -1;
>
> --
> 2.34.1
>