From nobody Mon Sep 28 17:49:01 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 CBA2B5B21A for ; Wed, 19 Aug 2026 09:46:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787132792; cv=none; b=RjIqLlBL9NqHBPRcSIV2CDrAf9JCQUvLMCFpWI/aIc4a8PGG+s8Ba0kdh68VHz1rtmhgcPateCGFgivGBMBoFyHJNegTsf+4qqIzl1gVj4RudYNv3DtUyHlvekEOAQgtqC5Uu+a7c9BLs84SV8CgnwVrHamBpPWIGZw6R1TOeEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787132792; c=relaxed/simple; bh=W7aykjoyBbylMpYRDhNpVy4JaXYOTxDSysjIdWEphu8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=X1ymQgJ3bNFEBvVPT6LGhd9NECdv1zmAV05/qu81g0MBlfe2aMRH79AXnJxbQzFlbM+/ICAoWLuvcDJRdEiAExqV/+5EGLqHlB2dN7913AreookaiY7Qq/BcPIc+aEOqaTW5gyQaTbr8eAcvI0tVhczFZapJRahYmqsbR5P+gwQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=csjrr8Nu; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="csjrr8Nu" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2cc61541f8cso22526695ad.0 for ; Wed, 19 Aug 2026 02:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787132790; x=1787737590; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=LTPJgMacEEKmZpqtZ6rnhlmPI98eKwXOy18WSdJ9udI=; b=csjrr8Nuk3RLul/xKLLpIX0mzriZdU+UfdX2qqy6v8erBx7ASq6Auws/BdiSoqtsuj lbHwXYhnwAbejVJui9/syExr4+PIHDgzmYcEEa4a6i0PipcL4Zw/3j/y5q28pg6JCpBG 3hCOMVD5vb0wsv8ABk1zx9bMX+LcX9Mm0meanKqn/QnwthNYeG+c2+d3M3oHlCy0hKhk AXKw76IjfXvNzHrimWx62UtmcgxCyH1pKVsJign1+6s6P/JsTKu9wfjCaUQJXkjC2o0U wy+dhNjkeRNvgpnHQo1QEsWx7IxhHaxeiunzC4DQvSNuc/JI5f+NMNuZ8GhQClVV0r2p LinQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787132790; x=1787737590; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=LTPJgMacEEKmZpqtZ6rnhlmPI98eKwXOy18WSdJ9udI=; b=VS4YMcp6Qhbr1SumzbHG71vgXcxBAluEqZfhL1UxGoKv/4io20FKWvYFm39pFDWlGR BvXXV+Ft7IB4wwyp9StVlT67BKH9Z+6DcRTaPfDeiL/7hphBF+kHchcBYVTt8eZxFssF ss0pjyyWKfa3qvdPDcR4rGhNN6n3z+VzT6+T/j6eCWRf79YhYLnjzg6GPP+VOiYVEMbu S6P4ukM/KAcpXwbnNatsSBNzuywS0BtSqFwjvmHwkrifz8oUEFFBXWVitn9B+aoln+b5 MNoCkF5o28jxKY4sOEPh+2RVS68LKWh6AYQnXskUveNz7Tv9xJ2e/RAS6Oo6O8FtUZ4e u8uw== X-Forwarded-Encrypted: i=1; AHgh+Rr3JLhbIWXZdtzunaiUZSlDgFJ5QDC8QEbCAIkDo5VMK/zkXDjpQv/4LLXNZbGmGWQ7alOCV6SuyMO2tBc=@vger.kernel.org X-Gm-Message-State: AFuF++nhEKHYJ/GyDRJ98VlU/1CtPaBmJZVaO0B9zHYbM/t1ZshCMsfr mso/3PgJxPiVrNbvanie5J0MZ36+Qw1m4beNgYIaGo4VS/j6YZC4nBrv X-Gm-Gg: AR+sD12nM6og0NH0mDUQSjTzCMmXnM+PtKPD5QrRgh9zf4PHbsnXJXAhhc+BLhizkxt RIC1XnpkGNTP2IIqhzZXYBoxT42S/HSVI5opfnj3c8B/BaIKz5gjjtHHkBltLwQIPOdcBa6c7OU cHOvvlPWwng4FXeqx0EgalxNY114TfylR2kxNiynSpGiRAgHxsJHhD/6hRn25hxhkRPRL1314TW yMQGBSET9LzXtQqA0KJ7+cqAAOHIbFPcvOeoe0o7xLFcFcYvxGjsfctOjnt/fwcGDPatqRJV80i Frryd1YwxfYOW+Jxnhnca+sP7oDCGO/rSupRTKJJEnC/VrytpkIB5Fwwuf0voanu4FfzpW51PxM a81SrTNxwx/n65g75fHnt6nAEdfRaR5NpgPsUPaZwQgz0exckWkRXijVdj9lzgmvLc9PW/XgR5l KdZVo+oWxhhTJkrOahhSZa6G7cWXZW2vIEHvy09wNDGJhVera/h3RaAti0s6rA5wfNbF82wWhT X-Received: by 2002:a17:90b:1d0d:b0:38e:9ca8:e99 with SMTP id 98e67ed59e1d1-3957f8f8c35mr3586642a91.5.1787132790157; Wed, 19 Aug 2026 02:46:30 -0700 (PDT) Received: from osman.mioffice.cn ([43.224.245.178]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3957fb17eb5sm2460684a91.3.2026.08.19.02.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2026 02:46:29 -0700 (PDT) From: Zhan Xusheng X-Google-Original-From: Zhan Xusheng To: Arnaldo Carvalho de Melo , Namhyung Kim Cc: Ian Rogers , Changbin Du , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Adrian Hunter , zhanxusheng@xiaomi.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Zhan Xusheng Subject: [PATCH v2] perf symbols: Don't apply the symfs layout to synthesised paths Date: Wed, 19 Aug 2026 17:46:21 +0800 Message-ID: <20260819094621.844115-1-zhanxusheng@xiaomi.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhan Xusheng From: Zhan Xusheng The flat symfs layout was implemented inside __symbol__join_symfs() alone, which went from return path__join(bf, size, symbol_conf.symfs, path); to taking perf_basename(path) first. No caller was changed, so all of them got it. Most pass dso__long_name(), which is what the option is about, but some pass a path perf built itself: dso.c "/usr/lib/debug" -> "debug" dso.c "/usr/lib/debug/.build-id/" -> "" build-id.c "/usr/lib/debug/.build-id/" -> "" disasm.c -> last component perf_basename() yields "" for a path ending in '/'. Tracing the lookups against an empty symfs, perf record -o pd.data -- sleep 0.3 strace -f -e trace=3Dopenat,newfstatat \ perf report -i pd.data --symfs ,flat --stdio 15 paths get tried. Four of them differ, in every case only in the prefix, which the patch restores: FEDORA, UBUNTU, MIXEDUP_UBUNTU /debug/ -> //usr/lib/debug/ BUILDID_DEBUGINFO / -> //usr/lib/debug/.build-id/ The tail is dso__long_name() for the first three and the build-id file for the fourth, the same either way, so the build-id file was being looked for in the symfs root and the distro debuginfo under /debug/. Those prefixes follow neither layout: perf's own prefix is flattened while dso__long_name() is still appended whole. Among the 11 paths that do not change are the basename lookups the option is for, /sleep and /vmlinux. The same trace with ,hierarchy is identical between the two builds. Use path__join() at those sites, which is what the helper did for them before. A hierarchy layout is unaffected, being that same call. The OPENEMBEDDED site passes "", where perf_basename() is already a no-op; it is converted for uniformity. Every remaining __symbol__join_symfs() caller passes a path from the profiled system. Fixes: f182573e06ab ("perf tools: Add layout support for --symfs option") Signed-off-by: Zhan Xusheng --- v1->v2: - Added the traced before/after to the changelog, as asked by Ian Rogers. No code change. v1: https://lore.kernel.org/r/20260811050046.4019578-1-zhanxusheng@xiaomi.c= om tools/perf/util/build-id.c | 2 +- tools/perf/util/disasm.c | 4 +++- tools/perf/util/dso.c | 11 ++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index eb95ab90f974..0c89fe75a650 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -599,7 +599,7 @@ static char *build_id_cache__find_debug(const char *sbu= ild_id, dirname =3D dirbuf; } =20 - len =3D __symbol__join_symfs(debugfile, PATH_MAX, dirname); + len =3D path__join(debugfile, PATH_MAX, symbol_conf.symfs, dirname); snprintf(debugfile + len, PATH_MAX - len, "%.2s/%s.debug", sbuild_id, sbuild_id + 2); =20 diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c index 0a1a7e9cf3ef..decf9348d735 100644 --- a/tools/perf/util/disasm.c +++ b/tools/perf/util/disasm.c @@ -31,6 +31,7 @@ #include "map.h" #include "maps.h" #include "namespaces.h" +#include "path.h" #include "srcline.h" #include "symbol.h" #include "thread.h" @@ -1173,7 +1174,8 @@ static int dso__disassemble_filename(struct dso *dso,= char *filename, size_t fil =20 build_id_filename =3D dso__build_id_filename(dso, NULL, 0, false); if (build_id_filename) { - __symbol__join_symfs(filename, filename_size, build_id_filename); + path__join(filename, filename_size, symbol_conf.symfs, + build_id_filename); free(build_id_filename); } else { if (dso__has_build_id(dso)) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 2309196d8df3..314c9a0edf28 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -167,12 +167,12 @@ int dso__read_binary_type_filename(const struct dso *= dso, break; =20 case DSO_BINARY_TYPE__FEDORA_DEBUGINFO: - len =3D __symbol__join_symfs(filename, size, "/usr/lib/debug"); + len =3D path__join(filename, size, symbol_conf.symfs, "/usr/lib/debug"); snprintf(filename + len, size - len, "%s.debug", dso__long_name(dso)); break; =20 case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO: - len =3D __symbol__join_symfs(filename, size, "/usr/lib/debug"); + len =3D path__join(filename, size, symbol_conf.symfs, "/usr/lib/debug"); snprintf(filename + len, size - len, "%s", dso__long_name(dso)); break; =20 @@ -187,7 +187,7 @@ int dso__read_binary_type_filename(const struct dso *ds= o, ret =3D -1; break; } - len =3D __symbol__join_symfs(filename, size, "/usr/lib/debug"); + len =3D path__join(filename, size, symbol_conf.symfs, "/usr/lib/debug"); snprintf(filename + len, size - len, "%s", dso__long_name(dso) + 4); break; =20 @@ -200,7 +200,7 @@ int dso__read_binary_type_filename(const struct dso *ds= o, while (last_slash !=3D dso__long_name(dso) && *last_slash !=3D '/') last_slash--; =20 - len =3D __symbol__join_symfs(filename, size, ""); + len =3D path__join(filename, size, symbol_conf.symfs, ""); dir_size =3D last_slash - dso__long_name(dso) + 2; if (dir_size > (size - len)) { ret =3D -1; @@ -219,7 +219,8 @@ int dso__read_binary_type_filename(const struct dso *ds= o, } =20 build_id__snprintf(dso__bid(dso), build_id_hex, sizeof(build_id_hex)); - len =3D __symbol__join_symfs(filename, size, "/usr/lib/debug/.build-id/"= ); + len =3D path__join(filename, size, symbol_conf.symfs, + "/usr/lib/debug/.build-id/"); snprintf(filename + len, size - len, "%.2s/%s.debug", build_id_hex, build_id_hex + 2); break; --=20 2.43.0