<feed xmlns='http://www.w3.org/2005/Atom'>
<title>lwn.git/arch/x86/kernel/dumpstack_32.c, branch v3.0.56</title>
<subtitle>Linux kernel documentation tree maintained by Jonathan Corbet</subtitle>
<id>http://mirrors.hust.edu.cn/git/lwn.git/atom?h=v3.0.56</id>
<link rel='self' href='http://mirrors.hust.edu.cn/git/lwn.git/atom?h=v3.0.56'/>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/'/>
<updated>2011-03-18T09:51:42+00:00</updated>
<entry>
<title>x86, dumpstack: Correct stack dump info when frame pointer is available</title>
<updated>2011-03-18T09:51:42+00:00</updated>
<author>
<name>Namhyung Kim</name>
<email>namhyung@gmail.com</email>
</author>
<published>2011-03-18T02:40:06+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=e8e999cf3cc733482e390b02ff25a64cecdc0b64'/>
<id>urn:sha1:e8e999cf3cc733482e390b02ff25a64cecdc0b64</id>
<content type='text'>
Current stack dump code scans entire stack and check each entry
contains a pointer to kernel code. If CONFIG_FRAME_POINTER=y it
could mark whether the pointer is valid or not based on value of
the frame pointer. Invalid entries could be preceded by '?' sign.

However this was not going to happen because scan start point
was always higher than the frame pointer so that they could not
meet.

Commit 9c0729dc8062 ("x86: Eliminate bp argument from the stack
tracing routines") delayed bp acquisition point, so the bp was
read in lower frame, thus all of the entries were marked
invalid.

This patch fixes this by reverting above commit while retaining
stack_frame() helper as suggested by Frederic Weisbecker.

End result looks like below:

before:

 [    3.508329] Call Trace:
 [    3.508551]  [&lt;ffffffff814f35c9&gt;] ? panic+0x91/0x199
 [    3.508662]  [&lt;ffffffff814f3739&gt;] ? printk+0x68/0x6a
 [    3.508770]  [&lt;ffffffff81a981b2&gt;] ? mount_block_root+0x257/0x26e
 [    3.508876]  [&lt;ffffffff81a9821f&gt;] ? mount_root+0x56/0x5a
 [    3.508975]  [&lt;ffffffff81a98393&gt;] ? prepare_namespace+0x170/0x1a9
 [    3.509216]  [&lt;ffffffff81a9772b&gt;] ? kernel_init+0x1d2/0x1e2
 [    3.509335]  [&lt;ffffffff81003894&gt;] ? kernel_thread_helper+0x4/0x10
 [    3.509442]  [&lt;ffffffff814f6880&gt;] ? restore_args+0x0/0x30
 [    3.509542]  [&lt;ffffffff81a97559&gt;] ? kernel_init+0x0/0x1e2
 [    3.509641]  [&lt;ffffffff81003890&gt;] ? kernel_thread_helper+0x0/0x10

after:

 [    3.522991] Call Trace:
 [    3.523351]  [&lt;ffffffff814f35b9&gt;] panic+0x91/0x199
 [    3.523468]  [&lt;ffffffff814f3729&gt;] ? printk+0x68/0x6a
 [    3.523576]  [&lt;ffffffff81a981b2&gt;] mount_block_root+0x257/0x26e
 [    3.523681]  [&lt;ffffffff81a9821f&gt;] mount_root+0x56/0x5a
 [    3.523780]  [&lt;ffffffff81a98393&gt;] prepare_namespace+0x170/0x1a9
 [    3.523885]  [&lt;ffffffff81a9772b&gt;] kernel_init+0x1d2/0x1e2
 [    3.523987]  [&lt;ffffffff81003894&gt;] kernel_thread_helper+0x4/0x10
 [    3.524228]  [&lt;ffffffff814f6880&gt;] ? restore_args+0x0/0x30
 [    3.524345]  [&lt;ffffffff81a97559&gt;] ? kernel_init+0x0/0x1e2
 [    3.524445]  [&lt;ffffffff81003890&gt;] ? kernel_thread_helper+0x0/0x10

 -v5:
   * fix build breakage with oprofile

 -v4:
   * use 0 instead of regs-&gt;bp
   * separate out printk changes

 -v3:
   * apply comment from Frederic
   * add a couple of printk fixes

Signed-off-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
Acked-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Acked-by: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: Soren Sandmann &lt;ssp@redhat.com&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;
Cc: Robert Richter &lt;robert.richter@amd.com&gt;
LKML-Reference: &lt;1300416006-3163-1-git-send-email-namhyung@gmail.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>x86: Eliminate bp argument from the stack tracing routines</title>
<updated>2010-11-18T13:37:34+00:00</updated>
<author>
<name>Soeren Sandmann Pedersen</name>
<email>sandmann@redhat.com</email>
</author>
<published>2010-11-05T09:59:39+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=9c0729dc8062bed96189bd14ac6d4920f3958743'/>
<id>urn:sha1:9c0729dc8062bed96189bd14ac6d4920f3958743</id>
<content type='text'>
The various stack tracing routines take a 'bp' argument in which the
caller is supposed to provide the base pointer to use, or 0 if doesn't
have one. Since bp is garbage whenever CONFIG_FRAME_POINTER is not
defined, this means all callers in principle should either always pass
0, or be conditional on CONFIG_FRAME_POINTER.

However, there are only really three use cases for stack tracing:

(a) Trace the current task, including IRQ stack if any
(b) Trace the current task, but skip IRQ stack
(c) Trace some other task

In all cases, if CONFIG_FRAME_POINTER is not defined, bp should just
be 0.  If it _is_ defined, then

- in case (a) bp should be gotten directly from the CPU's register, so
  the caller should pass NULL for regs,

- in case (b) the caller should should pass the IRQ registers to
  dump_trace(),

- in case (c) bp should be gotten from the top of the task's stack, so
  the caller should pass NULL for regs.

Hence, the bp argument is not necessary because the combination of
task and regs is sufficient to determine an appropriate value for bp.

This patch introduces a new inline function stack_frame(task, regs)
that computes the desired bp. This function is then called from the
two versions of dump_stack().

Signed-off-by: Soren Sandmann &lt;ssp@redhat.com&gt;
Acked-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: H. Peter Anvin &lt;hpa@zytor.com&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: Arjan van de Ven &lt;arjan@infradead.org&gt;,
Cc: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;,
Cc: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;,
LKML-Reference: &lt;m3oc9rop28.fsf@dhcp-100-3-82.bos.redhat.com&gt;&gt;
Signed-off-by: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
</content>
</entry>
<entry>
<title>x86, printk: Get rid of &lt;0&gt; from stack output</title>
<updated>2010-10-23T18:03:03+00:00</updated>
<author>
<name>Jiri Slaby</name>
<email>jslaby@suse.cz</email>
</author>
<published>2010-10-20T14:48:51+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=e4072a9a9d186fe86293effe8828faa4be75b4a4'/>
<id>urn:sha1:e4072a9a9d186fe86293effe8828faa4be75b4a4</id>
<content type='text'>
The stack output currently looks like this:

 7fffffffffffffff 0000000a00000000 ffffffff81093341 0000000000000046
&lt;0&gt; ffff88003a545fd8 0000000000000000 0000000000000000 00007fffa39769c0
&lt;0&gt; ffff88003e403f58 ffffffff8102fc4c ffff88003e403f58 ffff88003e403f78

The superfluous &lt;0&gt; are caused by recent printk KERN_CONT
change. &lt;*&gt; is now ignored in printk unless some text follows
the level and even then it still has to be the first in the
format message.

Note that the log_lvl parameter is now completely ignored in
show_stack_log_lvl and the stack is dumped with the default
level (like for quite some time already). It behaves the same as
the rest of the dump, function traces are dumped in the very
same manner. Only Code and maybe some lines are printed with
EMERG level.

Unfortunately I see no way how to fix this conceptually to have
the whole oops/BUG/panic output with the same level, so this
removed only the superfluous characters for the time being.

Just for illustration:

&lt;4&gt;Process kworker/0:0 (pid: 0, threadinfo ffff88003c8a6000, task ffff88003c85c100)
&lt;0&gt;Stack:
&lt;4&gt; ffffffff818022c0 0000000a00000001 0000000000000001 0000000000000046
&lt;4&gt; ffff88003c8a7fd8 0000000000000001 ffff88003c8a7e58 0000000000000000
&lt;4&gt; ffff88003e503f48 ffffffff8102fc4c ffff88003e503f48 ffff88003e503f68
&lt;0&gt;Call Trace:
&lt;0&gt; &lt;IRQ&gt;
&lt;4&gt; [&lt;ffffffff8102fc4c&gt;] ? call_softirq+0x1c/0x30 ...
&lt;0&gt;Code: 00 01 00 00 65 8b 04 25 80 c5 00 00 c7 45 ...

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: jirislaby@gmail.com
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
LKML-Reference: &lt;1287586131-16222-1-git-send-email-jslaby@suse.cz&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>x86: Unify dumpstack.h and stacktrace.h</title>
<updated>2010-06-08T21:29:52+00:00</updated>
<author>
<name>Frederic Weisbecker</name>
<email>fweisbec@gmail.com</email>
</author>
<published>2010-05-19T19:35:17+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=c9cf4dbb4d9ca715d8fedf13301a53296429abc6'/>
<id>urn:sha1:c9cf4dbb4d9ca715d8fedf13301a53296429abc6</id>
<content type='text'>
arch/x86/include/asm/stacktrace.h and arch/x86/kernel/dumpstack.h
declare headers of objects that deal with the same topic.
Actually most of the files that include stacktrace.h also include
dumpstack.h

Although dumpstack.h seems more reserved for internals of stack
traces, those are quite often needed to define specialized stack
trace operations. And perf event arch headers are going to need
access to such low level operations anyway. So don't continue to
bother with dumpstack.h as it's not anymore about isolated deep
internals.

v2: fix struct stack_frame definition conflict in sysprof

Signed-off-by: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Cc: H. Peter Anvin &lt;hpa@zytor.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Soeren Sandmann &lt;sandmann@daimi.au.dk&gt;
</content>
</entry>
<entry>
<title>perf: Drop useless check for ignored frame</title>
<updated>2010-01-13T09:09:08+00:00</updated>
<author>
<name>Frederic Weisbecker</name>
<email>fweisbec@gmail.com</email>
</author>
<published>2009-12-31T04:53:03+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=0fb8ee48d9dfff6a0913ceb0be2068d8be203763'/>
<id>urn:sha1:0fb8ee48d9dfff6a0913ceb0be2068d8be203763</id>
<content type='text'>
The check that ignores the debug and nmi stack frames is useless
now that we have a frame pointer that makes us start at the
right place. We don't anymore have to deal with these.

Signed-off-by: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
LKML-Reference: &lt;1262235183-5320-2-git-send-regression-fweisbec@gmail.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>perf events, x86/stacktrace: Make stack walking optional</title>
<updated>2009-12-17T08:56:19+00:00</updated>
<author>
<name>Frederic Weisbecker</name>
<email>fweisbec@gmail.com</email>
</author>
<published>2009-12-17T04:40:33+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=61c1917f47f73c968e92d04d15370b1dc3ec4592'/>
<id>urn:sha1:61c1917f47f73c968e92d04d15370b1dc3ec4592</id>
<content type='text'>
The current print_context_stack helper that does the stack
walking job is good for usual stacktraces as it walks through
all the stack and reports even addresses that look unreliable,
which is nice when we don't have frame pointers for example.

But we have users like perf that only require reliable
stacktraces, and those may want a more adapted stack walker, so
lets make this function a callback in stacktrace_ops that users
can tune for their needs.

Signed-off-by: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
LKML-Reference: &lt;1261024834-5336-1-git-send-regression-fweisbec@gmail.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>x86: dumpstack: Clean up the x86_stack_ids[][] initalization and other details</title>
<updated>2009-11-26T07:24:33+00:00</updated>
<author>
<name>Ingo Molnar</name>
<email>mingo@elte.hu</email>
</author>
<published>2009-11-26T07:17:31+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=b803090615ccec669681ff85ce28671e7bfefa3d'/>
<id>urn:sha1:b803090615ccec669681ff85ce28671e7bfefa3d</id>
<content type='text'>
Make the initialization more readable, plus tidy up a few small
visual details as well.

No change in functionality.

LKML-Reference: &lt;new-submission&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>headers: utsname.h redux</title>
<updated>2009-09-24T01:13:10+00:00</updated>
<author>
<name>Alexey Dobriyan</name>
<email>adobriyan@gmail.com</email>
</author>
<published>2009-09-24T00:22:25+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=2bcd57ab61e7cabed626226a3771617981c11ce1'/>
<id>urn:sha1:2bcd57ab61e7cabed626226a3771617981c11ce1</id>
<content type='text'>
* remove asm/atomic.h inclusion from linux/utsname.h --
   not needed after kref conversion
 * remove linux/utsname.h inclusion from files which do not need it

NOTE: it looks like fs/binfmt_elf.c do not need utsname.h, however
due to some personality stuff it _is_ needed -- cowardly leave ELF-related
headers and files alone.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>perf_counter: Ignore the nmi call frames in the x86-64 backtraces</title>
<updated>2009-07-01T20:37:23+00:00</updated>
<author>
<name>Frederic Weisbecker</name>
<email>fweisbec@gmail.com</email>
</author>
<published>2009-07-01T19:02:09+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=0406ca6d8e849d9dd027c8cb6791448e81411aef'/>
<id>urn:sha1:0406ca6d8e849d9dd027c8cb6791448e81411aef</id>
<content type='text'>
About every callchains recorded with perf record are filled up
including the internal perfcounter nmi frame:

 perf_callchain
 perf_counter_overflow
 intel_pmu_handle_irq
 perf_counter_nmi_handler
 notifier_call_chain
 atomic_notifier_call_chain
 notify_die
 do_nmi
 nmi

We want ignore this frame as it's not interesting for
instrumentation. To solve this, we simply ignore every frames
from nmi context.

New example of "perf report -s sym -c" after this patch:

9.59%  [k] search_by_key
             4.88%
                search_by_key
                reiserfs_read_locked_inode
                reiserfs_iget
                reiserfs_lookup
                do_lookup
                __link_path_walk
                path_walk
                do_path_lookup
                user_path_at
                vfs_fstatat
                vfs_lstat
                sys_newlstat
                system_call_fastpath
                __lxstat
                0x406fb1

             3.19%
                search_by_key
                search_by_entry_key
                reiserfs_find_entry
                reiserfs_lookup
                do_lookup
                __link_path_walk
                path_walk
                do_path_lookup
                user_path_at
                vfs_fstatat
                vfs_lstat
                sys_newlstat
                system_call_fastpath
                __lxstat
                0x406fb1
[...]

For now this patch only solves the problem in x86-64.

Signed-off-by: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: Mike Galbraith &lt;efault@gmx.de&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Cc: Anton Blanchard &lt;anton@samba.org&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;
LKML-Reference: &lt;1246474930-6088-1-git-send-email-fweisbec@gmail.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>ftrace: print real return in dumpstack for function graph</title>
<updated>2008-12-03T07:56:25+00:00</updated>
<author>
<name>Steven Rostedt</name>
<email>srostedt@redhat.com</email>
</author>
<published>2008-12-03T04:50:04+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=7ee991fbc6f947e9b04f29c9c6c1d057d0671a16'/>
<id>urn:sha1:7ee991fbc6f947e9b04f29c9c6c1d057d0671a16</id>
<content type='text'>
Impact: better dumpstack output

I noticed in my crash dumps and even in the stack tracer that a
lot of functions listed in the stack trace are simply
return_to_handler which is ftrace graphs way to insert its own
call into the return of a function.

But we lose out where the actually function was called from.

This patch adds in hooks to the dumpstack mechanism that detects
this and finds the real function to print. Both are printed to
let the user know that a hook is still in place.

This does give a funny side effect in the stack tracer output:

        Depth   Size      Location    (80 entries)
        -----   ----      --------
  0)     4144      48   save_stack_trace+0x2f/0x4d
  1)     4096     128   ftrace_call+0x5/0x2b
  2)     3968      16   mempool_alloc_slab+0x16/0x18
  3)     3952     384   return_to_handler+0x0/0x73
  4)     3568    -240   stack_trace_call+0x11d/0x209
  5)     3808     144   return_to_handler+0x0/0x73
  6)     3664    -128   mempool_alloc+0x4d/0xfe
  7)     3792     128   return_to_handler+0x0/0x73
  8)     3664     -32   scsi_sg_alloc+0x48/0x4a [scsi_mod]

As you can see, the real functions are now negative. This is due
to them not being found inside the stack.

Signed-off-by: Steven Rostedt &lt;srostedt@redhat.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
</feed>
