* [PATCH v1] perf symbol-elf: Add support for the block argument for libbfd
@ 2025-09-04 16:17 Ian Rogers
2025-09-04 17:38 ` James Clark
0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2025-09-04 16:17 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Kan Liang, Haibo Xu, Stephen Brennan,
linux-perf-users, linux-kernel, Rémi Bernon, Sam James,
James Clark
James Clark caught that the BUILD_NONDISTRO=1 build with libbfd was
broken due to an update to the read_build_id function adding a
blocking argument. Add support for this argument by first opening the
file blocking or non-blocking, then switching from bfd_openr to
bfd_fdopenr and passing the opened fd. bfd_fdopenr closes the fd on
error and when bfd_close are called.
Reported-by: James Clark <james.clark@linaro.org>
Closes: https://lore.kernel.org/lkml/20250903-james-perf-read-build-id-fix-v1-2-6a694d0a980f@linaro.org/
Fixes: 2c369d91d093 ("perf symbol: Add blocking argument to filename__read_build_id")
Signed-off-by: Ian Rogers <irogers@google.com>
---
This patch should be applied after:
https://lore.kernel.org/lkml/20250903-james-perf-read-build-id-fix-v1-1-6a694d0a980f@linaro.org/
---
tools/perf/util/symbol-elf.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 033c79231a54..1346fd180653 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -873,13 +873,17 @@ static int elf_read_build_id(Elf *elf, void *bf, size_t size)
#ifdef HAVE_LIBBFD_BUILDID_SUPPORT
-static int read_build_id(const char *filename, struct build_id *bid)
+static int read_build_id(const char *filename, struct build_id *bid, bool block)
{
size_t size = sizeof(bid->data);
- int err = -1;
+ int err = -1, fd;
bfd *abfd;
- abfd = bfd_openr(filename, NULL);
+ fd = open(filename, block ? O_RDONLY : (O_RDONLY | O_NONBLOCK));
+ if (fd < 0)
+ return -1;
+
+ abfd = bfd_fdopenr(filename, /*target=*/NULL, fd);
if (!abfd)
return -1;
--
2.51.0.338.gd7d06c2dae-goog
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v1] perf symbol-elf: Add support for the block argument for libbfd
2025-09-04 16:17 [PATCH v1] perf symbol-elf: Add support for the block argument for libbfd Ian Rogers
@ 2025-09-04 17:38 ` James Clark
0 siblings, 0 replies; 2+ messages in thread
From: James Clark @ 2025-09-04 17:38 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Adrian Hunter, Kan Liang, Haibo Xu, Stephen Brennan,
linux-perf-users, linux-kernel, Rémi Bernon, Sam James
On 04/09/2025 5:17 pm, Ian Rogers wrote:
> James Clark caught that the BUILD_NONDISTRO=1 build with libbfd was
> broken due to an update to the read_build_id function adding a
> blocking argument. Add support for this argument by first opening the
> file blocking or non-blocking, then switching from bfd_openr to
> bfd_fdopenr and passing the opened fd. bfd_fdopenr closes the fd on
> error and when bfd_close are called.
>
> Reported-by: James Clark <james.clark@linaro.org>
> Closes: https://lore.kernel.org/lkml/20250903-james-perf-read-build-id-fix-v1-2-6a694d0a980f@linaro.org/
> Fixes: 2c369d91d093 ("perf symbol: Add blocking argument to filename__read_build_id")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> This patch should be applied after:
> https://lore.kernel.org/lkml/20250903-james-perf-read-build-id-fix-v1-1-6a694d0a980f@linaro.org/
> ---
> tools/perf/util/symbol-elf.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index 033c79231a54..1346fd180653 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -873,13 +873,17 @@ static int elf_read_build_id(Elf *elf, void *bf, size_t size)
>
> #ifdef HAVE_LIBBFD_BUILDID_SUPPORT
>
> -static int read_build_id(const char *filename, struct build_id *bid)
> +static int read_build_id(const char *filename, struct build_id *bid, bool block)
> {
> size_t size = sizeof(bid->data);
> - int err = -1;
> + int err = -1, fd;
> bfd *abfd;
>
> - abfd = bfd_openr(filename, NULL);
> + fd = open(filename, block ? O_RDONLY : (O_RDONLY | O_NONBLOCK));
> + if (fd < 0)
> + return -1;
> +
> + abfd = bfd_fdopenr(filename, /*target=*/NULL, fd);
> if (!abfd)
> return -1;
>
Oh that was less awkward than I thought then. Assuming it doesn't mind
an fd opened with NONBLOCK?
Reviewed-by: James Clark <james.clark@linaro.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-04 17:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-04 16:17 [PATCH v1] perf symbol-elf: Add support for the block argument for libbfd Ian Rogers
2025-09-04 17:38 ` James Clark
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®