linux/tools/perf/util/bpf_skel/bperf_cgroup.h
Ian Rogers be806f06ad perf stat: Add/fix bperf cgroup max events workarounds
Commit b8308511f6 bumped the max events to 1024 but this results in
BPF verifier issues if the number of command line events is too
large. Workaround this by:

1) moving the constants to a header file to share between BPF and perf
   C code,
2) testing that the maximum number of events doesn't cause BPF
   verifier issues in debug builds,
3) lower the max events from 1024 to 128,
4) in perf stat, if there are more events than the BPF counters can
   support then disable BPF counter usage.

The rodata setup is factored into its own function to avoid
duplicating it in the testing code.

Signed-off-by: Ian Rogers <irogers@google.com>
Fixes: b8308511f6 ("perf stat bperf cgroup: Increase MAX_EVENTS from 32 to 1024")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2025-10-25 16:44:21 -07:00

16 lines
568 B
C

/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
/* Data structures shared between BPF and tools. */
#ifndef __BPERF_CGROUP_H
#define __BPERF_CGROUP_H
// These constants impact code size of bperf_cgroup.bpf.c that may result in BPF
// verifier issues. They are exposed to control the size and also to disable BPF
// counters when the number of user events is too large.
// max cgroup hierarchy level: arbitrary
#define BPERF_CGROUP__MAX_LEVELS 10
// max events per cgroup: arbitrary
#define BPERF_CGROUP__MAX_EVENTS 128
#endif /* __BPERF_CGROUP_H */