diff options
author | Oleg Nesterov <oleg@redhat.com> | 2014-10-09 18:25:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-09 22:25:50 -0400 |
commit | 58cb65487e92b47448d00a711c9f5922137d5678 (patch) | |
tree | ee260fe8859876f861b07d131eab07a35617b426 /mm/util.c | |
parent | 2c03376d2db005869b1d4449097d51c96196529e (diff) |
proc/maps: make vm_is_stack() logic namespace-friendly
- Rename vm_is_stack() to task_of_stack() and change it to return
"struct task_struct *" rather than the global (and thus wrong in
general) pid_t.
- Add the new pid_of_stack() helper which calls task_of_stack() and
uses the right namespace to report the correct pid_t.
Unfortunately we need to define this helper twice, in task_mmu.c
and in task_nommu.c. perhaps it makes sense to add fs/proc/util.c
and move at least pid_of_stack/task_of_stack there to avoid the
code duplication.
- Change show_map_vma() and show_numa_map() to use the new helper.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Greg Ungerer <gerg@uclinux.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/util.c')
-rw-r--r-- | mm/util.c | 23 |
1 files changed, 8 insertions, 15 deletions
@@ -170,32 +170,25 @@ static int vm_is_stack_for_task(struct task_struct *t, | |||
170 | /* | 170 | /* |
171 | * Check if the vma is being used as a stack. | 171 | * Check if the vma is being used as a stack. |
172 | * If is_group is non-zero, check in the entire thread group or else | 172 | * If is_group is non-zero, check in the entire thread group or else |
173 | * just check in the current task. Returns the pid of the task that | 173 | * just check in the current task. Returns the task_struct of the task |
174 | * the vma is stack for. | 174 | * that the vma is stack for. Must be called under rcu_read_lock(). |
175 | */ | 175 | */ |
176 | pid_t vm_is_stack(struct task_struct *task, | 176 | struct task_struct *task_of_stack(struct task_struct *task, |
177 | struct vm_area_struct *vma, int in_group) | 177 | struct vm_area_struct *vma, bool in_group) |
178 | { | 178 | { |
179 | pid_t ret = 0; | ||
180 | |||
181 | if (vm_is_stack_for_task(task, vma)) | 179 | if (vm_is_stack_for_task(task, vma)) |
182 | return task->pid; | 180 | return task; |
183 | 181 | ||
184 | if (in_group) { | 182 | if (in_group) { |
185 | struct task_struct *t; | 183 | struct task_struct *t; |
186 | 184 | ||
187 | rcu_read_lock(); | ||
188 | for_each_thread(task, t) { | 185 | for_each_thread(task, t) { |
189 | if (vm_is_stack_for_task(t, vma)) { | 186 | if (vm_is_stack_for_task(t, vma)) |
190 | ret = t->pid; | 187 | return t; |
191 | goto done; | ||
192 | } | ||
193 | } | 188 | } |
194 | done: | ||
195 | rcu_read_unlock(); | ||
196 | } | 189 | } |
197 | 190 | ||
198 | return ret; | 191 | return NULL; |
199 | } | 192 | } |
200 | 193 | ||
201 | #if defined(CONFIG_MMU) && !defined(HAVE_ARCH_PICK_MMAP_LAYOUT) | 194 | #if defined(CONFIG_MMU) && !defined(HAVE_ARCH_PICK_MMAP_LAYOUT) |