diff options
author | Johannes Weiner <hannes@cmpxchg.org> | 2016-02-02 19:57:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-02-03 11:28:43 -0500 |
commit | 65376df582174ffcec9e6471bf5b0dd79ba05e4a (patch) | |
tree | 60c4841a00605605bf8c315783ed48648333e865 /fs/proc/task_nommu.c | |
parent | 5c2ff95e41c9290d16556cd02e35b25d81be8fe0 (diff) |
proc: revert /proc/<pid>/maps [stack:TID] annotation
Commit b76437579d13 ("procfs: mark thread stack correctly in
proc/<pid>/maps") added [stack:TID] annotation to /proc/<pid>/maps.
Finding the task of a stack VMA requires walking the entire thread list,
turning this into quadratic behavior: a thousand threads means a
thousand stacks, so the rendering of /proc/<pid>/maps needs to look at a
million combinations.
The cost is not in proportion to the usefulness as described in the
patch.
Drop the [stack:TID] annotation to make /proc/<pid>/maps (and
/proc/<pid>/numa_maps) usable again for higher thread counts.
The [stack] annotation inside /proc/<pid>/task/<tid>/maps is retained, as
identifying the stack VMA there is an O(1) operation.
Siddesh said:
"The end users needed a way to identify thread stacks programmatically and
there wasn't a way to do that. I'm afraid I no longer remember (or have
access to the resources that would aid my memory since I changed
employers) the details of their requirement. However, I did do this on my
own time because I thought it was an interesting project for me and nobody
really gave any feedback then as to its utility, so as far as I am
concerned you could roll back the main thread maps information since the
information is available in the thread-specific files"
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
Cc: Shaohua Li <shli@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/task_nommu.c')
-rw-r--r-- | fs/proc/task_nommu.c | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index e0d64c92e4f6..faacb0c0d857 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c | |||
@@ -123,23 +123,26 @@ unsigned long task_statm(struct mm_struct *mm, | |||
123 | return size; | 123 | return size; |
124 | } | 124 | } |
125 | 125 | ||
126 | static pid_t pid_of_stack(struct proc_maps_private *priv, | 126 | static int is_stack(struct proc_maps_private *priv, |
127 | struct vm_area_struct *vma, bool is_pid) | 127 | struct vm_area_struct *vma, int is_pid) |
128 | { | 128 | { |
129 | struct inode *inode = priv->inode; | 129 | struct mm_struct *mm = vma->vm_mm; |
130 | struct task_struct *task; | 130 | int stack = 0; |
131 | pid_t ret = 0; | 131 | |
132 | 132 | if (is_pid) { | |
133 | rcu_read_lock(); | 133 | stack = vma->vm_start <= mm->start_stack && |
134 | task = pid_task(proc_pid(inode), PIDTYPE_PID); | 134 | vma->vm_end >= mm->start_stack; |
135 | if (task) { | 135 | } else { |
136 | task = task_of_stack(task, vma, is_pid); | 136 | struct inode *inode = priv->inode; |
137 | struct task_struct *task; | ||
138 | |||
139 | rcu_read_lock(); | ||
140 | task = pid_task(proc_pid(inode), PIDTYPE_PID); | ||
137 | if (task) | 141 | if (task) |
138 | ret = task_pid_nr_ns(task, inode->i_sb->s_fs_info); | 142 | stack = vma_is_stack_for_task(vma, task); |
143 | rcu_read_unlock(); | ||
139 | } | 144 | } |
140 | rcu_read_unlock(); | 145 | return stack; |
141 | |||
142 | return ret; | ||
143 | } | 146 | } |
144 | 147 | ||
145 | /* | 148 | /* |
@@ -181,21 +184,9 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, | |||
181 | if (file) { | 184 | if (file) { |
182 | seq_pad(m, ' '); | 185 | seq_pad(m, ' '); |
183 | seq_file_path(m, file, ""); | 186 | seq_file_path(m, file, ""); |
184 | } else if (mm) { | 187 | } else if (mm && is_stack(priv, vma, is_pid)) { |
185 | pid_t tid = pid_of_stack(priv, vma, is_pid); | 188 | seq_pad(m, ' '); |
186 | 189 | seq_printf(m, "[stack]"); | |
187 | if (tid != 0) { | ||
188 | seq_pad(m, ' '); | ||
189 | /* | ||
190 | * Thread stack in /proc/PID/task/TID/maps or | ||
191 | * the main process stack. | ||
192 | */ | ||
193 | if (!is_pid || (vma->vm_start <= mm->start_stack && | ||
194 | vma->vm_end >= mm->start_stack)) | ||
195 | seq_printf(m, "[stack]"); | ||
196 | else | ||
197 | seq_printf(m, "[stack:%d]", tid); | ||
198 | } | ||
199 | } | 190 | } |
200 | 191 | ||
201 | seq_putc(m, '\n'); | 192 | seq_putc(m, '\n'); |