From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2FA2433344C; Sun, 8 Mar 2026 18:38:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772995108; cv=none; b=AKGT6JY09XsHcIy4htN3JlJH60Y14qS0kmCtt84FehA/nZVkHJptGgzkU9sW2qSY58A1pEMzncW3ohPC7/3ByCiW1/vxdg30eg9a9LJSCF4BsAW8Sy6TOpXFN+9EMI7691F5FQpSvnXO8HNk10OZQWinCcj1GOCZA63Hi4Z50oI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772995108; c=relaxed/simple; bh=jZJBIlksgatlFHsMEq+0aBvFqu9v03d1c2RJYYj3/Vw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dYTUq7dQ7zqCAtabLk0Z5qbDhfQc8+oCvLFIGqbe4nvq27MXgm7si51Jm6sWjlhkEa7IfShH+OQSmSpZGy5mLD0ZwoFVR9gGH60/BUyvy/u72/V3eQ24G/xPJQ4R16X0suMUSY7XNaDCnPkLtCq7W1el8fTHIJS90fHZrREWHJk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZdlCCoG6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZdlCCoG6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71AEAC116C6; Sun, 8 Mar 2026 18:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772995107; bh=jZJBIlksgatlFHsMEq+0aBvFqu9v03d1c2RJYYj3/Vw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZdlCCoG6Ebyt/aF+JtWn7ConBk0iCh3KFkGnTKE7yJGso4f70z61PDqQtRXrEOvn2 +D+NCfDBND9QYYPFr66KckKOiSR3m0BQhweE79tNRn93I4FRQXoq6ZKxKoMywkv6fG 58+nryM1wSgC25gN5Vo3PMjWHJPatD085BEbVbAQkOwyCHW6nSZ3B272MaIDA7+oX6 Wjh0NMvkNbAq29M3izmciA6W9WXnJUws4C0qPWRd11j5Yk5e0boHvq2MrXovrJbyXe PZKUwnTHoVX6Hq1byo/tE/oypmbk8JJ7+VS1/tE76gWKfhc0dijkSg0SWLt/e4DO1Z /6tTN6EBTF5xA== Date: Sun, 8 Mar 2026 14:38:26 -0400 From: Sasha Levin To: Helge Deller Cc: Andrew Morton , Masahiro Yamada , Luis Chamberlain , Linus Torvalds , Richard Weinberger , Juergen Gross , Geert Uytterhoeven , James Bottomley , Jonathan Corbet , Nathan Chancellor , Nicolas Schier , Petr Pavlu , Daniel Gomez , Greg KH , Petr Mladek , Steven Rostedt , Kees Cook , Peter Zijlstra , Thorsten Leemhuis , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-doc@vger.kernel.org, rdunlap@infradead.org, laurent.pinchart@ideasonboard.com Subject: Re: [PATCH v2 1/4] kallsyms: embed source file:line info in kernel stack traces Message-ID: References: <20260307172022.460402-1-sashal@kernel.org> <20260307172022.460402-2-sashal@kernel.org> <3ab0cad6-bf55-4ae5-afb7-d9129ac2032e@gmx.de> 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=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <3ab0cad6-bf55-4ae5-afb7-d9129ac2032e@gmx.de> On Sat, Mar 07, 2026 at 10:41:20PM +0100, Helge Deller wrote: >Hi Sasha, > >On 3/7/26 18:20, Sasha Levin wrote: >>Add CONFIG_KALLSYMS_LINEINFO, which embeds a compact address-to-line >>lookup table in the kernel image so stack traces directly print source >>file and line number information: >> >> root@localhost:~# echo c > /proc/sysrq-trigger >> [ 11.201987] sysrq: Trigger a crash >> [ 11.202831] Kernel panic - not syncing: sysrq triggered crash >> [ 11.206218] Call Trace: >> [ 11.206501] >> [ 11.206749] dump_stack_lvl+0x5d/0x80 (lib/dump_stack.c:94) >> [ 11.207403] vpanic+0x36e/0x620 (kernel/panic.c:650) >> [ 11.208565] ? __lock_acquire+0x465/0x2240 (kernel/locking/lockdep.c:4674) >>[...] >> >>Assisted-by: Claude:claude-opus-4-6 >>Signed-off-by: Sasha Levin > >Shows relative paths and works OK on 32- and 64-bit parisc kernel. >You may add >Tested-by: Helge Deller Thanks for testing! I'm happy the regression was fixed. >A few notes/suggestions below.... > > >>--- >> Documentation/admin-guide/index.rst | 1 + >> .../admin-guide/kallsyms-lineinfo.rst | 72 +++ >> MAINTAINERS | 6 + >> include/linux/kallsyms.h | 32 +- >> init/Kconfig | 20 + >> kernel/kallsyms.c | 61 +++ >> kernel/kallsyms_internal.h | 11 + >> scripts/.gitignore | 1 + >> scripts/Makefile | 3 + >> scripts/gen_lineinfo.c | 510 ++++++++++++++++++ >> scripts/kallsyms.c | 16 + >> scripts/link-vmlinux.sh | 70 ++- >> 12 files changed, 799 insertions(+), 4 deletions(-) >> create mode 100644 Documentation/admin-guide/kallsyms-lineinfo.rst >> create mode 100644 scripts/gen_lineinfo.c > >>diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c >>index aec2f06858afd..c94d8f332c5df 100644 >>--- a/kernel/kallsyms.c >>+++ b/kernel/kallsyms.c >>@@ -467,6 +467,54 @@ static int append_buildid(char *buffer, const char *modname, >> #endif /* CONFIG_STACKTRACE_BUILD_ID */ >>+#ifdef CONFIG_KALLSYMS_LINEINFO >>+bool kallsyms_lookup_lineinfo(unsigned long addr, unsigned long sym_start, >>+ const char **file, unsigned int *line) >>+{ >>+ unsigned long long raw_offset; >>+ unsigned int offset, low, high, mid, file_id; >>+ >>+ if (!lineinfo_num_entries) >>+ return false; > >The "#ifdef CONFIG_KALLSYMS_LINEINFO" above prevents that this function >is compiled when the option is disabled. > >Instead, you *could* move the "CONFIG_KALLSYMS_LINEINFO" option into >the function with "IS_ENABLED()", like this...: >+ if (!IS_ENABLED(CONFIG_KALLSYMS_LINEINFO) || !lineinfo_num_entries) >+ return false; > >That way your code will always be compiled, and the code will be optimized >away by the compiler if the option is disabled. The huge benefit is, that >the compiler will do syntax-checking at every build, so you will see coding >bugs early. > >You could use the same semantic at other places in your patches, and of >course you then need to remove the #ifdef ... Ack, this makes sense. I'll do it in the v3 if it's needed. -- Thanks, Sasha