All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>, Jessica Yu <jeyu@kernel.org>,
	Evan Green <evgreen@chromium.org>,
	Hsin-Yi Wang <hsinyi@chromium.org>,
	Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-doc@vger.kernel.org, Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH v2 04/12] module: Add printk format to add module build ID to stacktraces
Date: Wed, 24 Mar 2021 12:11:28 -0700	[thread overview]
Message-ID: <161661308874.3012082.15483899786731677633@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <6dfb8ca2-20f3-e58a-ad6b-db6a6472afe0@rasmusvillemoes.dk>

Quoting Rasmus Villemoes (2021-03-24 02:57:13)
> On 24/03/2021 03.04, Stephen Boyd wrote:
> 
> > @@ -2778,6 +2793,10 @@ static inline void layout_symtab(struct module *mod, struct load_info *info)
> >  static void add_kallsyms(struct module *mod, const struct load_info *info)
> >  {
> >  }
> > +
> > +static void init_build_id(struct module *mod, const struct load_info *info)
> > +{
> > +}
> >  #endif /* CONFIG_KALLSYMS */
> >  
> >  static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsigned int num)
> > @@ -4004,6 +4023,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
> >               goto free_arch_cleanup;
> >       }
> >  
> > +     init_build_id(mod, info);
> >       dynamic_debug_setup(mod, info->debug, info->num_debug);
> >  
> >       /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
> > @@ -4235,7 +4255,7 @@ void * __weak dereference_module_function_descriptor(struct module *mod,
> >  const char *module_address_lookup(unsigned long addr,
> >                           unsigned long *size,
> >                           unsigned long *offset,
> > -                         char **modname,
> > +                         char **modname, unsigned char **modbuildid,
> 
> It's an existing defect with modname, but surely this should take a
> "const unsigned char **modbuildid", no?

Sure.

> 
> >                           char *namebuf)
> >  {
> >       const char *ret = NULL;
> > @@ -4246,6 +4266,8 @@ const char *module_address_lookup(unsigned long addr,
> >       if (mod) {
> >               if (modname)
> >                       *modname = mod->name;
> > +             if (modbuildid)
> > +                     *modbuildid = mod->build_id;
> >  
> >               ret = find_kallsyms_symbol(mod, addr, size, offset);
> >       }
> > diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> > index 41ddc353ebb8..9cd62e84e4aa 100644
> > --- a/lib/vsprintf.c
> > +++ b/lib/vsprintf.c
> > @@ -961,13 +961,15 @@ char *symbol_string(char *buf, char *end, void *ptr,
> >       char sym[KSYM_SYMBOL_LEN];
> >  #endif
> >  
> > -     if (fmt[1] == 'R')
> > +     if (fmt[1] == 'R' || fmt[1] == 'r')
> >               ptr = __builtin_extract_return_addr(ptr);
> >       value = (unsigned long)ptr;
> >  
> >  #ifdef CONFIG_KALLSYMS
> >       if (*fmt == 'B')
> >               sprint_backtrace(sym, value);
> > +     else if (*fmt == 'S' && (fmt[1] == 'b' || fmt[1] == 'r'))
> > +             sprint_symbol_stacktrace(sym, value);
> >       else if (*fmt != 's')
> >               sprint_symbol(sym, value);
> >       else
> > @@ -2129,6 +2131,8 @@ early_param("no_hash_pointers", no_hash_pointers_enable);
> >   * - 'S' For symbolic direct pointers (or function descriptors) with offset
> >   * - 's' For symbolic direct pointers (or function descriptors) without offset
> >   * - '[Ss]R' as above with __builtin_extract_return_addr() translation
> > + * - '[Ss]r' as above with __builtin_extract_return_addr() translation and module build ID
> > + * - '[Ss]b' as above with module build ID (for use in backtraces)
> 
> The code doesn't quite match the comment. The lowercase s is not handled
> (i.e., there's no way to say "without offset, with build ID"). You don't
> have to fix the code to support that right now, the whole kallsyms
> vsprintf code needs to be reworked inside-out anyway (having vsnprint
> call sprint_symbol* which builds the output using snprintf() calls makes
> me cringe), so please just replace [Ss] by S to make the comment match
> the code - I notice that you did only document the S variant in
> printk-formats.rst.

No problem. Will fix this comment.

> 
> Is there any reason you didn't just make b an optional flag that could
> be specified with or without R? I suppose the parsing is more difficult
> with several orthogonal flags (see escaped_string()), but it's a little
> easier to understand. Dunno, it's not like we're gonna think of 10 other
> things that could be printed for a symbol, so perhaps it's fine.
> 

I think I follow. So %pSb or %pSRb? If it's easier to understand then
sure. I was trying to avoid checking another character beyond fmt[1] but
it should be fine if fmt[1] is already 'R'.

  reply	other threads:[~2021-03-24 19:12 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24  2:04 [PATCH v2 00/12] Add build ID to stacktraces Stephen Boyd
2021-03-24  2:04 ` Stephen Boyd
2021-03-24  2:04 ` Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 01/12] buildid: Add API to parse build ID out of buffer Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 02/12] buildid: Add method to get running kernel's build ID Stephen Boyd
2021-03-24  2:04   ` Stephen Boyd
2021-03-24  9:24   ` Rasmus Villemoes
2021-03-24  9:24     ` Rasmus Villemoes
2021-03-24 19:06     ` Stephen Boyd
2021-03-24 19:06       ` Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 03/12] dump_stack: Add vmlinux build ID to stack traces Stephen Boyd
2021-03-24 11:22   ` Andy Shevchenko
2021-03-24 19:01     ` Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 04/12] module: Add printk format to add module build ID to stacktraces Stephen Boyd
2021-03-24  9:57   ` Rasmus Villemoes
2021-03-24 19:11     ` Stephen Boyd [this message]
2021-03-24 22:21       ` Rasmus Villemoes
2021-03-24 22:28         ` Stephen Boyd
2021-03-30 10:51           ` Petr Mladek
2021-03-30 10:29   ` Petr Mladek
2021-03-30 19:12     ` Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 05/12] arm64: stacktrace: Use %pSb for backtrace printing Stephen Boyd
2021-03-24  2:04   ` Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 06/12] x86/dumpstack: " Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 07/12] scripts/decode_stacktrace.sh: Support debuginfod Stephen Boyd
2021-03-24 11:27   ` Andy Shevchenko
2021-03-24 22:22     ` Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 08/12] scripts/decode_stacktrace.sh: Silence stderr messages from addr2line/nm Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 09/12] scripts/decode_stacktrace.sh: Indicate 'auto' can be used for base path Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 10/12] buildid: Mark some arguments const Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 11/12] buildid: Fix kernel-doc notation Stephen Boyd
2021-03-24  2:04 ` [PATCH v2 12/12] kdump: Use vmlinux_build_id() to simplify Stephen Boyd
2021-03-24  2:04   ` Stephen Boyd
2021-03-24  8:55 ` [PATCH v2 00/12] Add build ID to stacktraces Christoph Hellwig
2021-03-24  8:55   ` Christoph Hellwig
2021-03-24  8:55   ` Christoph Hellwig
2021-03-25 11:06   ` peter enderborg
2021-03-25 11:06     ` peter enderborg
2021-03-25 11:06     ` peter enderborg
2021-03-25 23:21     ` Stephen Boyd
2021-03-25 23:21       ` Stephen Boyd
2021-03-25 23:21       ` Stephen Boyd
2021-03-30 10:59       ` Petr Mladek
2021-03-30 10:59         ` Petr Mladek
2021-03-30 10:59         ` Petr Mladek
     [not found] ` <32011616573677@mail.yandex-team.ru>
2021-03-24 19:04   ` Stephen Boyd
2021-03-24 19:04     ` Stephen Boyd
2021-03-24 19:04     ` Stephen Boyd
2021-03-25 11:14 ` peter enderborg
2021-03-25 11:14   ` peter enderborg
2021-03-25 11:14   ` peter enderborg
2021-03-25 23:18   ` Stephen Boyd
2021-03-25 23:18     ` Stephen Boyd
2021-03-25 23:18     ` Stephen Boyd

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=161661308874.3012082.15483899786731677633@swboyd.mtv.corp.google.com \
    --to=swboyd@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ast@kernel.org \
    --cc=evgreen@chromium.org \
    --cc=hsinyi@chromium.org \
    --cc=jeyu@kernel.org \
    --cc=jolsa@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.