diff options
author | David S. Miller <davem@davemloft.net> | 2008-03-24 23:06:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-24 23:06:24 -0400 |
commit | 85a793533524f333e8d630dc22450e574b7e08d2 (patch) | |
tree | f535f7721bea10ea1ddd79e83159350b457de72b /arch | |
parent | 6d008153234c4cccae7bb0170defeea18258db4a (diff) |
[SPARC64]: Make save_stack_trace() more efficient.
Doing a 'flushw' every stack trace capture creates so much overhead
that it makes lockdep next to unusable.
We only care about the frame pointer chain and the function caller
program counters, so flush those by hand to the stack frame.
This is significantly more efficient than a 'flushw' because:
1) We only save 16 bytes per active register window to the stack.
2) This doesn't push the entire register window context of the current
call chain out of the cpu, forcing register window fill traps as we
return back down.
Note that we can't use 'restore' and 'save' instructions to move
around the register windows because that wouldn't work on Niagara
processors. They optimize 'save' into a new register window by
simply clearing out the registers instead of pulling them in from
the on-chip register window backing store.
Based upon a report by Tom Callaway.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc64/kernel/entry.S | 30 | ||||
-rw-r--r-- | arch/sparc64/kernel/stacktrace.c | 4 |
2 files changed, 33 insertions, 1 deletions
diff --git a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S index 6be4d2d2904e..49eca4b1cf25 100644 --- a/arch/sparc64/kernel/entry.S +++ b/arch/sparc64/kernel/entry.S | |||
@@ -1705,6 +1705,36 @@ __flushw_user: | |||
1705 | 2: retl | 1705 | 2: retl |
1706 | nop | 1706 | nop |
1707 | 1707 | ||
1708 | /* Flush %fp and %i7 to the stack for all register | ||
1709 | * windows active inside of the cpu. This allows | ||
1710 | * show_stack_trace() to avoid using an expensive | ||
1711 | * 'flushw'. | ||
1712 | */ | ||
1713 | .globl stack_trace_flush | ||
1714 | .type stack_trace_flush,#function | ||
1715 | stack_trace_flush: | ||
1716 | rdpr %pstate, %o0 | ||
1717 | wrpr %o0, PSTATE_IE, %pstate | ||
1718 | |||
1719 | rdpr %cwp, %g1 | ||
1720 | rdpr %canrestore, %g2 | ||
1721 | sub %g1, 1, %g3 | ||
1722 | |||
1723 | 1: brz,pn %g2, 2f | ||
1724 | sub %g2, 1, %g2 | ||
1725 | wrpr %g3, %cwp | ||
1726 | stx %fp, [%sp + STACK_BIAS + RW_V9_I6] | ||
1727 | stx %i7, [%sp + STACK_BIAS + RW_V9_I7] | ||
1728 | ba,pt %xcc, 1b | ||
1729 | sub %g3, 1, %g3 | ||
1730 | |||
1731 | 2: wrpr %g1, %cwp | ||
1732 | wrpr %o0, %pstate | ||
1733 | |||
1734 | retl | ||
1735 | nop | ||
1736 | .size stack_trace_flush,.-stack_trace_flush | ||
1737 | |||
1708 | #ifdef CONFIG_SMP | 1738 | #ifdef CONFIG_SMP |
1709 | .globl hard_smp_processor_id | 1739 | .globl hard_smp_processor_id |
1710 | hard_smp_processor_id: | 1740 | hard_smp_processor_id: |
diff --git a/arch/sparc64/kernel/stacktrace.c b/arch/sparc64/kernel/stacktrace.c index 47f92a59be18..84d39e873e88 100644 --- a/arch/sparc64/kernel/stacktrace.c +++ b/arch/sparc64/kernel/stacktrace.c | |||
@@ -2,13 +2,15 @@ | |||
2 | #include <linux/stacktrace.h> | 2 | #include <linux/stacktrace.h> |
3 | #include <linux/thread_info.h> | 3 | #include <linux/thread_info.h> |
4 | #include <asm/ptrace.h> | 4 | #include <asm/ptrace.h> |
5 | #include <asm/stacktrace.h> | ||
5 | 6 | ||
6 | void save_stack_trace(struct stack_trace *trace) | 7 | void save_stack_trace(struct stack_trace *trace) |
7 | { | 8 | { |
8 | unsigned long ksp, fp, thread_base; | 9 | unsigned long ksp, fp, thread_base; |
9 | struct thread_info *tp = task_thread_info(current); | 10 | struct thread_info *tp = task_thread_info(current); |
10 | 11 | ||
11 | flushw_all(); | 12 | stack_trace_flush(); |
13 | |||
12 | __asm__ __volatile__( | 14 | __asm__ __volatile__( |
13 | "mov %%fp, %0" | 15 | "mov %%fp, %0" |
14 | : "=r" (ksp) | 16 | : "=r" (ksp) |