From: Petr Mladek <pmladek@suse.com>
To: Maninder Singh <maninder1.s@samsung.com>
Cc: rostedt@goodmis.org, senozhatsky@chromium.org,
andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk,
akpm@linux-foundation.org, wangkefeng.wang@huawei.com,
mbenes@suse.cz, swboyd@chromium.org, ojeda@kernel.org,
linux-kernel@vger.kernel.org, will@kernel.org,
catalin.marinas@arm.com, Vaneet Narang <v.narang@samsung.com>,
Aaron Tomlin <atomlin@redhat.com>,
Luis Chamberlain <mcgrof@kernel.org>
Subject: Re: [PATCH 1/1] kallsyms: print module name in %ps/S case when KALLSYMS is disabled
Date: Wed, 9 Feb 2022 12:40:38 +0100 [thread overview]
Message-ID: <20220209114038.GA8279@pathway.suse.cz> (raw)
In-Reply-To: <20220201040044.1528568-1-maninder1.s@samsung.com>
On Tue 2022-02-01 09:30:44, Maninder Singh wrote:
> original:
> With KALLSYMS
> %pS %ps
> [16.4200] hello_init+0x0/0x24 [crash] hello_init [crash]
>
> Without KALLSYMS:
> [16.2200] 0xbe200040 0xbe200040
>
> With Patch (Without KALLSYMS:) load address + current offset [Module Name]
>
> [13.5993] 0xbe200000+0x40 [crash] 0xbe200000+0x40 [crash]
>
> It will help in better debugging and checking when KALLSYMS is disabled,
> user will get information about module name and load address of module.
>
> verified for arm64:
> / # insmod /crash.ko
>
> [ 19.263556] 0xffff800000ec0000+0x38 [crash]
>
> ..
>
> [ 19.276023] Call trace:
> [ 19.276277] 0xffff800000ec0000+0x28 [crash]
> [ 19.276567] 0xffff800000ec0000+0x58 [crash]
> [ 19.276727] 0xffff800000ec0000+0x74 [crash]
> [ 19.276866] 0xffff8000080127d0
> [ 19.276978] 0xffff80000812d95c
> [ 19.277085] 0xffff80000812f554
The idea is great. But the patch will need some changes, see below.
> --- a/include/linux/kallsyms.h
> +++ b/include/linux/kallsyms.h
> @@ -163,6 +163,33 @@ static inline bool kallsyms_show_value(const struct cred *cred)
> return false;
> }
>
> +#ifdef CONFIG_MODULES
> +static inline int fill_minimal_module_info(char *sym, int size, unsigned long value)
> +{
> + struct module *mod;
> + unsigned long offset;
> + int ret = 0;
> +
> + preempt_disable();
> + mod = __module_address(value);
> + if (mod) {
> + offset = value - (unsigned long)mod->core_layout.base;
> + snprintf(sym, size - 1, "0x%lx+0x%lx [%s]",
> + (unsigned long)mod->core_layout.base, offset, mod->name);
> +
> + sym[size - 1] = '\0';
> + ret = 1;
> + }
> +
> + preempt_enable();
> + return ret;
> +}
It looks too big for an inlined function. Anyway, we will need
something even more complex, see below.
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 61528094ec87..41c74abb1726 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1007,6 +1005,9 @@ char *symbol_string(char *buf, char *end, void *ptr,
>
> return string_nocheck(buf, end, sym, spec);
> #else
> + if (fill_minimal_module_info(sym, KSYM_SYMBOL_LEN, value))
> + return string_nocheck(buf, end, sym, spec);
The behavior should be different for different modifiers. Namely:
+ the offset is not printed for %ps // lower-case 's'
+ the address must be searched with offset -1 for %pB // on stack
+ build ID should be appended when 'b' modifier is appeanded
IMHO, we should implement a generic __sprint_symbol() that will
find the information using kallsyms_lookup_buildid() when available
and fallback to the mininalized approach when kallsyms are not available.
It might require moving the code out of kallsyms.c. It should be
co-ordinated with the other patchset that is moving these sources
into kernel/module/*, see
https://lore.kernel.org/r/20220130213214.1042497-1-atomlin@redhat.com
Adding Aaron and Luis into Cc.
Best Regards,
Petr
next prev parent reply other threads:[~2022-02-09 12:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220201040100epcas5p180ef094058fc9c76b4b94d9d673fc5fc@epcas5p1.samsung.com>
2022-02-01 4:00 ` Maninder Singh
2022-02-01 9:45 ` Andy Shevchenko
[not found] ` <CGME20220201040100epcas5p180ef094058fc9c76b4b94d9d673fc5fc@epcms5p7>
2022-02-01 10:24 ` Maninder Singh
2022-02-09 11:40 ` Petr Mladek [this message]
2022-02-09 23:02 ` Luis Chamberlain
2022-02-10 8:19 ` Petr Mladek
[not found] ` <CGME20220201040100epcas5p180ef094058fc9c76b4b94d9d673fc5fc@epcms5p4>
2022-02-10 8:48 ` Maninder Singh
2022-02-11 1:37 ` Luis Chamberlain
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=20220209114038.GA8279@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=atomlin@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=maninder1.s@samsung.com \
--cc=mbenes@suse.cz \
--cc=mcgrof@kernel.org \
--cc=ojeda@kernel.org \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=swboyd@chromium.org \
--cc=v.narang@samsung.com \
--cc=wangkefeng.wang@huawei.com \
--cc=will@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®