perf symbol: Add blocking argument to filename__read_build_id
authorIan Rogers <irogers@google.com>
Sat, 23 Aug 2025 00:00:24 +0000 (17:00 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Mon, 25 Aug 2025 22:07:18 +0000 (15:07 -0700)
commit2c369d91d0933aaff96b6b807b22363e6a38a625
treee22a6006aa6771373c892470e3516da2e2292404
parentba0b7081f7a521d7c28b527a4f18666a148471e7
perf symbol: Add blocking argument to filename__read_build_id

When synthesizing build-ids, for build ID mmap2 events, they will be
added for data mmaps if -d/--data is specified. The files opened for
their build IDs may block on the open causing perf to hang during
synthesis. There is some robustness in existing calls to
filename__read_build_id by checking the file path is to a regular
file, which unfortunately fails for symlinks. Rather than adding more
is_regular_file calls, switch filename__read_build_id to take a
"block" argument and specify O_NONBLOCK when this is false. The
existing is_regular_file checking callers and the event synthesis
callers are made to pass false and thereby avoiding the hang.

Fixes: 53b00ff358dc ("perf record: Make --buildid-mmap the default")
Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250823000024.724394-3-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
12 files changed:
tools/perf/bench/inject-buildid.c
tools/perf/builtin-buildid-cache.c
tools/perf/builtin-inject.c
tools/perf/tests/sdt.c
tools/perf/util/build-id.c
tools/perf/util/debuginfo.c
tools/perf/util/dsos.c
tools/perf/util/symbol-elf.c
tools/perf/util/symbol-minimal.c
tools/perf/util/symbol.c
tools/perf/util/symbol.h
tools/perf/util/synthetic-events.c