Skip to content

Commit 3444142

Browse files
Robin Holttorvalds
authored andcommitted
revert "procfs: provide stack information for threads" and its fixup commits
Originally, commit d899bf7 ("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 c44972f ("procfs: disable per-task stack usage on NOMMU") was applied to fix the NO_MMU case. Commit 89240ba ("x86, fs: Fix x86 procfs stack information for threads on 64-bit") was applied to fix a bug in ia32 executables being loaded. Commit 9ebd4eb ("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 1306d60 ('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 c44972f ("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 89240ba ("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> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3c904af commit 3444142

7 files changed

Lines changed: 2 additions & 30 deletions

File tree

‎Documentation/filesystems/proc.txt‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ address perms offset dev inode pathname
316316
08049000-0804a000 rw-p 00001000 03:00 8312 /opt/test
317317
0804a000-0806b000 rw-p 00000000 00:00 0 [heap]
318318
a7cb1000-a7cb2000 ---p 00000000 00:00 0
319-
a7cb2000-a7eb2000 rw-p 00000000 00:00 0 [threadstack:001ff4b4]
319+
a7cb2000-a7eb2000 rw-p 00000000 00:00 0
320320
a7eb2000-a7eb3000 ---p 00000000 00:00 0
321321
a7eb3000-a7ed5000 rw-p 00000000 00:00 0
322322
a7ed5000-a8008000 r-xp 00000000 03:00 4222 /lib/libc.so.6
@@ -352,7 +352,6 @@ is not associated with a file:
352352
[stack] = the stack of the main process
353353
[vdso] = the "virtual dynamic shared object",
354354
the kernel system call handler
355-
[threadstack:xxxxxxxx] = the stack of the thread, xxxxxxxx is the stack size
356355

357356
or if empty, the mapping is anonymous.
358357

‎fs/compat.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,8 +1531,6 @@ int compat_do_execve(char * filename,
15311531
if (retval < 0)
15321532
goto out;
15331533

1534-
current->stack_start = current->mm->start_stack;
1535-
15361534
/* execve succeeded */
15371535
current->fs->in_exec = 0;
15381536
current->in_execve = 0;

‎fs/exec.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,8 +1387,6 @@ int do_execve(char * filename,
13871387
if (retval < 0)
13881388
goto out;
13891389

1390-
current->stack_start = current->mm->start_stack;
1391-
13921390
/* execve succeeded */
13931391
current->fs->in_exec = 0;
13941392
current->in_execve = 0;

‎fs/proc/array.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
#include <linux/pid_namespace.h>
8282
#include <linux/ptrace.h>
8383
#include <linux/tracehook.h>
84-
#include <linux/swapops.h>
8584

8685
#include <asm/pgtable.h>
8786
#include <asm/processor.h>
@@ -495,7 +494,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
495494
rsslim,
496495
mm ? mm->start_code : 0,
497496
mm ? mm->end_code : 0,
498-
(permitted && mm) ? task->stack_start : 0,
497+
(permitted && mm) ? mm->start_stack : 0,
499498
esp,
500499
eip,
501500
/* The signal information here is obsolete.

‎fs/proc/task_mmu.c‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -247,25 +247,6 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
247247
} else if (vma->vm_start <= mm->start_stack &&
248248
vma->vm_end >= mm->start_stack) {
249249
name = "[stack]";
250-
} else {
251-
unsigned long stack_start;
252-
struct proc_maps_private *pmp;
253-
254-
pmp = m->private;
255-
stack_start = pmp->task->stack_start;
256-
257-
if (vma->vm_start <= stack_start &&
258-
vma->vm_end >= stack_start) {
259-
pad_len_spaces(m, len);
260-
seq_printf(m,
261-
"[threadstack:%08lx]",
262-
#ifdef CONFIG_STACK_GROWSUP
263-
vma->vm_end - stack_start
264-
#else
265-
stack_start - vma->vm_start
266-
#endif
267-
);
268-
}
269250
}
270251
} else {
271252
name = "[vdso]";

‎include/linux/sched.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,6 @@ struct task_struct {
14971497
/* bitmask of trace recursion */
14981498
unsigned long trace_recursion;
14991499
#endif /* CONFIG_TRACING */
1500-
unsigned long stack_start;
15011500
#ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */
15021501
struct memcg_batch_info {
15031502
int do_batch; /* incremented when batch uncharge started */

‎kernel/fork.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
11141114

11151115
p->bts = NULL;
11161116

1117-
p->stack_start = stack_start;
1118-
11191117
/* Perform scheduler related setup. Assign this task to a CPU. */
11201118
sched_fork(p, clone_flags);
11211119

0 commit comments

Comments
 (0)