From nobody Sun Feb 8 05:34:59 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEEBC7C081; Mon, 8 Jul 2024 11:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720439369; cv=none; b=ACNUhdKLoFyJghw7x2rEsq+g2VTVqDfPr0BWv2QcacAR5sd1qW4bOkklG3BvMLbFuWdr4f0/+giwZSzgvDaEqUdcoZsRvCtXCTXulm8gEJjGKgp0L9gHYdYWU84Su4YZh/VRv1xrrLkWVfqDLT/K0BRGe/bLeFxDxzyQ+DA9ttE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720439369; c=relaxed/simple; bh=FtaFVALYwIkUsySau/heuV6WhTmm4OoeH3g3/VEnOdY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=hzMh539OOBPcSz++R8h4MQCuVKEayfDrpGNRX+4Co7Bk/56vOq/PdQ3XW+0oFV9Q5J3cxltq8sSL4Ks4MsFZS4pNuYTg11XOE6BUegGWBcvYC9lhIsmeghOF+8gvgB0VSC3Kzb5Z+URrAA/fYuWhlXUWwZD75FZEsgv9s6VWxuk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=MUyY6MBT; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=j/8rNp0/; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="MUyY6MBT"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="j/8rNp0/" Date: Mon, 08 Jul 2024 11:49:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1720439365; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uf2CQnkVDyheqTK58lLBnpwbPOAH4iRIW4ujULuE+WA=; b=MUyY6MBT1+3qKsOPcmlBNyJeU8g3/rB2kg507O8PMQfH1jkE/2ulwtfSNxO37zI7yn+VXt BRSt+i+QtqirEXPZ3RVGI4/qJZlRk/Q7Q3j89PJw/37QLnc8w2NcQXv7WZWWxRVtTPOyAW IjffXjIepe8Qsjd/AeqKZpiUPfn3KW4VJMkcFH+mzE2zunS6buzKi2J0c2HsR3YW+L9CW/ kcpFJ82XIMmat4Ii/GsOlQ20Vfre4/jahRO1UAw9BYyVHEDCMxGQl4mro+c8q0J0QDLUcW kC6AjhIQAhXyuDg0rjHYEFupRAdlA1d67G550HxyXJVNcicP22cE97RukoVdxg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1720439365; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uf2CQnkVDyheqTK58lLBnpwbPOAH4iRIW4ujULuE+WA=; b=j/8rNp0/JAjpnMUx9f7EvPHfRMRqeNW63keVH5cis3p5aExF2tU87R59glA9HmvG0UxYgz KfuIAmr008A6KiCg== From: "tip-bot2 for Brian Johannesmeyer" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] scripts/faddr2line: Invoke addr2line as a single long-running process Cc: Brian Johannesmeyer , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240415145538.1938745-6-bjohannesmeyer@gmail.com> References: <20240415145538.1938745-6-bjohannesmeyer@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <172043936543.2215.9070138494709130266.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the objtool/core branch of tip: Commit-ID: e36b69e918112430ee53e24238bb87f5146f9acf Gitweb: https://git.kernel.org/tip/e36b69e918112430ee53e24238bb87f51= 46f9acf Author: Brian Johannesmeyer AuthorDate: Mon, 15 Apr 2024 16:55:36 +02:00 Committer: Josh Poimboeuf CommitterDate: Tue, 02 Jul 2024 23:38:36 -07:00 scripts/faddr2line: Invoke addr2line as a single long-running process Rather than invoking a separate addr2line process for each address, invoke a single addr2line coprocess, and pass each address to its stdin. Previous work [0] applied a similar change to perf, leading to a ~60x speed-up [1]. If using an object file that is _not_ vmlinux, faddr2line passes a section name argument to addr2line. Because we do not know until runtime which section names will be passed to addr2line, we cannot apply this change to non-vmlinux object files. Hence, it only applies to vmlinux. [0] commit be8ecc57f180 ("perf srcline: Use long-running addr2line per DSO") [1] Link: https://eighty-twenty.org/2021/09/09/perf-addr2line-speed-improvement Signed-off-by: Brian Johannesmeyer Link: https://lore.kernel.org/r/20240415145538.1938745-6-bjohannesmeyer@gma= il.com Signed-off-by: Josh Poimboeuf --- scripts/faddr2line | 52 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/scripts/faddr2line b/scripts/faddr2line index 820680c..48fc8cf 100755 --- a/scripts/faddr2line +++ b/scripts/faddr2line @@ -126,6 +126,48 @@ check_vmlinux() { fi } =20 +init_addr2line() { + local objfile=3D$1 + + check_vmlinux + + ADDR2LINE_ARGS=3D"--functions --pretty-print --inlines --addresses --exe= =3D$objfile" + if [[ $IS_VMLINUX =3D 1 ]]; then + # If the executable file is vmlinux, we don't pass section names to + # addr2line, so we can launch it now as a single long-running process. + coproc ADDR2LINE_PROC (${ADDR2LINE} ${ADDR2LINE_ARGS}) + fi +} + +run_addr2line() { + local addr=3D$1 + local sec_name=3D$2 + + if [[ $IS_VMLINUX =3D 1 ]]; then + # We send to the addr2line process: (1) the address, then (2) a sentinel + # value, i.e., something that can't be interpreted as a valid address + # (i.e., ","). This causes addr2line to write out: (1) the answer for + # our address, then (2) either "?? ??:0" or "0x0...0: ..." (if + # using binutils' addr2line), or "," (if using LLVM's addr2line). + echo ${addr} >& "${ADDR2LINE_PROC[1]}" + echo "," >& "${ADDR2LINE_PROC[1]}" + local first_line + read -r first_line <& "${ADDR2LINE_PROC[0]}" + ADDR2LINE_OUT=3D$(echo "${first_line}" | sed 's/^0x[0-9a-fA-F]*: //') + while read -r line <& "${ADDR2LINE_PROC[0]}"; do + if [[ "$line" =3D=3D "?? ??:0" ]] || [[ "$line" =3D=3D "," ]] || [[ $(e= cho "$line" | ${GREP} "^0x00*: ") ]]; then + break + fi + ADDR2LINE_OUT+=3D$'\n'$(echo "$line" | sed 's/^0x[0-9a-fA-F]*: //') + done + else + # Run addr2line as a single invocation. + local sec_arg + [[ -z $sec_name ]] && sec_arg=3D"" || sec_arg=3D"--section=3D${sec_name}" + ADDR2LINE_OUT=3D$(${ADDR2LINE} ${ADDR2LINE_ARGS} ${sec_arg} ${addr} | se= d 's/^0x[0-9a-fA-F]*: //') + fi +} + __faddr2line() { local objfile=3D$1 local func_addr=3D$2 @@ -260,12 +302,8 @@ __faddr2line() { =20 # Pass section address to addr2line and strip absolute paths # from the output: - local args=3D"--functions --pretty-print --inlines --addresses --exe=3D$= objfile" - [[ $IS_VMLINUX =3D 0 ]] && args=3D"$args --section=3D$sec_name" - local output_with_addr=3D$(${ADDR2LINE} $args $addr | sed "s; $dir_prefi= x\(\./\)*; ;") - [[ -z $output_with_addr ]] && continue - - local output=3D$(echo "${output_with_addr}" | sed 's/^0x[0-9a-fA-F]*: //= ') + run_addr2line $addr $sec_name + local output=3D$(echo "${ADDR2LINE_OUT}" | sed "s; $dir_prefix\(\./\)*; = ;") [[ -z $output ]] && continue =20 # Default output (non --list): @@ -309,7 +347,7 @@ run_readelf $objfile =20 echo "${ELF_SECHEADERS}" | ${GREP} -q '\.debug_info' || die "CONFIG_DEBUG_= INFO not enabled" =20 -check_vmlinux +init_addr2line $objfile =20 DIR_PREFIX=3Dsupercalifragilisticexpialidocious find_dir_prefix $objfile