Skip to content

Commit 3a0f56d

Browse files
captain5050acmel
authored andcommitted
perf bpf-filter: Fix opts declaration on older libbpfs
Building perf with LIBBPF_DYNAMIC (ie not the default static linking of libbpf with perf) is breaking as the libbpf isn't version 1.7 or newer, where dont_enable is added to bpf_perf_event_opts. To avoid this breakage add a compile time version check and don't declare the variable when not present. Fixes: 5e2ac8e ("perf bpf-filter: Enable events manually") Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: bpf@vger.kernel.org Cc: Hao Ge <gehao@kylinos.cn> Cc: Ilya Leoshkevich <iii@linux.ibm.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Richter <tmricht@linux.ibm.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 0dc96ca commit 3a0f56d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tools/perf/util/bpf-filter.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ static int create_idx_hash(struct evsel *evsel, struct perf_bpf_filter_entry *en
443443
return -1;
444444
}
445445

446+
#define LIBBPF_CURRENT_VERSION_GEQ(major, minor) \
447+
(LIBBPF_MAJOR_VERSION > (major) || \
448+
(LIBBPF_MAJOR_VERSION == (major) && LIBBPF_MINOR_VERSION >= (minor)))
449+
446450
int perf_bpf_filter__prepare(struct evsel *evsel, struct target *target)
447451
{
448452
int i, x, y, fd, ret;
@@ -451,8 +455,12 @@ int perf_bpf_filter__prepare(struct evsel *evsel, struct target *target)
451455
struct bpf_link *link;
452456
struct perf_bpf_filter_entry *entry;
453457
bool needs_idx_hash = !target__has_cpu(target);
458+
#if LIBBPF_CURRENT_VERSION_GEQ(1, 7)
454459
DECLARE_LIBBPF_OPTS(bpf_perf_event_opts, pe_opts,
455460
.dont_enable = true);
461+
#else
462+
DECLARE_LIBBPF_OPTS(bpf_perf_event_opts, pe_opts);
463+
#endif
456464

457465
entry = calloc(MAX_FILTERS, sizeof(*entry));
458466
if (entry == NULL)

0 commit comments

Comments
 (0)