Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1445177 > unrolled thread

Re: [PATCH 1/2] x86/dumpstack: Optimize save_stack_trace

Started byByungchul Park <byungchul.park@lge.com>
First post2016-07-18 05:20 +0200
Last post2016-07-19 02:20 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 1/2] x86/dumpstack: Optimize save_stack_trace Byungchul Park <byungchul.park@lge.com> - 2016-07-18 05:20 +0200
    Re: [PATCH 1/2] x86/dumpstack: Optimize save_stack_trace Josh Poimboeuf <jpoimboe@redhat.com> - 2016-07-18 15:10 +0200
      Re: [PATCH 1/2] x86/dumpstack: Optimize save_stack_trace Byungchul Park <byungchul.park@lge.com> - 2016-07-19 02:20 +0200

#1445177 — Re: [PATCH 1/2] x86/dumpstack: Optimize save_stack_trace

FromByungchul Park <byungchul.park@lge.com>
Date2016-07-18 05:20 +0200
SubjectRe: [PATCH 1/2] x86/dumpstack: Optimize save_stack_trace
Message-ID<rW7g5-LP-9@gated-at.bofh.it>
On Fri, Jul 08, 2016 at 10:22:46AM -0500, Josh Poimboeuf wrote:
> > > > Also, could you please rename the _norm names to _fast or so, to signal that this 
> > > > is a faster but less reliable method to get a stack dump? Nobody knows what 
> > > > '_norm' means, but '_fast' is pretty self-explanatory.
> > > 
> > > Hm, but is print_context_stack_bp() variant really less reliable?  From
> > > what I can tell, its only differences vs print_context_stack() are:
> > > 
> > > - It doesn't scan the stack for "guesses" (which are 'unreliable' and
> > >   are ignored by the ops->address() callback anyway).
> > > 
> > > - It stops if ops->address() returns an error (which in this case means
> > >   the array is full anyway).
> > > 
> > > - It stops if the address isn't a kernel text address.  I think this
> > >   shouldn't normally be possible unless there's some generated code like
> > >   bpf on the stack.  Maybe it could be slightly improved for this case.
> > > 
> > > So instead of adding a new save_stack_trace_fast() variant, why don't we
> > > just modify the existing save_stack_trace() to use
> > > print_context_stack_bp()?
> > 
> > I'm not sure this is a good idea. First of all if the kernel isn't built with
> > frame pointers, all you have is wild walk guesses.
> 
> True, though I'd argue that if frame pointers are disabled then
> save_stack_trace() should return an empty trace.  But admittedly, that

As Frederic said, I think, some save_stack_trace() users may want to
check the 'guesses', in other words, it's not good idea for
save_stack_trace() to return an empty trace when frame pointers are
disabled. No?

> > There are several different users of save_stack_trace() in the kernel, we can't
> > be sure that all of them are interested in dropping those guesses.
> > 
> > So I'd rather advocate in favour of a new seperate helper.
> 
> So how about we change save_stack_trace() to use print_context_stack()
> for CONFIG_FRAME_POINTER=n and print_context_stack_bp() for
> CONFIG_FRAME_POINTER=y?  That would preserve the existing behavior, no?

Even if CONFIG_FRAME_POINTER=y, someone may want to guess, doesn't they?

> 
> -- 
> Josh

[toc] | [next] | [standalone]


#1445475

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2016-07-18 15:10 +0200
Message-ID<rWgt4-6Eh-43@gated-at.bofh.it>
In reply to#1445177
On Mon, Jul 18, 2016 at 12:14:22PM +0900, Byungchul Park wrote:
> On Fri, Jul 08, 2016 at 10:22:46AM -0500, Josh Poimboeuf wrote:
> > > > > Also, could you please rename the _norm names to _fast or so, to signal that this 
> > > > > is a faster but less reliable method to get a stack dump? Nobody knows what 
> > > > > '_norm' means, but '_fast' is pretty self-explanatory.
> > > > 
> > > > Hm, but is print_context_stack_bp() variant really less reliable?  From
> > > > what I can tell, its only differences vs print_context_stack() are:
> > > > 
> > > > - It doesn't scan the stack for "guesses" (which are 'unreliable' and
> > > >   are ignored by the ops->address() callback anyway).
> > > > 
> > > > - It stops if ops->address() returns an error (which in this case means
> > > >   the array is full anyway).
> > > > 
> > > > - It stops if the address isn't a kernel text address.  I think this
> > > >   shouldn't normally be possible unless there's some generated code like
> > > >   bpf on the stack.  Maybe it could be slightly improved for this case.
> > > > 
> > > > So instead of adding a new save_stack_trace_fast() variant, why don't we
> > > > just modify the existing save_stack_trace() to use
> > > > print_context_stack_bp()?
> > > 
> > > I'm not sure this is a good idea. First of all if the kernel isn't built with
> > > frame pointers, all you have is wild walk guesses.
> > 
> > True, though I'd argue that if frame pointers are disabled then
> > save_stack_trace() should return an empty trace.  But admittedly, that
> 
> As Frederic said, I think, some save_stack_trace() users may want to
> check the 'guesses', in other words, it's not good idea for
> save_stack_trace() to return an empty trace when frame pointers are
> disabled. No?

With frame pointers disabled, yes, maybe guesses are better than
nothing.

> > > There are several different users of save_stack_trace() in the kernel, we can't
> > > be sure that all of them are interested in dropping those guesses.
> > > 
> > > So I'd rather advocate in favour of a new seperate helper.
> > 
> > So how about we change save_stack_trace() to use print_context_stack()
> > for CONFIG_FRAME_POINTER=n and print_context_stack_bp() for
> > CONFIG_FRAME_POINTER=y?  That would preserve the existing behavior, no?
> 
> Even if CONFIG_FRAME_POINTER=y, someone may want to guess, doesn't they?

For CONFIG_FRAME_POINTER=y, the guesses are ignored by
__save_stack_address() and only the reliable addresses are saved.

We shouldn't change that behavior, unless you actually know of a caller
who wants the guesses.  And even then the "guess" variation should be
named accordingly to make it clear that it's not a "reliable" stack
trace, even though frame pointers are enabled.

-- 
Josh

[toc] | [prev] | [next] | [standalone]


#1445950

FromByungchul Park <byungchul.park@lge.com>
Date2016-07-19 02:20 +0200
Message-ID<rWqVr-4Vk-5@gated-at.bofh.it>
In reply to#1445475
On Mon, Jul 18, 2016 at 08:09:10AM -0500, Josh Poimboeuf wrote:
> > > > There are several different users of save_stack_trace() in the kernel, we can't
> > > > be sure that all of them are interested in dropping those guesses.
> > > > 
> > > > So I'd rather advocate in favour of a new seperate helper.
> > > 
> > > So how about we change save_stack_trace() to use print_context_stack()
> > > for CONFIG_FRAME_POINTER=n and print_context_stack_bp() for
> > > CONFIG_FRAME_POINTER=y?  That would preserve the existing behavior, no?
> > 
> > Even if CONFIG_FRAME_POINTER=y, someone may want to guess, doesn't they?
> 
> For CONFIG_FRAME_POINTER=y, the guesses are ignored by
> __save_stack_address() and only the reliable addresses are saved.

Indeed. I was confused.

> We shouldn't change that behavior, unless you actually know of a caller
> who wants the guesses.  And even then the "guess" variation should be
> named accordingly to make it clear that it's not a "reliable" stack
> trace, even though frame pointers are enabled.

My question was caused by being confused. I agree with you.

> 
> -- 
> Josh

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web