From: Helge Deller <deller@gmx.de>
To: Sasha Levin <sashal@kernel.org>,
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>
Cc: 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: Sat, 7 Mar 2026 22:41:20 +0100 [thread overview]
Message-ID: <3ab0cad6-bf55-4ae5-afb7-d9129ac2032e@gmx.de> (raw)
In-Reply-To: <20260307172022.460402-2-sashal@kernel.org>
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>
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 ...
> diff --git a/kernel/kallsyms_internal.h b/kernel/kallsyms_internal.h
> index 81a867dbe57d4..982557aeff28d 100644
> --- a/kernel/kallsyms_internal.h
> +++ b/kernel/kallsyms_internal.h
> @@ -15,4 +15,15 @@ extern const u16 kallsyms_token_index[];
> extern const unsigned int kallsyms_markers[];
> extern const u8 kallsyms_seqs_of_names[];
>
> +#ifdef CONFIG_KALLSYMS_LINEINFO
> +extern const u32 lineinfo_num_entries;
> +extern const u32 lineinfo_addrs[];
^^ for exampe here...
Helge
next prev parent reply other threads:[~2026-03-07 21:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 17:20 [PATCH v2 0/4] " Sasha Levin
2026-03-07 17:20 ` [PATCH v2 1/4] " Sasha Levin
2026-03-07 21:41 ` Helge Deller [this message]
2026-03-08 18:38 ` Sasha Levin
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=3ab0cad6-bf55-4ae5-afb7-d9129ac2032e@gmx.de \
--to=deller@gmx.de \
--cc=James.Bottomley@HansenPartnership.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=da.gomez@kernel.org \
--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=sashal@kernel.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
all inboxes | Powered by JetHome®