From mboxrd@z Thu Jan 1 00:00:00 1970 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-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, char **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 = 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; + } /* Find source line information for the address. */ dwline = 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, char **file, unsigned int * } if (ret > 0) return ret; + if (ret < 0) + return 0; } 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, } out: - if (err) - pr_debug("unwind: failed with '%s'\n", dwfl_errmsg(-1)); + if (err) { + const char *msg = 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 = -EINVAL; + } for (i = 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 == -ENOMEM) ? -ENOMEM : (entries > 0 ? 1 : 0); + return (err == -ENOMEM || err == -EINVAL) ? err : (entries > 0 ? 1 : 0); return entries; } -- 2.55.0.766.g2966f0265a-goog