Re: [PATCH 3/6] x86/dumpstack: make printk_stack_address() more generally useful

From: Josh Poimboeuf
Date: Wed Aug 24 2016 - 14:43:49 EST


On Wed, Aug 24, 2016 at 10:28:38AM -0700, Joe Perches wrote:
> On Wed, 2016-08-24 at 11:50 -0500, Josh Poimboeuf wrote:
> > Change printk_stack_address() to be useful when called by an unwinder
> > outside the context of dump_trace().
> >
> > Specifically:
> >
> > - printk_stack_address()'s 'data' argument is always used as the log
> > Â level string.ÂÂMake that explicit.
>
> If this is true, and I'm not sure it is as I believe
> there are static strings emitted like EOE and IRQ,
> shouldn't this bubble up through the calling tree?
>
> > - Call touch_nmi_watchdog().
> []
> > diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
> []
> > @@ -26,10 +26,11 @@ int kstack_depth_to_print = 3 * STACKSLOTS_PER_LINE;
> > Âstatic int die_counter;
> > Â
> > Âstatic void printk_stack_address(unsigned long address, int reliable,
> > - void *data)
> > + Âchar *log_lvl)
> > Â{
> > + touch_nmi_watchdog();
> > Â printk("%s [<%p>] %s%pB\n",
> > - (char *)data, (void *)address, reliable ? "" : "? ",
> > + log_lvl, (void *)address, reliable ? "" : "? ",
> > Â (void *)address);
> > Â}
> > Â
> > @@ -148,7 +149,6 @@ static int print_trace_stack(void *data, char *name)
> > Â */
> > Âstatic int print_trace_address(void *data, unsigned long addr, int reliable)
> > Â{
> > - touch_nmi_watchdog();
> > Â printk_stack_address(addr, reliable, data);
> > Â return 0;
> > Â}
>
> like for data here?

This function needs to keep its 'void *data' argument because it's a
callback for stacktrace_ops, so it has to conform to the callback
interface. 'data' is used for passing a pointer to an opaque data
structure to the callback.

Also this is the only caller of printk_stack_address(), so there's
nowhere else to bubble it up to.

--
Josh