From nobody Tue Dec 2 00:44:06 2025 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E50982FC031 for ; Mon, 24 Nov 2025 10:59:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763981978; cv=none; b=XO8SCZPXhJfJcZ+BxITUIUCAyTS7TIOj5Yrb/Zd/XG/a3MxpBgsO+7j7WiRPymRNBIwppnHcUhpQIqsBV44D9GRBbTihYCbjmr08bhicNW4dYHZuUSZ5h/8M7J/WF34fYi+3c5mPhOCz1m0Tb7nCwRh8Gk9ZUdQSRFGD/oSZvmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763981978; c=relaxed/simple; bh=KFFXxsQTAmZS+a4BukfJ3HDLuW62d+/mNEmK3NfVCos=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=E4zFNKmvoIcav8/oV9tqF9SKoJTLYeqpQDe7t3/OOCIW0mnKzjiYlaLHpmNkdraAxHTLoKXbONUHlelyA88YJDM3afwxviubuup0LhiI6nOqDrL0DBECK4VnSWmdW4YnE9tocHNdJKGzssxuJhQsoYHKh66Lu5YusdESgVO/8ug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=pPcx2mBs; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pPcx2mBs" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-42b3c965cc4so2178299f8f.0 for ; Mon, 24 Nov 2025 02:59:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763981974; x=1764586774; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=rJZWeNL/L5TAelLBtZwTlpzk2ssVlRMGmT3P4O+XmDk=; b=pPcx2mBs3PCjqdHrZ4I4FeGECwNuK73UyAP/07ldISBIxiBnerOxjUyjqwXBKiHDFd POfiSwYkaklNC6HOc7WEoTbPS/oke3i0SmJRAj1kTLKhhqtvQFW7ZVlUwMjzz6s3Oi/S YXFz1SFXigS5KZYLMZea5OCzh/dbKoAogw0GS44ohH6heEbPtJQ/gMhfAEGeY5d0gH9I sZ6s0ENj7/7xfJTVRHPDNbZCUL9IrZzEbiJieq7B7rGuWTMUhb5rHuzLreZpdiOn9FVt 2dZvETszj+NfDKxp/RGp8DvKj2nHAy2y9B7i1YFq8v90mCv/rJKsjFWQJJcnbj+Gi/Nu x17g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763981974; x=1764586774; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rJZWeNL/L5TAelLBtZwTlpzk2ssVlRMGmT3P4O+XmDk=; b=nDVJb7dG4KsYpcr5glmD92QSZqqymgWE1UxrEkVG2j4zNeAnwN/+zQhiONoyGvMFDy saTB84SzOmOEye+VRwo0WXGTSqJNxIqoo+kKMD67ci5gQWxzzPm3fvFuWOzm8bZNsf6p aV6cfHoghSyZ7u7tPRUQnytXRkNJLCoXGiSy0xLy/j0xCGwcNqqEgJ0zPcI+62Ze2g5u GhogNDV8iBcoaqbU4Vf2vJCvIG8nSAGQZlgQrrSoGT+MhzlQ8ev2vexl3Lbj0QNTnTYm 2O8upvgqzpmjSsEp6k2mnkdOQVTdTDdLRilLEYcwcA3jFrC6US63Mus9Q5UaGsUgk5ZY mqyg== X-Forwarded-Encrypted: i=1; AJvYcCWyU21VkXQ1xx44y6ftIbZQj7XfZCfMshtZZf6SAB2ufdIwZ9aRMkVSs7HD6HGKB/gTtzgQn+Tr6k0Og8I=@vger.kernel.org X-Gm-Message-State: AOJu0YwYsB5WnIJUvA0DM8KyB7RoNBGCCYK2R8ndgXYsLJ78LrkTDIVo KfGooW2iH89Vt3kzk4nndX5aeC9sM3Gs9uGncVLjRpMOTV7I2AFbMIQSqRz80Y6XZ8A= X-Gm-Gg: ASbGncuZnlyCCwO0z6NAEPqh7PfMhpxSBRgvgSMvlxckV6ndb/OnC5BXhpGVGNRKiod YzgXUUh2y1SMKWI4K0/ia3PM48roIc2rOspxpojs8CNGAIFQPdfhE4/YzF6jqp+k0fFmfZckXps qPbkXhm5iHtT3pvLC5MAR25q8DagHUQBLnoLWZscHoL8kY/uIVc+JvQO78sw4c/OPNH58DmFIzz 8DEEgmChiB/VttmndTQxYSHLS/ta4wxXnaSaBTU5St+Yj3ID1YyDr7mtXhrN5sHDa3JDUtibv1F C8ijUNYh0S9Ct0au+bkbi+KlYGhW3PbCHonORQSLWfaPpr+ATwmmGK6U6O3IpzG2zuqaUoQAiTN SoBdKhsnMH3bd/HjEpJBGZN8h2pwOZ7l2lDlJgFkdyqVVQpy6Uu40EtsIVmKOP5FjbazakFRIUw T3G8ClTMoqg7/55EzIb8pgDjHQrT0HSYE= X-Google-Smtp-Source: AGHT+IHSW8oyA47+Vpl2YYgvYcYcBG1sj8hIEmTd/6AmNWUxYRo1AGVMy9QcFZNtSfezkLKm6uK4yA== X-Received: by 2002:a5d:584b:0:b0:429:b963:cdd5 with SMTP id ffacd0b85a97d-42cc12f1d70mr12796820f8f.5.1763981974100; Mon, 24 Nov 2025 02:59:34 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42cb7fd9b45sm27700464f8f.43.2025.11.24.02.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Nov 2025 02:59:33 -0800 (PST) From: James Clark Date: Mon, 24 Nov 2025 10:59:08 +0000 Subject: [PATCH v2] perf tools: Don't read build-ids from non-regular files Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251124-james-perf-non-block-v2-1-54cdc2f13a24@linaro.org> X-B4-Tracking: v=1; b=H4sIAHs6JGkC/22NQQ6CMBBFr0Jm7RhmCJC68h6GxYAFqtiSqSEaw t2txKXL95L//grRqrMRTtkKahcXXfAJ+JBBN4ofLLprYuCcSyIyeJOHjThb7dEHj+0UujsWbKr OVCY3IpCms9revfbspUk8uvgM+t5fFvraX5Dpf3AhJKyk5Tpnacu6OE/Oi4Zj0AGabds+cT/RW LkAAAA= To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Simplify the build ID reading code by removing the non-blocking option. Having to pass the correct option to this function was fragile and a mistake would result in a hang, see the linked fix. Furthermore, compressed files are always opened blocking anyway, ignoring the non-blocking option. We also don't expect to read build IDs from non-regular files. The only hits to this function that are non-regular are devices that won't be elf files with build IDs, for example "/dev/dri/renderD129". Now instead of opening these as non-blocking and failing to read, we skip them. Even if something like a pipe or character device did have a build ID, I don't think it would have worked because you need to call read() in a loop, check for -EAGAIN and handle timeouts to make non-blocking reads work. Link: https://lore.kernel.org/linux-perf-users/20251022-james-perf-fix-dso-= block-v1-1-c4faab150546@linaro.org/ Signed-off-by: James Clark --- I looked at the paths for hits to this function and found the following categories: Devices, which non-block reads were unsuccessfully attempted, but are now skipped: * /dev/dri/renderD129 Non-valid paths, where 'non-regular' is irrelevant e.g.: * [vdso] * ... (deleted) * anon_inode:i915.gem Shared memory. These are regular and blocking reads work, so no changes there: * /dev/shm/.org.chromium.Chromium.ejhzXY Symlinks to regular files. Also no change as is_regular_file() is true for these too. --- Changes in v2: - Check is_regular_file in libbfd__read_build_id() too - Return -EWOULDBLOCK instead of -EFAULT for non-regular files - Link to v1: https://lore.kernel.org/r/20251121-james-perf-non-block-v1-1-= 6ab2702ab573@linaro.org --- tools/perf/bench/inject-buildid.c | 2 +- tools/perf/builtin-buildid-cache.c | 8 ++++---- tools/perf/builtin-inject.c | 4 ++-- tools/perf/tests/pe-file-parsing.c | 4 ++-- tools/perf/tests/sdt.c | 2 +- tools/perf/util/build-id.c | 4 ++-- tools/perf/util/debuginfo.c | 2 +- tools/perf/util/dsos.c | 4 ++-- tools/perf/util/libbfd.c | 9 +++++++-- tools/perf/util/libbfd.h | 5 ++--- tools/perf/util/symbol-elf.c | 13 +++++++------ tools/perf/util/symbol-minimal.c | 11 ++++++++--- tools/perf/util/symbol.c | 5 ++--- tools/perf/util/symbol.h | 2 +- tools/perf/util/synthetic-events.c | 2 +- 15 files changed, 43 insertions(+), 34 deletions(-) diff --git a/tools/perf/bench/inject-buildid.c b/tools/perf/bench/inject-bu= ildid.c index 12387ea88b9a..aad572a78d7f 100644 --- a/tools/perf/bench/inject-buildid.c +++ b/tools/perf/bench/inject-buildid.c @@ -85,7 +85,7 @@ static int add_dso(const char *fpath, const struct stat *= sb __maybe_unused, if (typeflag =3D=3D FTW_D || typeflag =3D=3D FTW_SL) return 0; =20 - if (filename__read_build_id(fpath, &bid, /*block=3D*/true) < 0) + if (filename__read_build_id(fpath, &bid) < 0) return 0; =20 dso->name =3D realpath(fpath, NULL); diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildi= d-cache.c index 2e0f2004696a..c98104481c8a 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c @@ -180,7 +180,7 @@ static int build_id_cache__add_file(const char *filenam= e, struct nsinfo *nsi) struct nscookie nsc; =20 nsinfo__mountns_enter(nsi, &nsc); - err =3D filename__read_build_id(filename, &bid, /*block=3D*/true); + err =3D filename__read_build_id(filename, &bid); nsinfo__mountns_exit(&nsc); if (err < 0) { pr_debug("Couldn't read a build-id in %s\n", filename); @@ -204,7 +204,7 @@ static int build_id_cache__remove_file(const char *file= name, struct nsinfo *nsi) int err; =20 nsinfo__mountns_enter(nsi, &nsc); - err =3D filename__read_build_id(filename, &bid, /*block=3D*/true); + err =3D filename__read_build_id(filename, &bid); nsinfo__mountns_exit(&nsc); if (err < 0) { pr_debug("Couldn't read a build-id in %s\n", filename); @@ -280,7 +280,7 @@ static bool dso__missing_buildid_cache(struct dso *dso,= int parm __maybe_unused) if (!dso__build_id_filename(dso, filename, sizeof(filename), false)) return true; =20 - if (filename__read_build_id(filename, &bid, /*block=3D*/true) =3D=3D -1) { + if (filename__read_build_id(filename, &bid) =3D=3D -1) { if (errno =3D=3D ENOENT) return false; =20 @@ -309,7 +309,7 @@ static int build_id_cache__update_file(const char *file= name, struct nsinfo *nsi) int err; =20 nsinfo__mountns_enter(nsi, &nsc); - err =3D filename__read_build_id(filename, &bid, /*block=3D*/true); + err =3D filename__read_build_id(filename, &bid); nsinfo__mountns_exit(&nsc); if (err < 0) { pr_debug("Couldn't read a build-id in %s\n", filename); diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index bd9245d2dd41..0e40f2a4bd18 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -668,12 +668,12 @@ static int dso__read_build_id(struct dso *dso) =20 mutex_lock(dso__lock(dso)); nsinfo__mountns_enter(dso__nsinfo(dso), &nsc); - if (filename__read_build_id(dso__long_name(dso), &bid, /*block=3D*/true) = > 0) + if (filename__read_build_id(dso__long_name(dso), &bid) > 0) dso__set_build_id(dso, &bid); else if (dso__nsinfo(dso)) { char *new_name =3D dso__filename_with_chroot(dso, dso__long_name(dso)); =20 - if (new_name && filename__read_build_id(new_name, &bid, /*block=3D*/true= ) > 0) + if (new_name && filename__read_build_id(new_name, &bid) > 0) dso__set_build_id(dso, &bid); free(new_name); } diff --git a/tools/perf/tests/pe-file-parsing.c b/tools/perf/tests/pe-file-= parsing.c index 8b31d1d05f90..30c7da79e109 100644 --- a/tools/perf/tests/pe-file-parsing.c +++ b/tools/perf/tests/pe-file-parsing.c @@ -37,7 +37,7 @@ static int run_dir(const char *d) size_t idx; =20 scnprintf(filename, PATH_MAX, "%s/pe-file.exe", d); - ret =3D filename__read_build_id(filename, &bid, /*block=3D*/true); + ret =3D filename__read_build_id(filename, &bid); TEST_ASSERT_VAL("Failed to read build_id", ret =3D=3D sizeof(expect_build_id)); TEST_ASSERT_VAL("Wrong build_id", !memcmp(bid.data, expect_build_id, @@ -49,7 +49,7 @@ static int run_dir(const char *d) !strcmp(debuglink, expect_debuglink)); =20 scnprintf(debugfile, PATH_MAX, "%s/%s", d, debuglink); - ret =3D filename__read_build_id(debugfile, &bid, /*block=3D*/true); + ret =3D filename__read_build_id(debugfile, &bid); TEST_ASSERT_VAL("Failed to read debug file build_id", ret =3D=3D sizeof(expect_build_id)); TEST_ASSERT_VAL("Wrong build_id", !memcmp(bid.data, expect_build_id, diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c index 6132f1af3e22..93baee2eae42 100644 --- a/tools/perf/tests/sdt.c +++ b/tools/perf/tests/sdt.c @@ -31,7 +31,7 @@ static int build_id_cache__add_file(const char *filename) struct build_id bid =3D { .size =3D 0, }; int err; =20 - err =3D filename__read_build_id(filename, &bid, /*block=3D*/true); + err =3D filename__read_build_id(filename, &bid); if (err < 0) { pr_debug("Failed to read build id of %s\n", filename); return err; diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 35505a1ffd11..fdb35133fde4 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -122,7 +122,7 @@ int filename__snprintf_build_id(const char *pathname, c= har *sbuild_id, size_t sb struct build_id bid =3D { .size =3D 0, }; int ret; =20 - ret =3D filename__read_build_id(pathname, &bid, /*block=3D*/true); + ret =3D filename__read_build_id(pathname, &bid); if (ret < 0) return ret; =20 @@ -848,7 +848,7 @@ static int filename__read_build_id_ns(const char *filen= ame, int ret; =20 nsinfo__mountns_enter(nsi, &nsc); - ret =3D filename__read_build_id(filename, bid, /*block=3D*/true); + ret =3D filename__read_build_id(filename, bid); nsinfo__mountns_exit(&nsc); =20 return ret; diff --git a/tools/perf/util/debuginfo.c b/tools/perf/util/debuginfo.c index bb9ebd84ec2d..4a559b3e8cdc 100644 --- a/tools/perf/util/debuginfo.c +++ b/tools/perf/util/debuginfo.c @@ -115,7 +115,7 @@ struct debuginfo *debuginfo__new(const char *path) * incase the path isn't for a regular file. */ assert(!dso__has_build_id(dso)); - if (filename__read_build_id(path, &bid, /*block=3D*/false) > 0) + if (filename__read_build_id(path, &bid) > 0) dso__set_build_id(dso, &bid); =20 for (type =3D distro_dwarf_types; diff --git a/tools/perf/util/dsos.c b/tools/perf/util/dsos.c index 64c1d65b0149..0a7645c7fae7 100644 --- a/tools/perf/util/dsos.c +++ b/tools/perf/util/dsos.c @@ -81,13 +81,13 @@ static int dsos__read_build_ids_cb(struct dso *dso, voi= d *data) return 0; } nsinfo__mountns_enter(dso__nsinfo(dso), &nsc); - if (filename__read_build_id(dso__long_name(dso), &bid, /*block=3D*/true) = > 0) { + if (filename__read_build_id(dso__long_name(dso), &bid) > 0) { dso__set_build_id(dso, &bid); args->have_build_id =3D true; } else if (errno =3D=3D ENOENT && dso__nsinfo(dso)) { char *new_name =3D dso__filename_with_chroot(dso, dso__long_name(dso)); =20 - if (new_name && filename__read_build_id(new_name, &bid, /*block=3D*/true= ) > 0) { + if (new_name && filename__read_build_id(new_name, &bid) > 0) { dso__set_build_id(dso, &bid); args->have_build_id =3D true; } diff --git a/tools/perf/util/libbfd.c b/tools/perf/util/libbfd.c index 01147fbf73b3..0099b415decc 100644 --- a/tools/perf/util/libbfd.c +++ b/tools/perf/util/libbfd.c @@ -383,13 +383,18 @@ int dso__load_bfd_symbols(struct dso *dso, const char= *debugfile) return err; } =20 -int libbfd__read_build_id(const char *filename, struct build_id *bid, bool= block) +int libbfd__read_build_id(const char *filename, struct build_id *bid) { size_t size =3D sizeof(bid->data); int err =3D -1, fd; bfd *abfd; =20 - fd =3D open(filename, block ? O_RDONLY : (O_RDONLY | O_NONBLOCK)); + if (!filename) + return -EFAULT; + if (!is_regular_file(filename)) + return -EWOULDBLOCK; + + fd =3D open(filename, O_RDONLY); if (fd < 0) return -1; =20 diff --git a/tools/perf/util/libbfd.h b/tools/perf/util/libbfd.h index e300f171d1bd..953886f3d62f 100644 --- a/tools/perf/util/libbfd.h +++ b/tools/perf/util/libbfd.h @@ -25,7 +25,7 @@ void dso__free_a2l_libbfd(struct dso *dso); int symbol__disassemble_libbfd(const char *filename, struct symbol *sym, struct annotate_args *args); =20 -int libbfd__read_build_id(const char *filename, struct build_id *bid, bool= block); +int libbfd__read_build_id(const char *filename, struct build_id *bid); =20 int libbfd_filename__read_debuglink(const char *filename, char *debuglink,= size_t size); =20 @@ -59,8 +59,7 @@ static inline int symbol__disassemble_libbfd(const char *= filename __always_unuse } =20 static inline int libbfd__read_build_id(const char *filename __always_unus= ed, - struct build_id *bid __always_unused, - bool block __always_unused) + struct build_id *bid __always_unused) { return -1; } diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 9e820599bab3..c5c382c3409a 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -860,20 +860,20 @@ static int elf_read_build_id(Elf *elf, void *bf, size= _t size) return err; } =20 -static int read_build_id(const char *filename, struct build_id *bid, bool = block) +static int read_build_id(const char *filename, struct build_id *bid) { size_t size =3D sizeof(bid->data); int fd, err; Elf *elf; =20 - err =3D libbfd__read_build_id(filename, bid, block); + err =3D libbfd__read_build_id(filename, bid); if (err >=3D 0) goto out; =20 if (size < BUILD_ID_SIZE) goto out; =20 - fd =3D open(filename, block ? O_RDONLY : (O_RDONLY | O_NONBLOCK)); + fd =3D open(filename, O_RDONLY); if (fd < 0) goto out; =20 @@ -894,7 +894,7 @@ static int read_build_id(const char *filename, struct b= uild_id *bid, bool block) return err; } =20 -int filename__read_build_id(const char *filename, struct build_id *bid, bo= ol block) +int filename__read_build_id(const char *filename, struct build_id *bid) { struct kmod_path m =3D { .name =3D NULL, }; char path[PATH_MAX]; @@ -902,6 +902,8 @@ int filename__read_build_id(const char *filename, struc= t build_id *bid, bool blo =20 if (!filename) return -EFAULT; + if (!is_regular_file(filename)) + return -EWOULDBLOCK; =20 err =3D kmod_path__parse(&m, filename); if (err) @@ -918,10 +920,9 @@ int filename__read_build_id(const char *filename, stru= ct build_id *bid, bool blo } close(fd); filename =3D path; - block =3D true; } =20 - err =3D read_build_id(filename, bid, block); + err =3D read_build_id(filename, bid); =20 if (m.comp) unlink(filename); diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-mini= mal.c index aeb253248895..c6b17c14a2e9 100644 --- a/tools/perf/util/symbol-minimal.c +++ b/tools/perf/util/symbol-minimal.c @@ -85,7 +85,7 @@ int filename__read_debuglink(const char *filename __maybe= _unused, /* * Just try PT_NOTE header otherwise fails */ -int filename__read_build_id(const char *filename, struct build_id *bid, bo= ol block) +int filename__read_build_id(const char *filename, struct build_id *bid) { int fd, ret =3D -1; bool need_swap =3D false, elf32; @@ -102,7 +102,12 @@ int filename__read_build_id(const char *filename, stru= ct build_id *bid, bool blo void *phdr, *buf =3D NULL; ssize_t phdr_size, ehdr_size, buf_size =3D 0; =20 - fd =3D open(filename, block ? O_RDONLY : (O_RDONLY | O_NONBLOCK)); + if (!filename) + return -EFAULT; + if (!is_regular_file(filename)) + return -EWOULDBLOCK; + + fd =3D open(filename, O_RDONLY); if (fd < 0) return -1; =20 @@ -323,7 +328,7 @@ int dso__load_sym(struct dso *dso, struct map *map __ma= ybe_unused, if (ret >=3D 0) RC_CHK_ACCESS(dso)->is_64_bit =3D ret; =20 - if (filename__read_build_id(ss->name, &bid, /*block=3D*/true) > 0) + if (filename__read_build_id(ss->name, &bid) > 0) dso__set_build_id(dso, &bid); return 0; } diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index cc26b7bf302b..d8fc5ea77f84 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1743,14 +1743,13 @@ int dso__load(struct dso *dso, struct map *map) =20 /* * Read the build id if possible. This is required for - * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work. Don't block in case path - * isn't for a regular file. + * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work. */ if (!dso__has_build_id(dso)) { struct build_id bid =3D { .size =3D 0, }; =20 __symbol__join_symfs(name, PATH_MAX, dso__long_name(dso)); - if (filename__read_build_id(name, &bid, /*block=3D*/false) > 0) + if (filename__read_build_id(name, &bid) > 0) dso__set_build_id(dso, &bid); } =20 diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 347106218799..3fb5d146d9b1 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -140,7 +140,7 @@ struct symbol *dso__next_symbol(struct symbol *sym); =20 enum dso_type dso__type_fd(int fd); =20 -int filename__read_build_id(const char *filename, struct build_id *id, boo= l block); +int filename__read_build_id(const char *filename, struct build_id *id); int sysfs__read_build_id(const char *filename, struct build_id *bid); int modules__parse(const char *filename, void *arg, int (*process_module)(void *arg, const char *name, diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic= -events.c index 5aa44c4aba62..2ba9fa25e00a 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -401,7 +401,7 @@ static void perf_record_mmap2__read_build_id(struct per= f_record_mmap2 *event, nsi =3D nsinfo__new(event->pid); nsinfo__mountns_enter(nsi, &nc); =20 - rc =3D filename__read_build_id(event->filename, &bid, /*block=3D*/false) = > 0 ? 0 : -1; + rc =3D filename__read_build_id(event->filename, &bid) > 0 ? 0 : -1; =20 nsinfo__mountns_exit(&nc); nsinfo__put(nsi); --- base-commit: 134852abcbfa5f6a4a17619c8f44c857f800ae03 change-id: 20251119-james-perf-non-block-3296c96909aa Best regards, --=20 James Clark