linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] perf bpf-event: Use libbpf version rather than feature check
@ 2025-10-03  1:23 Ian Rogers
  2025-10-03  1:23 ` [PATCH v1 2/2] tools build: Remove libbpf-strings feature test Ian Rogers
  2025-10-03 19:21 ` [PATCH v1 1/2] perf bpf-event: Use libbpf version rather than feature check Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 3+ messages in thread
From: Ian Rogers @ 2025-10-03  1:23 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Blake Jones, linux-kernel,
	linux-perf-users, bpf

The feature check guarded the -DHAVE_LIBBPF_STRINGS_SUPPORT is
unnecessary as it is sufficient and easier to use the
LIBBPF_CURRENT_VERSION_GEQ macro.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/Makefile.config  | 7 -------
 tools/perf/builtin-check.c  | 1 +
 tools/perf/util/bpf-event.c | 2 --
 tools/perf/util/bpf-utils.h | 5 +++++
 4 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 6cdb96576cb8..b0e15721c5a5 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -596,13 +596,6 @@ ifndef NO_LIBELF
 	  LIBBPF_INCLUDE = $(LIBBPF_DIR)/..
         endif
       endif
-
-      FEATURE_CHECK_CFLAGS-libbpf-strings="-I$(LIBBPF_INCLUDE)"
-      $(call feature_check,libbpf-strings)
-      ifeq ($(feature-libbpf-strings), 1)
-        $(call detected,CONFIG_LIBBPF_STRINGS)
-        CFLAGS += -DHAVE_LIBBPF_STRINGS_SUPPORT
-      endif
     endif
   endif # NO_LIBBPF
 endif # NO_LIBELF
diff --git a/tools/perf/builtin-check.c b/tools/perf/builtin-check.c
index 7fd054760e47..8c0668911fb1 100644
--- a/tools/perf/builtin-check.c
+++ b/tools/perf/builtin-check.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "builtin.h"
 #include "color.h"
+#include "util/bpf-utils.h"
 #include "util/debug.h"
 #include "util/header.h"
 #include <tools/config.h>
diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index 59f84aef91b4..2298cd396c42 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -288,9 +288,7 @@ 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;
diff --git a/tools/perf/util/bpf-utils.h b/tools/perf/util/bpf-utils.h
index eafc43b8731f..a8bc1a232968 100644
--- a/tools/perf/util/bpf-utils.h
+++ b/tools/perf/util/bpf-utils.h
@@ -14,6 +14,11 @@
        (LIBBPF_MAJOR_VERSION > (major) ||                              \
         (LIBBPF_MAJOR_VERSION == (major) && LIBBPF_MINOR_VERSION >= (minor)))
 
+#if LIBBPF_CURRENT_VERSION_GEQ(1, 7)
+// libbpf 1.7+ support the btf_dump_type_data_opts.emit_strings option.
+#define HAVE_LIBBPF_STRINGS_SUPPORT 1
+#endif
+
 /*
  * Get bpf_prog_info in continuous memory
  *
-- 
2.51.0.618.g983fd99d29-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v1 2/2] tools build: Remove libbpf-strings feature test
  2025-10-03  1:23 [PATCH v1 1/2] perf bpf-event: Use libbpf version rather than feature check Ian Rogers
@ 2025-10-03  1:23 ` Ian Rogers
  2025-10-03 19:21 ` [PATCH v1 1/2] perf bpf-event: Use libbpf version rather than feature check Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2025-10-03  1:23 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Blake Jones, linux-kernel,
	linux-perf-users, bpf

The feature test is unnecessary as the LIBBPF_CURRENT_VERSION_GEQ(1,7)
macro can be used instead. The only use was in perf and this is now
removed.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/build/Makefile.feature              |  1 -
 tools/build/feature/Makefile              |  4 ----
 tools/build/feature/test-libbpf-strings.c | 10 ----------
 3 files changed, 15 deletions(-)
 delete mode 100644 tools/build/feature/test-libbpf-strings.c

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 9399f591bd69..f9477df18841 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -124,7 +124,6 @@ FEATURE_TESTS_EXTRA :=                  \
          llvm                           \
          clang                          \
          libbpf                         \
-         libbpf-strings                 \
          libpfm4                        \
          libdebuginfod			\
          clang-bpf-co-re		\
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index d13d2a1f44fe..fd304dc2aafd 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -57,7 +57,6 @@ FILES=                                          \
          test-lzma.bin                          \
          test-bpf.bin                           \
          test-libbpf.bin                        \
-         test-libbpf-strings.bin                \
          test-get_cpuid.bin                     \
          test-sdt.bin                           \
          test-cxx.bin                           \
@@ -332,9 +331,6 @@ $(OUTPUT)test-bpf.bin:
 $(OUTPUT)test-libbpf.bin:
 	$(BUILD) -lbpf
 
-$(OUTPUT)test-libbpf-strings.bin:
-	$(BUILD)
-
 $(OUTPUT)test-sdt.bin:
 	$(BUILD)
 
diff --git a/tools/build/feature/test-libbpf-strings.c b/tools/build/feature/test-libbpf-strings.c
deleted file mode 100644
index 83e6c45f5c85..000000000000
--- a/tools/build/feature/test-libbpf-strings.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <bpf/btf.h>
-
-int main(void)
-{
-	struct btf_dump_type_data_opts opts;
-
-	opts.emit_strings = 0;
-	return opts.emit_strings;
-}
-- 
2.51.0.618.g983fd99d29-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/2] perf bpf-event: Use libbpf version rather than feature check
  2025-10-03  1:23 [PATCH v1 1/2] perf bpf-event: Use libbpf version rather than feature check Ian Rogers
  2025-10-03  1:23 ` [PATCH v1 2/2] tools build: Remove libbpf-strings feature test Ian Rogers
@ 2025-10-03 19:21 ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-10-03 19:21 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Blake Jones,
	linux-kernel, linux-perf-users, bpf

On Thu, Oct 02, 2025 at 06:23:48PM -0700, Ian Rogers wrote:
> The feature check guarded the -DHAVE_LIBBPF_STRINGS_SUPPORT is
> unnecessary as it is sufficient and easier to use the
> LIBBPF_CURRENT_VERSION_GEQ macro.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/Makefile.config  | 7 -------
>  tools/perf/builtin-check.c  | 1 +
>  tools/perf/util/bpf-event.c | 2 --
>  tools/perf/util/bpf-utils.h | 5 +++++
>  4 files changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 6cdb96576cb8..b0e15721c5a5 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -596,13 +596,6 @@ ifndef NO_LIBELF
>  	  LIBBPF_INCLUDE = $(LIBBPF_DIR)/..
>          endif
>        endif
> -
> -      FEATURE_CHECK_CFLAGS-libbpf-strings="-I$(LIBBPF_INCLUDE)"
> -      $(call feature_check,libbpf-strings)
> -      ifeq ($(feature-libbpf-strings), 1)
> -        $(call detected,CONFIG_LIBBPF_STRINGS)
> -        CFLAGS += -DHAVE_LIBBPF_STRINGS_SUPPORT
> -      endif
>      endif
>    endif # NO_LIBBPF
>  endif # NO_LIBELF
> diff --git a/tools/perf/builtin-check.c b/tools/perf/builtin-check.c
> index 7fd054760e47..8c0668911fb1 100644
> --- a/tools/perf/builtin-check.c
> +++ b/tools/perf/builtin-check.c
> @@ -1,6 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #include "builtin.h"
>  #include "color.h"
> +#include "util/bpf-utils.h"
>  #include "util/debug.h"
>  #include "util/header.h"
>  #include <tools/config.h>
> diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
> index 59f84aef91b4..2298cd396c42 100644
> --- a/tools/perf/util/bpf-event.c
> +++ b/tools/perf/util/bpf-event.c
> @@ -288,9 +288,7 @@ 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

I see, this is already under HAVE_LIBBPF_STRINGS_SUPPORT

Applying,

- Arnaldo

>  	};
>  	struct btf_dump *d;
>  	size_t btf_size;
> diff --git a/tools/perf/util/bpf-utils.h b/tools/perf/util/bpf-utils.h
> index eafc43b8731f..a8bc1a232968 100644
> --- a/tools/perf/util/bpf-utils.h
> +++ b/tools/perf/util/bpf-utils.h
> @@ -14,6 +14,11 @@
>         (LIBBPF_MAJOR_VERSION > (major) ||                              \
>          (LIBBPF_MAJOR_VERSION == (major) && LIBBPF_MINOR_VERSION >= (minor)))
>  
> +#if LIBBPF_CURRENT_VERSION_GEQ(1, 7)
> +// libbpf 1.7+ support the btf_dump_type_data_opts.emit_strings option.
> +#define HAVE_LIBBPF_STRINGS_SUPPORT 1
> +#endif
> +
>  /*
>   * Get bpf_prog_info in continuous memory
>   *
> -- 
> 2.51.0.618.g983fd99d29-goog

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-03 19:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-03  1:23 [PATCH v1 1/2] perf bpf-event: Use libbpf version rather than feature check Ian Rogers
2025-10-03  1:23 ` [PATCH v1 2/2] tools build: Remove libbpf-strings feature test Ian Rogers
2025-10-03 19:21 ` [PATCH v1 1/2] perf bpf-event: Use libbpf version rather than feature check Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).