mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Clark <james.clark@linaro.org>
To: Ian Rogers <irogers@google.com>
Cc: "Peter Zijlstra" <peterz@infradead.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Arnaldo Carvalho de Melo" <acme@kernel.org>,
	"Namhyung Kim" <namhyung@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"Kan Liang" <kan.liang@linux.intel.com>,
	"Haibo Xu" <haibo1.xu@intel.com>,
	"Stephen Brennan" <stephen.s.brennan@oracle.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Rémi Bernon" <rbernon@codeweavers.com>,
	"Sam James" <sam@gentoo.org>
Subject: Re: [PATCH v1] perf symbol-elf: Add support for the block argument for libbfd
Date: Thu, 4 Sep 2025 18:38:33 +0100	[thread overview]
Message-ID: <2be96cf8-39fe-4499-9e6b-97268c685698@linaro.org> (raw)
In-Reply-To: <20250904161731.1193729-1-irogers@google.com>



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>


      reply	other threads:[~2025-09-04 17:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04 16:17 Ian Rogers
2025-09-04 17:38 ` James Clark [this message]

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=2be96cf8-39fe-4499-9e6b-97268c685698@linaro.org \
    --to=james.clark@linaro.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=haibo1.xu@intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rbernon@codeweavers.com \
    --cc=sam@gentoo.org \
    --cc=stephen.s.brennan@oracle.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

all inboxes | Powered by JetHome®