diff options
author | Robin Holt <holt@sgi.com> | 2010-05-11 17:06:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-26 17:32:04 -0400 |
commit | b759d0992e1fdcf2a76ebef37289e787b375fa28 (patch) | |
tree | bcd613d0a5dee3ccbe9e83c27e3efdff7d9cb8b9 | |
parent | 23e7ebc2b334b2a200983e8e48289634f0b0bf5f (diff) |
revert "procfs: provide stack information for threads" and its fixup commits
commit 34441427aab4bdb3069a4ffcda69a99357abcb2e upstream.
Originally, commit d899bf7b ("procfs: provide stack information for
threads") attempted to introduce a new feature for showing where the
threadstack was located and how many pages are being utilized by the
stack.
Commit c44972f1 ("procfs: disable per-task stack usage on NOMMU") was
applied to fix the NO_MMU case.
Commit 89240ba0 ("x86, fs: Fix x86 procfs stack information for threads on
64-bit") was applied to fix a bug in ia32 executables being loaded.
Commit 9ebd4eba7 ("procfs: fix /proc/<pid>/stat stack pointer for kernel
threads") was applied to fix a bug which had kernel threads printing a
userland stack address.
Commit 1306d603f ('proc: partially revert "procfs: provide stack
information for threads"') was then applied to revert the stack pages
being used to solve a significant performance regression.
This patch nearly undoes the effect of all these patches.
The reason for reverting these is it provides an unusable value in
field 28. For x86_64, a fork will result in the task->stack_start
value being updated to the current user top of stack and not the stack
start address. This unpredictability of the stack_start value makes
it worthless. That includes the intended use of showing how much stack
space a thread has.
Other architectures will get different values. As an example, ia64
gets 0. The do_fork() and copy_process() functions appear to treat the
stack_start and stack_size parameters as architecture specific.
I only partially reverted c44972f1 ("procfs: disable per-task stack usage
on NOMMU") . If I had completely reverted it, I would have had to change
mm/Makefile only build pagewalk.o when CONFIG_PROC_PAGE_MONITOR is
configured. Since I could not test the builds without significant effort,
I decided to not change mm/Makefile.
I only partially reverted 89240ba0 ("x86, fs: Fix x86 procfs stack
information for threads on 64-bit") . I left the KSTK_ESP() change in
place as that seemed worthwhile.
Signed-off-by: Robin Holt <holt@sgi.com>
Cc: Stefani Seibold <stefani@seibold.net>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | Documentation/filesystems/proc.txt | 3 | ||||
-rw-r--r-- | fs/compat.c | 2 | ||||
-rw-r--r-- | fs/exec.c | 2 | ||||
-rw-r--r-- | fs/proc/array.c | 3 | ||||
-rw-r--r-- | fs/proc/task_mmu.c | 19 | ||||
-rw-r--r-- | include/linux/sched.h | 1 | ||||
-rw-r--r-- | kernel/fork.c | 2 |
7 files changed, 2 insertions, 30 deletions
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 0d07513a67a6..bf241be2cfd2 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt | |||
@@ -308,7 +308,7 @@ address perms offset dev inode pathname | |||
308 | 08049000-0804a000 rw-p 00001000 03:00 8312 /opt/test | 308 | 08049000-0804a000 rw-p 00001000 03:00 8312 /opt/test |
309 | 0804a000-0806b000 rw-p 00000000 00:00 0 [heap] | 309 | 0804a000-0806b000 rw-p 00000000 00:00 0 [heap] |
310 | a7cb1000-a7cb2000 ---p 00000000 00:00 0 | 310 | a7cb1000-a7cb2000 ---p 00000000 00:00 0 |
311 | a7cb2000-a7eb2000 rw-p 00000000 00:00 0 [threadstack:001ff4b4] | 311 | a7cb2000-a7eb2000 rw-p 00000000 00:00 0 |
312 | a7eb2000-a7eb3000 ---p 00000000 00:00 0 | 312 | a7eb2000-a7eb3000 ---p 00000000 00:00 0 |
313 | a7eb3000-a7ed5000 rw-p 00000000 00:00 0 | 313 | a7eb3000-a7ed5000 rw-p 00000000 00:00 0 |
314 | a7ed5000-a8008000 r-xp 00000000 03:00 4222 /lib/libc.so.6 | 314 | a7ed5000-a8008000 r-xp 00000000 03:00 4222 /lib/libc.so.6 |
@@ -344,7 +344,6 @@ is not associated with a file: | |||
344 | [stack] = the stack of the main process | 344 | [stack] = the stack of the main process |
345 | [vdso] = the "virtual dynamic shared object", | 345 | [vdso] = the "virtual dynamic shared object", |
346 | the kernel system call handler | 346 | the kernel system call handler |
347 | [threadstack:xxxxxxxx] = the stack of the thread, xxxxxxxx is the stack size | ||
348 | 347 | ||
349 | or if empty, the mapping is anonymous. | 348 | or if empty, the mapping is anonymous. |
350 | 349 | ||
diff --git a/fs/compat.c b/fs/compat.c index 00d90c2e66f0..514b6236ac74 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -1530,8 +1530,6 @@ int compat_do_execve(char * filename, | |||
1530 | if (retval < 0) | 1530 | if (retval < 0) |
1531 | goto out; | 1531 | goto out; |
1532 | 1532 | ||
1533 | current->stack_start = current->mm->start_stack; | ||
1534 | |||
1535 | /* execve succeeded */ | 1533 | /* execve succeeded */ |
1536 | current->fs->in_exec = 0; | 1534 | current->fs->in_exec = 0; |
1537 | current->in_execve = 0; | 1535 | current->in_execve = 0; |
@@ -1386,8 +1386,6 @@ int do_execve(char * filename, | |||
1386 | if (retval < 0) | 1386 | if (retval < 0) |
1387 | goto out; | 1387 | goto out; |
1388 | 1388 | ||
1389 | current->stack_start = current->mm->start_stack; | ||
1390 | |||
1391 | /* execve succeeded */ | 1389 | /* execve succeeded */ |
1392 | current->fs->in_exec = 0; | 1390 | current->fs->in_exec = 0; |
1393 | current->in_execve = 0; | 1391 | current->in_execve = 0; |
diff --git a/fs/proc/array.c b/fs/proc/array.c index 13b5d0708175..69eb4c43669b 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -82,7 +82,6 @@ | |||
82 | #include <linux/pid_namespace.h> | 82 | #include <linux/pid_namespace.h> |
83 | #include <linux/ptrace.h> | 83 | #include <linux/ptrace.h> |
84 | #include <linux/tracehook.h> | 84 | #include <linux/tracehook.h> |
85 | #include <linux/swapops.h> | ||
86 | 85 | ||
87 | #include <asm/pgtable.h> | 86 | #include <asm/pgtable.h> |
88 | #include <asm/processor.h> | 87 | #include <asm/processor.h> |
@@ -494,7 +493,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
494 | rsslim, | 493 | rsslim, |
495 | mm ? mm->start_code : 0, | 494 | mm ? mm->start_code : 0, |
496 | mm ? mm->end_code : 0, | 495 | mm ? mm->end_code : 0, |
497 | (permitted && mm) ? task->stack_start : 0, | 496 | (permitted && mm) ? mm->start_stack : 0, |
498 | esp, | 497 | esp, |
499 | eip, | 498 | eip, |
500 | /* The signal information here is obsolete. | 499 | /* The signal information here is obsolete. |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index f277c4a111cb..9df34a506c2b 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -243,25 +243,6 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma) | |||
243 | } else if (vma->vm_start <= mm->start_stack && | 243 | } else if (vma->vm_start <= mm->start_stack && |
244 | vma->vm_end >= mm->start_stack) { | 244 | vma->vm_end >= mm->start_stack) { |
245 | name = "[stack]"; | 245 | name = "[stack]"; |
246 | } else { | ||
247 | unsigned long stack_start; | ||
248 | struct proc_maps_private *pmp; | ||
249 | |||
250 | pmp = m->private; | ||
251 | stack_start = pmp->task->stack_start; | ||
252 | |||
253 | if (vma->vm_start <= stack_start && | ||
254 | vma->vm_end >= stack_start) { | ||
255 | pad_len_spaces(m, len); | ||
256 | seq_printf(m, | ||
257 | "[threadstack:%08lx]", | ||
258 | #ifdef CONFIG_STACK_GROWSUP | ||
259 | vma->vm_end - stack_start | ||
260 | #else | ||
261 | stack_start - vma->vm_start | ||
262 | #endif | ||
263 | ); | ||
264 | } | ||
265 | } | 246 | } |
266 | } else { | 247 | } else { |
267 | name = "[vdso]"; | 248 | name = "[vdso]"; |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 1f5fa53b46b1..db821a408828 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1560,7 +1560,6 @@ struct task_struct { | |||
1560 | /* bitmask of trace recursion */ | 1560 | /* bitmask of trace recursion */ |
1561 | unsigned long trace_recursion; | 1561 | unsigned long trace_recursion; |
1562 | #endif /* CONFIG_TRACING */ | 1562 | #endif /* CONFIG_TRACING */ |
1563 | unsigned long stack_start; | ||
1564 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */ | 1563 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */ |
1565 | struct memcg_batch_info { | 1564 | struct memcg_batch_info { |
1566 | int do_batch; /* incremented when batch uncharge started */ | 1565 | int do_batch; /* incremented when batch uncharge started */ |
diff --git a/kernel/fork.c b/kernel/fork.c index f88bd984df35..0ea67a3df3a6 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1134,8 +1134,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1134 | 1134 | ||
1135 | p->bts = NULL; | 1135 | p->bts = NULL; |
1136 | 1136 | ||
1137 | p->stack_start = stack_start; | ||
1138 | |||
1139 | /* Perform scheduler related setup. Assign this task to a CPU. */ | 1137 | /* Perform scheduler related setup. Assign this task to a CPU. */ |
1140 | sched_fork(p, clone_flags); | 1138 | sched_fork(p, clone_flags); |
1141 | 1139 | ||