Skip to contentSkip to conversation

LIBBPF_DYNAMIC=1 fixes

PATCH In review Arnaldo Carvalho de Melo 3 participants 9 messages Sep 19, 2025 – Oct 1, 2025 perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

cover LIBBPF_DYNAMIC=1 fixes

Hi,

Please take a look, noticed after processing a patch from Ian
for another such issue, on a hurry now, haven't checked when that emit_string was introduced.

- Arnaldo

Arnaldo Carvalho de Melo (2):
perf bpf: Move the LIBBPF_CURRENT_VERSION_GEQ macro to bpf-utils.h perf bpf: Check libbpf version to use
btf_dump_type_data_opts.emit_strings

 tools/perf/util/bpf-event.c  | 2 ++
 tools/perf/util/bpf-filter.c | 5 +----
 tools/perf/util/bpf-utils.h  | 5 +++++
 3 files changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.51.0
author maintainer
#1 lore raw

PATCH 1/2 perf bpf: Move the LIBBPF_CURRENT_VERSION_GEQ macro to bpf-utils.h

From: Arnaldo Carvalho de Melo <[email protected]>

We need it to fix some other libbpf version dependent issues when building with LIBBPF_DINAMYC=1

Cc Adrian Hunter <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Ian Rogers <[email protected]>
Cc James Clark <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/util/bpf-filter.c | 5 +----
 tools/perf/util/bpf-utils.h  | 5 +++++
 2 files changed, 6 insertions(+), 4 deletions(-)
tools/perf/util/bpf-filter.c +1 -4
index 92308c38fbb567ba..1a2e7b388d57d367 100644
@@ -56,6 +56,7 @@
 #include "util/debug.h"
 #include "util/evsel.h"
 #include "util/target.h"
+#include "util/bpf-utils.h"
 
 #include "util/bpf-filter.h"
 #include <util/bpf-filter-flex.h>
@@ -443,10 +444,6 @@ static int create_idx_hash(struct evsel *evsel, struct perf_bpf_filter_entry *en
 	return -1;
 }
 
-#define LIBBPF_CURRENT_VERSION_GEQ(major, minor)			\
-	(LIBBPF_MAJOR_VERSION > (major) ||				\
-	 (LIBBPF_MAJOR_VERSION == (major) && LIBBPF_MINOR_VERSION >= (minor)))
-
 int perf_bpf_filter__prepare(struct evsel *evsel, struct target *target)
 {
 	int i, x, y, fd, ret;
tools/perf/util/bpf-utils.h +5 -0
index 86a5055cdfad6689..eafc43b8731f1e31 100644
@@ -8,6 +8,11 @@
 #ifdef HAVE_LIBBPF_SUPPORT
 
 #include <bpf/libbpf.h>
+#include <bpf/libbpf_version.h>
+
+#define LIBBPF_CURRENT_VERSION_GEQ(major, minor)                       \
+       (LIBBPF_MAJOR_VERSION > (major) ||                              \
+        (LIBBPF_MAJOR_VERSION == (major) && LIBBPF_MINOR_VERSION >= (minor)))
 
 /*
  * Get bpf_prog_info in continuous memory
Signature · 1 line
2.51.0
author maintainer
#3 lore raw

PATCH 2/2 perf bpf: Check libbpf version to use btf_dump_type_data_opts.emit_strings

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

When building perf with LIBBPF_DINAMIC=1 on a fedora system with libbpf-devel 1.5 I it was breaking with:

util/bpf-event.c: In function ‘format_btf_variable’:
util/bpf-event.c:291:18: error: ‘const struct btf_dump_type_data_opts’ has no member named ‘emit_strings’
291 | .emit_strings = 1,

      |                  ^~~~~~~~~~~~

util/bpf-event.c:291:33: error: initialized field overwritten [-Werror=override-init]
291 | .emit_strings = 1,
| ^
util/bpf-event.c:291:33: note: (near initialization for ‘opts.skip_names’)

Check the version before using that feature.

Cc Adrian Hunter <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Ian Rogers <[email protected]>
Cc James Clark <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/util/bpf-event.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/bpf-event.c +2 -0
index 2298cd396c4235e2..59f84aef91b4a2ec 100644
@@ -288,7 +288,9 @@ static void format_btf_variable(struct btf *btf, char *buf, size_t buf_size,
 		.sz = sizeof(struct btf_dump_type_data_opts),
 		.skip_names = 1,
 		.compact = 1,
+#if LIBBPF_CURRENT_VERSION_GEQ(1, 7)
 		.emit_strings = 1,
+#endif
 	};
 	struct btf_dump *d;
 	size_t btf_size;
Signature · 1 line
2.51.0
maintainer Acked-by on the v1 series
#5 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 6 lines · Arnaldo Carvalho de Melo

Hi,

Please take a look, noticed after processing a patch from Ian
for another such issue, on a hurry now, haven't checked when that emit_string was introduced.

Quoted 6 lines

- Arnaldo

Arnaldo Carvalho de Melo (2):
perf bpf: Move the LIBBPF_CURRENT_VERSION_GEQ macro to bpf-utils.h perf bpf: Check libbpf version to use
btf_dump_type_data_opts.emit_strings

Thanks,
Namhyung

Quoted 9 lines
 tools/perf/util/bpf-event.c  | 2 ++
 tools/perf/util/bpf-filter.c | 5 +----
 tools/perf/util/bpf-utils.h  | 5 +++++
 3 files changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.51.0
reviewer Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] perf bpf: Check libbpf version to use btf_dump_type_data_opts.emit_strings

In reply to Arnaldo Carvalho de Melo
Quoted 4 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

When building perf with LIBBPF_DINAMIC=1 on a fedora system with

nit: s/DINAMIC/DYNAMIC/

Quoted 13 lines

libbpf-devel 1.5 I it was breaking with:

util/bpf-event.c: In function ‘format_btf_variable’:
util/bpf-event.c:291:18: error: ‘const struct btf_dump_type_data_opts’ has no member named ‘emit_strings’
291 | .emit_strings = 1,

      |                  ^~~~~~~~~~~~

util/bpf-event.c:291:33: error: initialized field overwritten [-Werror=override-init]
291 | .emit_strings = 1,
| ^
util/bpf-event.c:291:33: note: (near initialization for ‘opts.skip_names’)

Check the version before using that feature.

Quoted 8 lines
Cc Adrian Hunter <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Ian Rogers <[email protected]>
Cc James Clark <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Namhyung Kim <[email protected]>

Thanks,
Ian

Quoted 21 lines
---
 tools/perf/util/bpf-event.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/bpf-event.c +2 -1
index 2298cd396c4235e2..59f84aef91b4a2ec 100644
@@ -288,7 +288,9 @@ static void format_btf_variable(struct btf *btf, char *buf, size_t buf_size,
                .sz = sizeof(struct btf_dump_type_data_opts),
                .skip_names = 1,
                .compact = 1,
+#if LIBBPF_CURRENT_VERSION_GEQ(1, 7)
                .emit_strings = 1,
+#endif
        };
        struct btf_dump *d;
        size_t btf_size;
--

2.51.0

reviewer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] perf bpf: Move the LIBBPF_CURRENT_VERSION_GEQ macro to bpf-utils.h

In reply to Arnaldo Carvalho de Melo
Quoted 5 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

We need it to fix some other libbpf version dependent issues when building with LIBBPF_DINAMYC=1

nit: s/DINAMYC/DYNAMIC/ :-)

Thanks,
Ian

Quoted 56 lines
Cc Adrian Hunter <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Ian Rogers <[email protected]>
Cc James Clark <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/util/bpf-filter.c | 5 +----
 tools/perf/util/bpf-utils.h  | 5 +++++
 2 files changed, 6 insertions(+), 4 deletions(-)
tools/perf/util/bpf-filter.c +1 -4
index 92308c38fbb567ba..1a2e7b388d57d367 100644
@@ -56,6 +56,7 @@
 #include "util/debug.h"
 #include "util/evsel.h"
 #include "util/target.h"
+#include "util/bpf-utils.h"
 
 #include "util/bpf-filter.h"
 #include <util/bpf-filter-flex.h>
@@ -443,10 +444,6 @@ static int create_idx_hash(struct evsel *evsel, struct perf_bpf_filter_entry *en
        return -1;
 }
 
-#define LIBBPF_CURRENT_VERSION_GEQ(major, minor)                       \
-       (LIBBPF_MAJOR_VERSION > (major) ||                              \
-        (LIBBPF_MAJOR_VERSION == (major) && LIBBPF_MINOR_VERSION >= (minor)))
-
 int perf_bpf_filter__prepare(struct evsel *evsel, struct target *target)
 {
        int i, x, y, fd, ret;
tools/perf/util/bpf-utils.h +5 -1
index 86a5055cdfad6689..eafc43b8731f1e31 100644
@@ -8,6 +8,11 @@
 #ifdef HAVE_LIBBPF_SUPPORT
 
 #include <bpf/libbpf.h>
+#include <bpf/libbpf_version.h>
+
+#define LIBBPF_CURRENT_VERSION_GEQ(major, minor)                       \
+       (LIBBPF_MAJOR_VERSION > (major) ||                              \
+        (LIBBPF_MAJOR_VERSION == (major) && LIBBPF_MINOR_VERSION >= (minor)))
 
 /*
  * Get bpf_prog_info in continuous memory
--

2.51.0

reviewer
#6 lore raw
In reply to Namhyung Kim
Quoted 7 lines · Namhyung Kim
Quoted 5 lines · Arnaldo Carvalho de Melo

Hi,

Please take a look, noticed after processing a patch from Ian
for another such issue, on a hurry now, haven't checked when that emit_string was introduced.

emit_strings was added in Linux v6.17 and libbpf was tagged as version 1.7 prior to that.

Thanks,
Ian

Quoted 22 lines
Quoted 7 lines

- Arnaldo

Arnaldo Carvalho de Melo (2):
perf bpf: Move the LIBBPF_CURRENT_VERSION_GEQ macro to bpf-utils.h perf bpf: Check libbpf version to use
btf_dump_type_data_opts.emit_strings

Thanks,
Namhyung

Quoted 9 lines
 tools/perf/util/bpf-event.c  | 2 ++
 tools/perf/util/bpf-filter.c | 5 +----
 tools/perf/util/bpf-utils.h  | 5 +++++
 3 files changed, 8 insertions(+), 4 deletions(-)

--
2.51.0

reviewer
#7 lore raw
Quoted 10 lines · Ian Rogers
Quoted 7 lines · Namhyung Kim
Quoted 5 lines · Arnaldo Carvalho de Melo

Hi,

Please take a look, noticed after processing a patch from Ian
for another such issue, on a hurry now, haven't checked when that emit_string was introduced.

Quoted 5 lines

emit_strings was added in Linux v6.17 and libbpf was tagged as version 1.7 prior to that.

Thanks,
Ian

Ping.

When this lands I can rebase:
https://lore.kernel.org/lkml/[email protected]/
on it.

Thanks,
Ian

Quoted 22 lines
Quoted 22 lines
Quoted 7 lines

- Arnaldo

Arnaldo Carvalho de Melo (2):
perf bpf: Move the LIBBPF_CURRENT_VERSION_GEQ macro to bpf-utils.h perf bpf: Check libbpf version to use
btf_dump_type_data_opts.emit_strings

Thanks,
Namhyung

Quoted 9 lines
 tools/perf/util/bpf-event.c  | 2 ++
 tools/perf/util/bpf-filter.c | 5 +----
 tools/perf/util/bpf-utils.h  | 5 +++++
 3 files changed, 8 insertions(+), 4 deletions(-)

--
2.51.0

author maintainer
#8 lore raw
Quoted 14 lines · Ian Rogers
Quoted 13 lines · Ian Rogers
Quoted 7 lines · Namhyung Kim
Quoted 5 lines · Arnaldo Carvalho de Melo

Hi,

Please take a look, noticed after processing a patch from Ian
for another such issue, on a hurry now, haven't checked when that emit_string was introduced.

emit_strings was added in Linux v6.17 and libbpf was tagged as version 1.7 prior to that.

Quoted 8 lines
Quoted 2 lines

Thanks,
Ian

Ping.

When this lands I can rebase:
https://lore.kernel.org/lkml/[email protected]/
on it.

I'm testing this now.

- Arnaldo

Quoted 25 lines

Thanks,
Ian

Quoted 22 lines
Quoted 22 lines
Quoted 7 lines

- Arnaldo

Arnaldo Carvalho de Melo (2):
perf bpf: Move the LIBBPF_CURRENT_VERSION_GEQ macro to bpf-utils.h perf bpf: Check libbpf version to use
btf_dump_type_data_opts.emit_strings

Thanks,
Namhyung

Quoted 9 lines
 tools/perf/util/bpf-event.c  | 2 ++
 tools/perf/util/bpf-filter.c | 5 +----
 tools/perf/util/bpf-utils.h  | 5 +++++
 3 files changed, 8 insertions(+), 4 deletions(-)

--
2.51.0