public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: push old stack address on irqstack for unwinder
@ 2009-01-30 16:50 Martin Hicks
  2009-01-30 23:37 ` H. Peter Anvin
  0 siblings, 1 reply; 8+ messages in thread
From: Martin Hicks @ 2009-01-30 16:50 UTC (permalink / raw)
  To: tglx, mingo, hpa, heukelum; +Cc: linux-kernel


Hi,

KDB was using this information.  Could this be pushed towards 2.6.29 please?

This re-adds the old stack pointer to the top of the irqstack to help
with unwinding.  It was removed in commit d99015b1abbad743aa049b439c1e1dede6d0fa49
as part of the save_args out-of-line work.

Signed-off-by: Martin Hicks <mort@sgi.com>
---
 arch/x86/kernel/entry_64.S |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index e28c7a9..a134621 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -346,6 +346,7 @@ ENTRY(save_args)
 	popq_cfi %rax			/* move return address... */
 	mov %gs:pda_irqstackptr,%rsp
 	EMPTY_FRAME 0
+	pushq_cfi %rbp			/* backlink for unwinder */
 	pushq_cfi %rax			/* ... to the new stack */
 	/*
 	 * We entered an interrupt context - irqs are off:



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] x86: push old stack address on irqstack for unwinder
  2009-01-30 16:50 [PATCH] x86: push old stack address on irqstack for unwinder Martin Hicks
@ 2009-01-30 23:37 ` H. Peter Anvin
  2009-01-31  0:35   ` H. Peter Anvin
  0 siblings, 1 reply; 8+ messages in thread
From: H. Peter Anvin @ 2009-01-30 23:37 UTC (permalink / raw)
  To: Martin Hicks; +Cc: tglx, mingo, heukelum, linux-kernel

Martin Hicks wrote:
> Hi,
> 
> KDB was using this information.  Could this be pushed towards 2.6.29 please?
> 
> This re-adds the old stack pointer to the top of the irqstack to help
> with unwinding.  It was removed in commit d99015b1abbad743aa049b439c1e1dede6d0fa49
> as part of the save_args out-of-line work.
> 

This bothers me... why should we add even a single instruction to what 
is arguably the single hottest path in the kernel to support an 
out-of-tree debugger, especially if kgdb (which is in-tree) doesn't need it?

What does kgdb do differently (or is kgdb broken too)?

	-hpa

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] x86: push old stack address on irqstack for unwinder
  2009-01-30 23:37 ` H. Peter Anvin
@ 2009-01-31  0:35   ` H. Peter Anvin
  2009-01-31  0:39     ` Ingo Molnar
  0 siblings, 1 reply; 8+ messages in thread
From: H. Peter Anvin @ 2009-01-31  0:35 UTC (permalink / raw)
  To: Martin Hicks; +Cc: tglx, mingo, heukelum, linux-kernel

H. Peter Anvin wrote:
> Martin Hicks wrote:
>> Hi,
>>
>> KDB was using this information.  Could this be pushed towards 2.6.29 
>> please?
>>
>> This re-adds the old stack pointer to the top of the irqstack to help
>> with unwinding.  It was removed in commit 
>> d99015b1abbad743aa049b439c1e1dede6d0fa49
>> as part of the save_args out-of-line work.
>>
> 
> This bothers me... why should we add even a single instruction to what 
> is arguably the single hottest path in the kernel to support an 
> out-of-tree debugger, especially if kgdb (which is in-tree) doesn't need 
> it?
> 
> What does kgdb do differently (or is kgdb broken too)?
> 

Thinking about it some more, I think this makes sense under

#ifdef CONFIG_FRAME_POINTER

... since if we're not building with frame pointers, this is pretty 
pointless, and if we are, we're adding these all over the place anyway.

Does this work for you?  Let me know and I'll get it in if so.

	-hpa

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] x86: push old stack address on irqstack for unwinder
  2009-01-31  0:35   ` H. Peter Anvin
@ 2009-01-31  0:39     ` Ingo Molnar
  2009-01-31  0:47       ` H. Peter Anvin
  2009-01-31 17:45       ` Martin Hicks
  0 siblings, 2 replies; 8+ messages in thread
From: Ingo Molnar @ 2009-01-31  0:39 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Martin Hicks, tglx, mingo, heukelum, linux-kernel


* H. Peter Anvin <hpa@zytor.com> wrote:

> H. Peter Anvin wrote:
>> Martin Hicks wrote:
>>> Hi,
>>>
>>> KDB was using this information.  Could this be pushed towards 2.6.29  
>>> please?
>>>
>>> This re-adds the old stack pointer to the top of the irqstack to help
>>> with unwinding.  It was removed in commit  
>>> d99015b1abbad743aa049b439c1e1dede6d0fa49
>>> as part of the save_args out-of-line work.
>>>
>>
>> This bothers me... why should we add even a single instruction to what  
>> is arguably the single hottest path in the kernel to support an  
>> out-of-tree debugger, especially if kgdb (which is in-tree) doesn't 
>> need it?
>>
>> What does kgdb do differently (or is kgdb broken too)?
>>
>
> Thinking about it some more, I think this makes sense under
>
> #ifdef CONFIG_FRAME_POINTER
>
> ... since if we're not building with frame pointers, this is pretty  
> pointless, and if we are, we're adding these all over the place anyway.
>
> Does this work for you?  Let me know and I'll get it in if so.

Would be nice to have an #ifdef-less primitive for this - something like:

	pushq_frame %rbp

and a matching:

	popq_frame %rbp

for those cases that need it (this one doesnt as we dont pop out of the 
stack).

	Ingo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] x86: push old stack address on irqstack for unwinder
  2009-01-31  0:39     ` Ingo Molnar
@ 2009-01-31  0:47       ` H. Peter Anvin
  2009-01-31  0:50         ` Ingo Molnar
  2009-01-31 17:45       ` Martin Hicks
  1 sibling, 1 reply; 8+ messages in thread
From: H. Peter Anvin @ 2009-01-31  0:47 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Martin Hicks, tglx, mingo, heukelum, linux-kernel

Ingo Molnar wrote:
> 
> Would be nice to have an #ifdef-less primitive for this - something like:
> 
> 	pushq_frame %rbp
> 
> and a matching:
> 
> 	popq_frame %rbp
> 
> for those cases that need it (this one doesnt as we dont pop out of the 
> stack).
> 

It certainly would if this isn't a singleton, which I think it could 
possibly be?

Otherwise it really should be a part of an entry/exit macro; this is 
somewhat special in that it sets up a frame pointer as something other 
than a normal entry/exit sequence.

	-hpa

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] x86: push old stack address on irqstack for unwinder
  2009-01-31  0:47       ` H. Peter Anvin
@ 2009-01-31  0:50         ` Ingo Molnar
  0 siblings, 0 replies; 8+ messages in thread
From: Ingo Molnar @ 2009-01-31  0:50 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Martin Hicks, tglx, mingo, heukelum, linux-kernel


* H. Peter Anvin <hpa@zytor.com> wrote:

> Ingo Molnar wrote:
>>
>> Would be nice to have an #ifdef-less primitive for this - something like:
>>
>> 	pushq_frame %rbp
>>
>> and a matching:
>>
>> 	popq_frame %rbp
>>
>> for those cases that need it (this one doesnt as we dont pop out of the 
>> stack).
>>
>
> It certainly would if this isn't a singleton, which I think it could 
> possibly be?

yeah. This is pretty much the only non-restored frame we construct so 
indeed it would be a singleton. Perhaps the IST ones are such ones too.

> Otherwise it really should be a part of an entry/exit macro; this is 
> somewhat special in that it sets up a frame pointer as something other 
> than a normal entry/exit sequence.

Sure - your call really.

	Ingo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] x86: push old stack address on irqstack for unwinder
  2009-01-31  0:39     ` Ingo Molnar
  2009-01-31  0:47       ` H. Peter Anvin
@ 2009-01-31 17:45       ` Martin Hicks
  2009-02-03  5:18         ` H. Peter Anvin
  1 sibling, 1 reply; 8+ messages in thread
From: Martin Hicks @ 2009-01-31 17:45 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: H. Peter Anvin, tglx, mingo, heukelum, linux-kernel, kdb


On Sat, Jan 31, 2009 at 01:39:21AM +0100, Ingo Molnar wrote:
> 
> * H. Peter Anvin <hpa@zytor.com> wrote:
> 
> > H. Peter Anvin wrote:
> >> Martin Hicks wrote:
> >>> Hi,
> >>>
> >>> KDB was using this information.  Could this be pushed towards 2.6.29  
> >>> please?
> >>>
> >>> This re-adds the old stack pointer to the top of the irqstack to help
> >>> with unwinding.  It was removed in commit  
> >>> d99015b1abbad743aa049b439c1e1dede6d0fa49
> >>> as part of the save_args out-of-line work.
> >>>
> >>
> >> This bothers me... why should we add even a single instruction to what  
> >> is arguably the single hottest path in the kernel to support an  
> >> out-of-tree debugger, especially if kgdb (which is in-tree) doesn't 
> >> need it?
> >>
> >> What does kgdb do differently (or is kgdb broken too)?
> >>

I was searching around, trying to find out if there was another way for
kdb to do this, and I think removing the backlink is breaking other
stuff also.  dump_trace() in dumpstack_64.S is using the same trick as
KDB to trace out of the interrupt stack:

            /*
             * We link to the next stack (which would be
             * the process stack normally) the last
             * pointer (index -1 to end) in the IRQ stack:
             */
            stack = (unsigned long *) (irqstack_end[-1]);
            irqstack_end = NULL;
            ops->stack(data, "EOI");
            continue;


mh


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] x86: push old stack address on irqstack for unwinder
  2009-01-31 17:45       ` Martin Hicks
@ 2009-02-03  5:18         ` H. Peter Anvin
  0 siblings, 0 replies; 8+ messages in thread
From: H. Peter Anvin @ 2009-02-03  5:18 UTC (permalink / raw)
  To: Martin Hicks; +Cc: Ingo Molnar, tglx, mingo, heukelum, linux-kernel, kdb

Martin Hicks wrote:
> 
> I was searching around, trying to find out if there was another way for
> kdb to do this, and I think removing the backlink is breaking other
> stuff also.  dump_trace() in dumpstack_64.S is using the same trick as
> KDB to trace out of the interrupt stack:
> 

OK, that makes it a no-brainer.  Applied to tip:x86/urgent, thanks!

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-02-03  5:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-30 16:50 [PATCH] x86: push old stack address on irqstack for unwinder Martin Hicks
2009-01-30 23:37 ` H. Peter Anvin
2009-01-31  0:35   ` H. Peter Anvin
2009-01-31  0:39     ` Ingo Molnar
2009-01-31  0:47       ` H. Peter Anvin
2009-01-31  0:50         ` Ingo Molnar
2009-01-31 17:45       ` Martin Hicks
2009-02-03  5:18         ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox