From: Sasha Levin <sashal@kernel.org>
To: Helge Deller <deller@gmx.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Masahiro Yamada <masahiroy@kernel.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Richard Weinberger <richard@nod.at>,
Juergen Gross <jgross@suse.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
James Bottomley <James.Bottomley@hansenpartnership.com>,
Jonathan Corbet <corbet@lwn.net>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>, Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Greg KH <gregkh@linuxfoundation.org>,
Petr Mladek <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>, Kees Cook <kees@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Thorsten Leemhuis <linux@leemhuis.info>,
Vlastimil Babka <vbabka@kernel.org>,
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
Date: Sun, 8 Mar 2026 14:38:26 -0400 [thread overview]
Message-ID: <aa3CIjVhSsQUXSej@laps> (raw)
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] <TASK>
>> [ 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 <sashal@kernel.org>
>
>Shows relative paths and works OK on 32- and 64-bit parisc kernel.
>You may add
>Tested-by: Helge Deller <deller@gmx.de>
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
next prev parent reply other threads:[~2026-03-08 18:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 17:20 [PATCH v2 0/4] kallsyms: embed source file:line info in kernel stack traces Sasha Levin
2026-03-07 17:20 ` [PATCH v2 1/4] " Sasha Levin
2026-03-07 21:41 ` Helge Deller
2026-03-08 18:38 ` Sasha Levin [this message]
2026-03-07 17:20 ` [PATCH v2 2/4] kallsyms: extend lineinfo to loadable modules Sasha Levin
2026-03-07 17:20 ` [PATCH v2 3/4] kallsyms: delta-compress lineinfo tables for ~2.7x size reduction Sasha Levin
2026-03-07 17:20 ` [PATCH v2 4/4] kallsyms: add KUnit tests for lineinfo feature Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aa3CIjVhSsQUXSej@laps \
--to=sashal@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=da.gomez@kernel.org \
--cc=deller@gmx.de \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=jgross@suse.com \
--cc=kees@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux@leemhuis.info \
--cc=masahiroy@kernel.org \
--cc=mcgrof@kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=peterz@infradead.org \
--cc=petr.pavlu@suse.com \
--cc=pmladek@suse.com \
--cc=rdunlap@infradead.org \
--cc=richard@nod.at \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.org \
--cc=vbabka@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox