diff options
author | Stefani Seibold <stefani@seibold.net> | 2009-09-22 19:45:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-23 10:39:41 -0400 |
commit | d899bf7b55f503ba7d3d07ed27c3a37e270fa7db (patch) | |
tree | 32a5ee7816b2f0cb3261dcca8102b9cafe9251bd /Documentation | |
parent | cba8aafe1e07dfc8bae5ba78be8e02883bd34d31 (diff) |
procfs: provide stack information for threads
A patch to give a better overview of the userland application stack usage,
especially for embedded linux.
Currently you are only able to dump the main process/thread stack usage
which is showed in /proc/pid/status by the "VmStk" Value. But you get no
information about the consumed stack memory of the the threads.
There is an enhancement in the /proc/<pid>/{task/*,}/*maps and which marks
the vm mapping where the thread stack pointer reside with "[thread stack
xxxxxxxx]". xxxxxxxx is the maximum size of stack. This is a value
information, because libpthread doesn't set the start of the stack to the
top of the mapped area, depending of the pthread usage.
A sample output of /proc/<pid>/task/<tid>/maps looks like:
08048000-08049000 r-xp 00000000 03:00 8312 /opt/z
08049000-0804a000 rw-p 00001000 03:00 8312 /opt/z
0804a000-0806b000 rw-p 00000000 00:00 0 [heap]
a7d12000-a7d13000 ---p 00000000 00:00 0
a7d13000-a7f13000 rw-p 00000000 00:00 0 [thread stack: 001ff4b4]
a7f13000-a7f14000 ---p 00000000 00:00 0
a7f14000-a7f36000 rw-p 00000000 00:00 0
a7f36000-a8069000 r-xp 00000000 03:00 4222 /lib/libc.so.6
a8069000-a806b000 r--p 00133000 03:00 4222 /lib/libc.so.6
a806b000-a806c000 rw-p 00135000 03:00 4222 /lib/libc.so.6
a806c000-a806f000 rw-p 00000000 00:00 0
a806f000-a8083000 r-xp 00000000 03:00 14462 /lib/libpthread.so.0
a8083000-a8084000 r--p 00013000 03:00 14462 /lib/libpthread.so.0
a8084000-a8085000 rw-p 00014000 03:00 14462 /lib/libpthread.so.0
a8085000-a8088000 rw-p 00000000 00:00 0
a8088000-a80a4000 r-xp 00000000 03:00 8317 /lib/ld-linux.so.2
a80a4000-a80a5000 r--p 0001b000 03:00 8317 /lib/ld-linux.so.2
a80a5000-a80a6000 rw-p 0001c000 03:00 8317 /lib/ld-linux.so.2
afaf5000-afb0a000 rw-p 00000000 00:00 0 [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
Also there is a new entry "stack usage" in /proc/<pid>/{task/*,}/status
which will you give the current stack usage in kb.
A sample output of /proc/self/status looks like:
Name: cat
State: R (running)
Tgid: 507
Pid: 507
.
.
.
CapBnd: fffffffffffffeff
voluntary_ctxt_switches: 0
nonvoluntary_ctxt_switches: 0
Stack usage: 12 kB
I also fixed stack base address in /proc/<pid>/{task/*,}/stat to the base
address of the associated thread stack and not the one of the main
process. This makes more sense.
[akpm@linux-foundation.org: fs/proc/array.c now needs walk_page_range()]
Signed-off-by: Stefani Seibold <stefani@seibold.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/filesystems/proc.txt | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 75988ba26a51..b5aee7838a00 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt | |||
@@ -176,6 +176,7 @@ read the file /proc/PID/status: | |||
176 | CapBnd: ffffffffffffffff | 176 | CapBnd: ffffffffffffffff |
177 | voluntary_ctxt_switches: 0 | 177 | voluntary_ctxt_switches: 0 |
178 | nonvoluntary_ctxt_switches: 1 | 178 | nonvoluntary_ctxt_switches: 1 |
179 | Stack usage: 12 kB | ||
179 | 180 | ||
180 | This shows you nearly the same information you would get if you viewed it with | 181 | This shows you nearly the same information you would get if you viewed it with |
181 | the ps command. In fact, ps uses the proc file system to obtain its | 182 | the ps command. In fact, ps uses the proc file system to obtain its |
@@ -229,6 +230,7 @@ Table 1-2: Contents of the statm files (as of 2.6.30-rc7) | |||
229 | Mems_allowed_list Same as previous, but in "list format" | 230 | Mems_allowed_list Same as previous, but in "list format" |
230 | voluntary_ctxt_switches number of voluntary context switches | 231 | voluntary_ctxt_switches number of voluntary context switches |
231 | nonvoluntary_ctxt_switches number of non voluntary context switches | 232 | nonvoluntary_ctxt_switches number of non voluntary context switches |
233 | Stack usage: stack usage high water mark (round up to page size) | ||
232 | .............................................................................. | 234 | .............................................................................. |
233 | 235 | ||
234 | Table 1-3: Contents of the statm files (as of 2.6.8-rc3) | 236 | Table 1-3: Contents of the statm files (as of 2.6.8-rc3) |
@@ -307,7 +309,7 @@ address perms offset dev inode pathname | |||
307 | 08049000-0804a000 rw-p 00001000 03:00 8312 /opt/test | 309 | 08049000-0804a000 rw-p 00001000 03:00 8312 /opt/test |
308 | 0804a000-0806b000 rw-p 00000000 00:00 0 [heap] | 310 | 0804a000-0806b000 rw-p 00000000 00:00 0 [heap] |
309 | a7cb1000-a7cb2000 ---p 00000000 00:00 0 | 311 | a7cb1000-a7cb2000 ---p 00000000 00:00 0 |
310 | a7cb2000-a7eb2000 rw-p 00000000 00:00 0 | 312 | a7cb2000-a7eb2000 rw-p 00000000 00:00 0 [threadstack:001ff4b4] |
311 | a7eb2000-a7eb3000 ---p 00000000 00:00 0 | 313 | a7eb2000-a7eb3000 ---p 00000000 00:00 0 |
312 | a7eb3000-a7ed5000 rw-p 00000000 00:00 0 | 314 | a7eb3000-a7ed5000 rw-p 00000000 00:00 0 |
313 | a7ed5000-a8008000 r-xp 00000000 03:00 4222 /lib/libc.so.6 | 315 | a7ed5000-a8008000 r-xp 00000000 03:00 4222 /lib/libc.so.6 |
@@ -343,6 +345,7 @@ is not associated with a file: | |||
343 | [stack] = the stack of the main process | 345 | [stack] = the stack of the main process |
344 | [vdso] = the "virtual dynamic shared object", | 346 | [vdso] = the "virtual dynamic shared object", |
345 | the kernel system call handler | 347 | the kernel system call handler |
348 | [threadstack:xxxxxxxx] = the stack of the thread, xxxxxxxx is the stack size | ||
346 | 349 | ||
347 | or if empty, the mapping is anonymous. | 350 | or if empty, the mapping is anonymous. |
348 | 351 | ||