bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Blake Jones <blakejones@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ian Rogers <irogers@google.com>, Jiri Olsa <jolsa@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Tomas Glozar <tglozar@redhat.com>,
	James Clark <james.clark@linaro.org>, Leo Yan <leo.yan@arm.com>,
	Guilherme Amadio <amadio@gentoo.org>,
	Yang Jihong <yangjihong@bytedance.com>,
	Charlie Jenkins <charlie@rivosinc.com>,
	Chun-Tse Shao <ctshao@google.com>,
	Aditya Gupta <adityag@linux.ibm.com>,
	Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
	Zhongqiu Han <quic_zhonhan@quicinc.com>,
	Andi Kleen <ak@linux.intel.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Yujie Liu <yujie.liu@intel.com>,
	Graham Woodward <graham.woodward@arm.com>,
	Yicong Yang <yangyicong@hisilicon.com>,
	Ben Gainey <ben.gainey@arm.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	bpf@vger.kernel.org
Subject: Re: [PATCH v2 1/4] perf: detect support for libbpf's emit_strings option
Date: Fri, 6 Jun 2025 12:04:52 -0700	[thread overview]
Message-ID: <aEM71LulKhuEinN6@google.com> (raw)
In-Reply-To: <20250605233934.1881839-2-blakejones@google.com>

On Thu, Jun 05, 2025 at 04:39:31PM -0700, Blake Jones wrote:
> This creates a config option that detects libbpf's ability to display
> character arrays as strings, which was just added to the BPF tree
> (https://git.kernel.org/bpf/bpf-next/c/87c9c79a02b4).
> 
> To test this change, I built perf (from later in this patch set) with:
> 
> - static libbpf (default, using source from kernel tree)
> - dynamic libbpf (LIBBPF_DYNAMIC=1 LIBBPF_INCLUDE=/usr/local/include)
> 
> For both the static and dynamic versions, I used headers with and without
> the ".emit_strings" option.
> 
> I verified that of the four resulting binaries, the two with
> ".emit_strings" would successfully record BPF_METADATA events, and the two
> without wouldn't.  All four binaries would successfully display
> BPF_METADATA events, because the relevant bit of libbpf code is only used
> during "perf record".
> 
> Signed-off-by: Blake Jones <blakejones@google.com>
> ---
>  tools/build/Makefile.feature              |  1 +
>  tools/build/feature/Makefile              |  4 ++++
>  tools/build/feature/test-libbpf-strings.c | 10 ++++++++++
>  tools/perf/Documentation/perf-check.txt   |  1 +
>  tools/perf/Makefile.config                | 12 ++++++++++++
>  tools/perf/builtin-check.c                |  1 +
>  6 files changed, 29 insertions(+)
>  create mode 100644 tools/build/feature/test-libbpf-strings.c
> 
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index 57bd995ce6af..541ea3cc53e9 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -126,6 +126,7 @@ FEATURE_TESTS_EXTRA :=                  \
>           llvm                           \
>           clang                          \
>           libbpf                         \
> +         libbpf-strings                 \
>           libbpf-btf__load_from_kernel_by_id \
>           libbpf-bpf_prog_load           \
>           libbpf-bpf_object__next_program \

Please check out tmp.perf-tools-next branch which made some changes in
the area.

Thanks,
Namhyung


> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index b8b5fb183dd4..327bb501fd2b 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -59,6 +59,7 @@ FILES=                                          \
>           test-lzma.bin                          \
>           test-bpf.bin                           \
>           test-libbpf.bin                        \
> +         test-libbpf-strings.bin                \
>           test-get_cpuid.bin                     \
>           test-sdt.bin                           \
>           test-cxx.bin                           \
> @@ -360,6 +361,9 @@ $(OUTPUT)test-libbpf-bpf_program__set_insns.bin:
>  $(OUTPUT)test-libbpf-btf__raw_data.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
> new file mode 100644
> index 000000000000..83e6c45f5c85
> --- /dev/null
> +++ b/tools/build/feature/test-libbpf-strings.c
> @@ -0,0 +1,10 @@
> +// 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;
> +}
> diff --git a/tools/perf/Documentation/perf-check.txt b/tools/perf/Documentation/perf-check.txt
> index a764a4629220..799982d8d868 100644
> --- a/tools/perf/Documentation/perf-check.txt
> +++ b/tools/perf/Documentation/perf-check.txt
> @@ -52,6 +52,7 @@ feature::
>                  dwarf-unwind            /  HAVE_DWARF_UNWIND_SUPPORT
>                  auxtrace                /  HAVE_AUXTRACE_SUPPORT
>                  libbfd                  /  HAVE_LIBBFD_SUPPORT
> +                libbpf-strings          /  HAVE_LIBBPF_STRINGS_SUPPORT
>                  libcapstone             /  HAVE_LIBCAPSTONE_SUPPORT
>                  libcrypto               /  HAVE_LIBCRYPTO_SUPPORT
>                  libdw-dwarf-unwind      /  HAVE_LIBDW_SUPPORT
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index d1ea7bf44964..647ade45e4e5 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -595,8 +595,20 @@ ifndef NO_LIBELF
>            LIBBPF_STATIC := 1
>            $(call detected,CONFIG_LIBBPF)
>            CFLAGS += -DHAVE_LIBBPF_SUPPORT
> +          ifneq ($(OUTPUT),)
> +            LIBBPF_INCLUDE = $(abspath $(OUTPUT))/libbpf/include
> +          else
> +            LIBBPF_INCLUDE = $(CURDIR)/libbpf/include
> +          endif
>          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 9a509cb3bb9a..f4827f0ddb47 100644
> --- a/tools/perf/builtin-check.c
> +++ b/tools/perf/builtin-check.c
> @@ -43,6 +43,7 @@ struct feature_status supported_features[] = {
>  	FEATURE_STATUS("dwarf-unwind", HAVE_DWARF_UNWIND_SUPPORT),
>  	FEATURE_STATUS("auxtrace", HAVE_AUXTRACE_SUPPORT),
>  	FEATURE_STATUS_TIP("libbfd", HAVE_LIBBFD_SUPPORT, "Deprecated, license incompatibility, use BUILD_NONDISTRO=1 and install binutils-dev[el]"),
> +	FEATURE_STATUS("libbpf-strings", HAVE_LIBBPF_STRINGS_SUPPORT),
>  	FEATURE_STATUS("libcapstone", HAVE_LIBCAPSTONE_SUPPORT),
>  	FEATURE_STATUS("libcrypto", HAVE_LIBCRYPTO_SUPPORT),
>  	FEATURE_STATUS("libdw-dwarf-unwind", HAVE_LIBDW_SUPPORT),
> -- 
> 2.50.0.rc0.604.gd4ff7b7c86-goog
> 

  reply	other threads:[~2025-06-06 19:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05 23:39 [PATCH v2 0/4] perf: generate events for BPF metadata Blake Jones
2025-06-05 23:39 ` [PATCH v2 1/4] perf: detect support for libbpf's emit_strings option Blake Jones
2025-06-06 19:04   ` Namhyung Kim [this message]
2025-06-06 21:52     ` Blake Jones
2025-06-05 23:39 ` [PATCH v2 2/4] perf: collect BPF metadata from existing BPF programs Blake Jones
2025-06-05 23:39 ` [PATCH v2 3/4] perf: collect BPF metadata from new programs, and display the new event Blake Jones
2025-06-06 19:02   ` Namhyung Kim
2025-06-06 21:51     ` Blake Jones
2025-06-05 23:39 ` [PATCH v2 4/4] perf: add test for PERF_RECORD_BPF_METADATA collection Blake Jones
2025-07-09 21:02   ` Ian Rogers
2025-07-09 21:08     ` Blake Jones
2025-07-09 21:44       ` Ian Rogers
2025-07-26  0:41         ` Blake Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aEM71LulKhuEinN6@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adityag@linux.ibm.com \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=amadio@gentoo.org \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=ben.gainey@arm.com \
    --cc=blakejones@google.com \
    --cc=bpf@vger.kernel.org \
    --cc=charlie@rivosinc.com \
    --cc=ctshao@google.com \
    --cc=dvyukov@google.com \
    --cc=graham.woodward@arm.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=leo.yan@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=quic_zhonhan@quicinc.com \
    --cc=rostedt@goodmis.org \
    --cc=tglozar@redhat.com \
    --cc=yangjihong@bytedance.com \
    --cc=yangyicong@hisilicon.com \
    --cc=yujie.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).