aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/task_mmu.c25
-rw-r--r--fs/proc/task_nommu.c21
2 files changed, 41 insertions, 5 deletions
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 4793e4a843b0..adddf697c4ea 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -261,13 +261,31 @@ static int do_maps_open(struct inode *inode, struct file *file,
261 sizeof(struct proc_maps_private)); 261 sizeof(struct proc_maps_private));
262} 262}
263 263
264static pid_t pid_of_stack(struct proc_maps_private *priv,
265 struct vm_area_struct *vma, bool is_pid)
266{
267 struct inode *inode = priv->inode;
268 struct task_struct *task;
269 pid_t ret = 0;
270
271 rcu_read_lock();
272 task = pid_task(proc_pid(inode), PIDTYPE_PID);
273 if (task) {
274 task = task_of_stack(task, vma, is_pid);
275 if (task)
276 ret = task_pid_nr_ns(task, inode->i_sb->s_fs_info);
277 }
278 rcu_read_unlock();
279
280 return ret;
281}
282
264static void 283static void
265show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) 284show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
266{ 285{
267 struct mm_struct *mm = vma->vm_mm; 286 struct mm_struct *mm = vma->vm_mm;
268 struct file *file = vma->vm_file; 287 struct file *file = vma->vm_file;
269 struct proc_maps_private *priv = m->private; 288 struct proc_maps_private *priv = m->private;
270 struct task_struct *task = priv->task;
271 vm_flags_t flags = vma->vm_flags; 289 vm_flags_t flags = vma->vm_flags;
272 unsigned long ino = 0; 290 unsigned long ino = 0;
273 unsigned long long pgoff = 0; 291 unsigned long long pgoff = 0;
@@ -332,8 +350,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
332 goto done; 350 goto done;
333 } 351 }
334 352
335 tid = vm_is_stack(task, vma, is_pid); 353 tid = pid_of_stack(priv, vma, is_pid);
336
337 if (tid != 0) { 354 if (tid != 0) {
338 /* 355 /*
339 * Thread stack in /proc/PID/task/TID/maps or 356 * Thread stack in /proc/PID/task/TID/maps or
@@ -1446,7 +1463,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
1446 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { 1463 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
1447 seq_puts(m, " heap"); 1464 seq_puts(m, " heap");
1448 } else { 1465 } else {
1449 pid_t tid = vm_is_stack(task, vma, is_pid); 1466 pid_t tid = pid_of_stack(proc_priv, vma, is_pid);
1450 if (tid != 0) { 1467 if (tid != 0) {
1451 /* 1468 /*
1452 * Thread stack in /proc/PID/task/TID/maps or 1469 * Thread stack in /proc/PID/task/TID/maps or
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
126static 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, ' ');