From nobody Mon Sep 28 09:58:47 2026 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (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 C9CF43DFC8A for ; Mon, 24 Aug 2026 06:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787552931; cv=none; b=Ouhf0NlHcCKlklUbjlkow1xmdmXM08PgdXfGpfELgmDIf8WZl6ymQSs3W8SObVY2h1Eh+ty93y2XdgLAk3DfWQOauQ5lpZAWyRuXMEycYzokFyJ54L4Va81dhupDVj+uuWoIM6ecyctaici2nRFddAAy+T2+mWbyNIai1OaJ0wU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787552931; c=relaxed/simple; bh=gMaNXf7xJjOQ+qdNmKmHhulbQS0EBessgU12SUxZg28=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=H4OfgcSDiAAr75aF+pm92GgY8VL23rr7vSg+rg5cvGnt5rDnpjBrGHa4HVaLdImp3JqXbV8VdImb3Erf50RxMk6bBYGEHGEXz1RYNJ20eazu/BjVkmGpUEc9A1GPgdf/uFKgTIQIgLIMO57A2DPLzUGSh+t8LYkFyOm+6XCpv9c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=r3xBMGvr; arc=none smtp.client-ip=209.85.216.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="r3xBMGvr" Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-38e4758ab46so4887866a91.0 for ; Sun, 23 Aug 2026 23:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787552929; x=1788157729; darn=vger.kernel.org; h=content-type:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=UgqPKMSInHAUx1W1Amw4siLEmTlfxJRfowC3pdCETa4=; b=r3xBMGvr1W/jgcPpAq5jLksL5JmaqcjnYHlKiauRg6g5ihMeDoWU0IUdQmek/R8tIL c/WhJE9dA8MOA2eJ7/XnLStfOJ08CJq2H4PNzEDyS7aue99cVCOMH+Z5BhNiTOrBmvOh at9pjYpbSe4JGLajH4Dhp8EQmYv41Dua+vBFKMOMDqIvWpTDn9YPZVGNKn/1+FhWhPJf 1RJ9vjMeIZPzhRdBOp9gBzJW1Ni9knPkEZ1ImABgX5K4oNxB8BIvqSZsgVTs5utrFNnP wKKUgaTmhWWyebc183jn25rdTWitLdb1ETPa0A4XQaJrnSF1jd8tJp1IYdub+NnQgoM/ 9zPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787552929; x=1788157729; h=content-type:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=UgqPKMSInHAUx1W1Amw4siLEmTlfxJRfowC3pdCETa4=; b=hYV8dgHe09EDXSJEX8J12cA8eOKK0HDgvUEE9cRiq5p4rO/o0CH5SLe9Go+XbA8C19 TNhCRhM4N+/QxypITwz4X8bhlu+Ejb2Rju6QrDLH1A+GhTxYIeiqyXD0Emg6YOaWR0JE NAL0anjCJoobaxi4/TbuELpvrAOhePIKnVQy+ojFRC1RAodXTj4yMnZDTrIvrnDaZu7S yvzq/AZOBw4YXld4sPfwge1RCkQEeVnKDU3aX/nKhVjKrOh8EsQ7hDPexpsHhbtk+mun pzRR6yq7JbuiySDslqI5tIDwWQ9zuPL6vV1044vgjlTzPP+zT6rNy6Z2InOobERt+H+t x21g== X-Forwarded-Encrypted: i=1; AHgh+Rq0wGLRfOmEmyh3j8SKKGOK2Nc06dvDbxk3wmyBJ2xraW1P/VFr4CQi6b1jJl+q0R1FWZhtJp3CJc4aCDQ=@vger.kernel.org X-Gm-Message-State: AFuF++nz5cXYWAd6C16IK/uJHJRYInG/Rq3bjA24zc5JY1U7F7kN/IfJ qLO6fSgsxByyvOof5qYCIdHZ4O71TtV6wXC3I+mhK5YFPMKSeBX9sKDMK7FoRCYcqyCZnYhw7CK EgsSsC6+0HA== X-Received: from dlbvv2.prod.google.com ([2002:a05:7022:5f02:b0:140:f3ca:6a02]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:5646:b0:381:28e0:6259 with SMTP id 98e67ed59e1d1-395c36fb278mr45944849a91.9.1787552928935; Sun, 23 Aug 2026 23:28:48 -0700 (PDT) Date: Sun, 23 Aug 2026 23:28:40 -0700 In-Reply-To: <20260824062841.1529489-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260824062841.1529489-1-irogers@google.com> X-Mailer: git-send-email 2.55.0.766.g2966f0265a-goog Message-ID: <20260824062841.1529489-2-irogers@google.com> Subject: [PATCH v1 1/2] perf libdw: Pass dso_name explicitly to properly anchor split-debug builds From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Tanushree Shah , Michael Liang , Alessio Podda , Shimin Guo , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When resolving source lines via get_srcline(), srcline_dso_name() explicitly checks for and returns the split-debug file path (dso__symsrc_filename, which is cached during dso__load()) rather than the default executable path (dso__long_name). Because libdw__addr2line defaulted to dso__long_name without accepting a passed dso_name, the Dwfl_Module was hardcoded to initialize against the stripped executable instead of the intended split debug file. By explicitly passing the successfully resolved dso_name down the call path from addr2line() to dso__libdw_dwfl(), libdw accurately anchors to the dynamically discovered split-debug file, fixing dwarf resolution for these binaries. Assisted-by: Antigravity:gemini-3.6-flash Signed-off-by: Ian Rogers --- tools/perf/arch/powerpc/util/skip-callchain-idx.c | 2 +- tools/perf/util/dso.h | 5 +++-- tools/perf/util/libdw.c | 10 +++++----- tools/perf/util/libdw.h | 5 +++-- tools/perf/util/srcline.c | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf= /arch/powerpc/util/skip-callchain-idx.c index e57f10798fa6..f7dd27faaec2 100644 --- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c +++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c @@ -152,7 +152,7 @@ static int check_return_addr(struct dso *dso, Dwarf_Add= r mapped_pc) Dwarf_Addr end =3D mapped_pc; bool signalp; =20 - dwfl =3D dso__libdw_dwfl(dso); + dwfl =3D dso__libdw_dwfl(dso, NULL); if (!dwfl) return -1; =20 diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 55c4aaa53c38..3271e1ecaa9e 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -380,9 +380,10 @@ static inline void dso__set_libdw(struct dso *dso, voi= d *val) =20 struct Dwfl; #ifdef HAVE_LIBDW_SUPPORT -struct Dwfl *dso__libdw_dwfl(struct dso *dso); +struct Dwfl *dso__libdw_dwfl(struct dso *dso, const char *dso_name); #else -static inline struct Dwfl *dso__libdw_dwfl(struct dso *dso __maybe_unused) +static inline struct Dwfl *dso__libdw_dwfl(struct dso *dso __maybe_unused, + const char *dso_name __maybe_unused) { return NULL; } diff --git a/tools/perf/util/libdw.c b/tools/perf/util/libdw.c index 4ca7e7e4fbe9..f53caee980b0 100644 --- a/tools/perf/util/libdw.c +++ b/tools/perf/util/libdw.c @@ -25,17 +25,17 @@ void dso__free_libdw(struct dso *dso) } } =20 -struct Dwfl *dso__libdw_dwfl(struct dso *dso) +struct Dwfl *dso__libdw_dwfl(struct dso *dso, const char *dso_name) { Dwfl *dwfl =3D dso__libdw(dso); - const char *dso_name; Dwfl_Module *mod; int fd; =20 if (dwfl) return dwfl; =20 - dso_name =3D dso__long_name(dso); + if (!dso_name) + dso_name =3D dso__long_name(dso); /* * Initialize Dwfl session. * We need to open the DSO file to report it to libdw. @@ -163,11 +163,11 @@ static int libdw_a2l_cb(Dwarf_Die *die, void *_args) return DWARF_CB_ABORT; } =20 -int libdw__addr2line(u64 addr, char **file, unsigned int *line_nr, +int libdw__addr2line(const char *dso_name, u64 addr, char **file, unsigned= int *line_nr, struct dso *dso, bool unwind_inlines, struct inline_node *node, struct symbol *sym) { - Dwfl *dwfl =3D dso__libdw_dwfl(dso); + Dwfl *dwfl =3D dso__libdw_dwfl(dso, dso_name); Dwfl_Module *mod; Dwfl_Line *dwline; Dwarf_Addr bias; diff --git a/tools/perf/util/libdw.h b/tools/perf/util/libdw.h index b12094737415..4bdd28d44e25 100644 --- a/tools/perf/util/libdw.h +++ b/tools/perf/util/libdw.h @@ -25,7 +25,7 @@ struct symbol; * * Returns 1 on success (found), 0 on failure (not found). */ -int libdw__addr2line(u64 addr, char **file, +int libdw__addr2line(const char *dso_name, u64 addr, char **file, unsigned int *line_nr, struct dso *dso, bool unwind_inlines, struct inline_node *node, struct symbol *sym); @@ -40,7 +40,8 @@ void dso__free_libdw(struct dso *dso); =20 #else /* HAVE_LIBDW_SUPPORT */ =20 -static inline int libdw__addr2line(u64 addr __maybe_unused, char **file __= maybe_unused, +static inline int libdw__addr2line(const char *dso_name, u64 addr __maybe_= unused, + char **file __maybe_unused, unsigned int *line_nr __maybe_unused, struct dso *dso __maybe_unused, bool unwind_inlines __maybe_unused, diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index b082178c279b..8e954f0c860a 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -155,7 +155,7 @@ static int addr2line(const char *dso_name, u64 addr, ch= ar **file, unsigned int * for (size_t i =3D 0; i < ARRAY_SIZE(symbol_conf.addr2line_style); i++) { switch (symbol_conf.addr2line_style[i]) { case A2L_STYLE_LIBDW: - ret =3D libdw__addr2line(addr, file, line_nr, dso, unwind_inlines, + ret =3D libdw__addr2line(dso_name, addr, file, line_nr, dso, unwind_inl= ines, node, sym); break; case A2L_STYLE_LLVM: --=20 2.55.0.766.g2966f0265a-goog From nobody Mon Sep 28 09:58:47 2026 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (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 8EDE93AD52B for ; Mon, 24 Aug 2026 06:28:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.70 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787552933; cv=none; b=D0KHG2voxXHSM15oi10FQzEXlaCTIlO6oqAGtULNsyrombSssZgdWJJyyO8WDY60OAoWan+fRBUDQt1eR5ko/UO4AkN3OX/CMJwRMFAlRDstkHeMA4/q+GcaoflKLS+zCN0ghZytgkHKLpt9uETnH8zl7T5NAC3DFOZGmQjj04M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787552933; c=relaxed/simple; bh=4eWUqLwBnzO/oAAgJK7XoceNIi25ziducW/VGCAJXck=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=Q+vYVgm9ufmcO6hURt3mG18qS63uBeJqps47kVKeXd+KdkOB6lwpW8zYaVhfEm7oQYYvpB0dddBXgsRd9pRXhGOgCo1eRzF2FAttoCP4jeQG6T/AE/33pM2xG9yZa1VHEEz+9kYr7YacWSTGcfw0hxtVF5d4x8TO1bMfzBoM1Rs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=HC5FqISB; arc=none smtp.client-ip=209.85.216.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HC5FqISB" Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-38e5a616d07so3815637a91.2 for ; Sun, 23 Aug 2026 23:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787552931; x=1788157731; darn=vger.kernel.org; h=content-type:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=/RJSinviL1rUCPbdWLEv3+LGdZL1Zd0kdSRn2umOLqM=; b=HC5FqISBVld/qjicU0puH9Qd6mae6KaSnrQ3ST9o+NdbX5oDmK0cFeSk2q3dvvPbVn s0MYyRN/efmrWM3XBQHB8lZ5R/J8WM3GVouKtqdkJZRTXh9w+dwDNvvPv5J1mJf15YKv UCbcQ7LaEFdMp2mzJoj8wWaCBnQgYTVUYW/h0i3+sIvNCHYjSuQlQGqcqGquzxu819gK cl15Y8pN/cxsfGDdM+z3zwPzqY/1cxG539ZjSfHejCY6mX30zKtG4zdDumWOI7UJjVrS vFx3IOFIgkrnzA8GhbxRHVlHxp77F6K1VLByFMkue26qH53bVx6cO3Ug9J+TwsCkl+4k f9Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787552931; x=1788157731; h=content-type:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/RJSinviL1rUCPbdWLEv3+LGdZL1Zd0kdSRn2umOLqM=; b=lfYycvP2iB5tpPgvRMN7UgXxdDQ/IHK1Nf+tb+roIWBOBcy2Km2caP+m51Z2MI+uF6 VWUK3p7FfjguJ07NtVadXjYeLGMDF6fMh/D1VrVjaNdnQXTtcDyaR9A60ByaflNOG5kP vJtb7vdSEzAdKzlQ8b+OMHtR6lWfHZADti45tKYAclyHcj5N3qwI8DoQ2kHobHprmbo+ 3tqU6quykKRvnBVD6/uF9IbUWtPfNNu2FpC1q4hOWXGY7JSJMAHg2EnPEx+vNibrrxZL mlV8V4bOzuZ+F7ennkXVRihPhgNlPmnJG0h7APsiHFU7u12+QbFonkvjJFgtTgzQAx0g Xnhw== X-Forwarded-Encrypted: i=1; AHgh+Ro/VCdVGmQiwGxKdoJ6qHW7AHHZBplty0BQddtK8bJ/3I9MGK1B6zhIpXA6NeouhXcocHUZBO9O2dXdUgY=@vger.kernel.org X-Gm-Message-State: AFuF++mCM4nfZ0YD5HFJA3IHi1xpzL2cu6svWYYpr7nSI9/wEDNVTNw9 u5jJkhM6u+3NazPEPsMsJIz5UvPh5MAYeuVqJz0oXievfiODCuhnYQQKd6fUtOtcvDssqH8vT7a ABs7npYg+jA== X-Received: from dlbrc13.prod.google.com ([2002:a05:7022:ea8d:b0:141:48ce:1002]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1b42:b0:37f:fd1f:d30f with SMTP id 98e67ed59e1d1-395c3a06ffcmr40283068a91.12.1787552930721; Sun, 23 Aug 2026 23:28:50 -0700 (PDT) Date: Sun, 23 Aug 2026 23:28:41 -0700 In-Reply-To: <20260824062841.1529489-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260824062841.1529489-1-irogers@google.com> X-Mailer: git-send-email 2.55.0.766.g2966f0265a-goog Message-ID: <20260824062841.1529489-3-irogers@google.com> Subject: [PATCH v1 2/2] perf libdw: Optimize fallback logic for missing DWARF From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Tanushree Shah , Michael Liang , Alessio Podda , Shimin Guo , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When libdw encounters a DWARF definition it cannot accurately un-inline or an address block natively missing structural line maps, dwfl_module_getsrc() falls back immediately with 0. This causes perf's addr2line_style loop to fall back to launching the cmd__addr2line() sub-process wrapper. In environments generating massive numbers of unmapped traces, this forces thousands of redundant `addr2line -e` fork/execs in a polling loop. This patch intercepts failure scenarios: 1. Returns -1 when dwfl_module_getsrc() returns NULL (meaning the DWARF is parsed but the line mapping is natively missing). 2. Evaluates `ret < 0` in addr2line() to dynamically bypass the subprocess fallback and return 0. This precisely acts as a failure condition, incrementing the dso->a2l_fails counter and accurately triggering the A2L_FAIL_LIMIT throttling without shelling out. 3. Incorporates exact error string checking for "no DWARF" to safely abort alternative fallbacks directly within both libdw resolving and the unwinder logic (unwind-libdw). This preserves fallbacks if unwinder or DWARF parsing genuinely aborts, but avoids falling back when mappings are absent. Assisted-by: Antigravity:gemini-3.6-flash Signed-off-by: Ian Rogers --- tools/perf/util/libdw.c | 11 +++++++++-- tools/perf/util/srcline.c | 2 ++ tools/perf/util/unwind-libdw.c | 15 ++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/libdw.c b/tools/perf/util/libdw.c index f53caee980b0..7c681b03c654 100644 --- a/tools/perf/util/libdw.c +++ b/tools/perf/util/libdw.c @@ -186,8 +186,15 @@ int libdw__addr2line(const char *dso_name, u64 addr, c= har **file, unsigned int * * between the regular ELF addr2line addresses and those to use with * libdw. */ - if (!dwfl_module_getdwarf(mod, &bias)) - return 0; + if (!dwfl_module_getdwarf(mod, &bias)) { + const char *err =3D dwfl_errmsg(-1); + + /* + * Abort fallbacks specifically when DWARF is completely missing, + * but allow alternative backends to try if parsing failed. + */ + return (err && strstr(err, "no DWARF")) ? -1 : 0; + } =20 /* Find source line information for the address. */ dwline =3D dwfl_module_getsrc(mod, addr + bias); diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index 8e954f0c860a..8283a741c018 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -176,6 +176,8 @@ static int addr2line(const char *dso_name, u64 addr, ch= ar **file, unsigned int * } if (ret > 0) return ret; + if (ret < 0) + return 0; } =20 return 0; diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index 63a5c2253174..69d4585c870c 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c @@ -441,8 +441,17 @@ int libdw__get_entries(unwind_entry_cb_t cb, void *arg, } =20 out: - if (err) - pr_debug("unwind: failed with '%s'\n", dwfl_errmsg(-1)); + if (err) { + const char *msg =3D dwfl_errmsg(-1); + + pr_debug("unwind: failed with '%s'\n", msg); + /* + * Abort fallbacks specifically when unwinding information is completely + * missing, but allow fallback unwinders to try if parsing simply failed. + */ + if (msg && strstr(msg, "no DWARF")) + err =3D -EINVAL; + } =20 for (i =3D 0; i < ui->idx; i++) map_symbol__exit(&ui->entries[i].ms); @@ -460,6 +469,6 @@ int libdw__get_entries(unwind_entry_cb_t cb, void *arg, * < 0 : fatal error (e.g. -ENOMEM). Aborts unwinding entirely. */ if (err) - return (err =3D=3D -ENOMEM) ? -ENOMEM : (entries > 0 ? 1 : 0); + return (err =3D=3D -ENOMEM || err =3D=3D -EINVAL) ? err : (entries > 0 ?= 1 : 0); return entries; } --=20 2.55.0.766.g2966f0265a-goog