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 /fs/proc/task_nommu.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 'fs/proc/task_nommu.c')
-rw-r--r-- | fs/proc/task_nommu.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index f36e213835cc..599ec2e20104 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c | |||
@@ -123,6 +123,25 @@ 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, | ||
127 | struct vm_area_struct *vma, bool is_pid) | ||
128 | { | ||
129 | struct inode *inode = priv->inode; | ||
130 | struct task_struct *task; | ||
131 | pid_t ret = 0; | ||
132 | |||
133 | rcu_read_lock(); | ||
134 | task = pid_task(proc_pid(inode), PIDTYPE_PID); | ||
135 | if (task) { | ||
136 | task = task_of_stack(task, vma, is_pid); | ||
137 | if (task) | ||
138 | ret = task_pid_nr_ns(task, inode->i_sb->s_fs_info); | ||
139 | } | ||
140 | rcu_read_unlock(); | ||
141 | |||
142 | return ret; | ||
143 | } | ||
144 | |||
126 | /* | 145 | /* |
127 | * display a single VMA to a sequenced file | 146 | * display a single VMA to a sequenced file |
128 | */ | 147 | */ |
@@ -163,7 +182,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, | |||
163 | seq_pad(m, ' '); | 182 | seq_pad(m, ' '); |
164 | seq_path(m, &file->f_path, ""); | 183 | seq_path(m, &file->f_path, ""); |
165 | } else if (mm) { | 184 | } else if (mm) { |
166 | pid_t tid = vm_is_stack(priv->task, vma, is_pid); | 185 | pid_t tid = pid_of_stack(priv, vma, is_pid); |
167 | 186 | ||
168 | if (tid != 0) { | 187 | if (tid != 0) { |
169 | seq_pad(m, ' '); | 188 | seq_pad(m, ' '); |