Re: [PATCH] Fix print out of function which called WARN_ON()

From: Hugh Dickins
Date: Sun May 17 2009 - 18:46:24 EST


On Sun, 17 May 2009, Linus Torvalds wrote:
> On Sun, 17 May 2009, Hugh Dickins wrote:
> > On Sat, 16 May 2009, Linus Torvalds wrote:
> > >
> > > This patch not only avoids the warnings and gets the right caller
> > > information, it cleans up the code too:
> > >
> > > - it uses '%pS' instead of of sprint_symbol
> >
> > > - char function[KSYM_SYMBOL_LEN];
> >
> > This should be a big improvement, because that buffer on the stack
> > was netting lots of stale return addresses, printed out with ?s in
> > the warning's dump_stack(). I had been wanting to add a memset,
> > but your %pS should circumvent the need for that nicely.
>
> Are you sure it was that function[] array?

No, not sure at all, that was just a conclusion I jumped to.
Though I think I was seeing it on x86-32 too.

>
> The thing is, on at least x86-64, any function using va_start() will
> allocate something like 64 bytes of stack space for the reg-save area. I'm
> not quite sure _why_ it does that, but it's very irritating, and it showed
> up quite clearly in some of the stackspace usage things.
>
> I even sent the gcc people a patch to fix the worst of it (gcc used to
> allocate about twice as much space because it also had a XMM save area
> even if you compiled without XMM support or something like that), but my
> point is, I'm afraid there is still a noticeable gap on the stack due to
> this, at least for the _fmt() case.
>
> But yes, for the _null() case we now have neither that function buffer
> _nor_ the stupid va_list save area, so that case should be much better.
>
> Of course, we could avoid that entirely if we were to just pass in the
> right stack pointer to dump_stack(), and the "warn_slowpath_xyz()"
> functions could just pass in the stack of their caller. Sadly, we
> currently have no way to do that :(
>
> We could change the dump_stack() calling convention to give a stack
> pointer or NULL, and then use __builtin_frame_address(0) in the caller..
> But we have a _lot_ of "dump_stack()" users.

Not to mention the astonishing array of dump_stack, show_stack,
show_trace, dump_trace, etc etc, layers we've now accumulated,
in x86 at least. I ran away the last time I looked there.

Hugh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/