diff options
Diffstat (limited to 'fs/proc/task_mmu.c')
-rw-r--r-- | fs/proc/task_mmu.c | 73 |
1 files changed, 27 insertions, 46 deletions
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 85d16c67c33e..fa95ab2d3674 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -259,23 +259,29 @@ static int do_maps_open(struct inode *inode, struct file *file, | |||
259 | sizeof(struct proc_maps_private)); | 259 | sizeof(struct proc_maps_private)); |
260 | } | 260 | } |
261 | 261 | ||
262 | static pid_t pid_of_stack(struct proc_maps_private *priv, | 262 | /* |
263 | struct vm_area_struct *vma, bool is_pid) | 263 | * Indicate if the VMA is a stack for the given task; for |
264 | * /proc/PID/maps that is the stack of the main task. | ||
265 | */ | ||
266 | static int is_stack(struct proc_maps_private *priv, | ||
267 | struct vm_area_struct *vma, int is_pid) | ||
264 | { | 268 | { |
265 | struct inode *inode = priv->inode; | 269 | int stack = 0; |
266 | struct task_struct *task; | 270 | |
267 | pid_t ret = 0; | 271 | if (is_pid) { |
272 | stack = vma->vm_start <= vma->vm_mm->start_stack && | ||
273 | vma->vm_end >= vma->vm_mm->start_stack; | ||
274 | } else { | ||
275 | struct inode *inode = priv->inode; | ||
276 | struct task_struct *task; | ||
268 | 277 | ||
269 | rcu_read_lock(); | 278 | rcu_read_lock(); |
270 | task = pid_task(proc_pid(inode), PIDTYPE_PID); | 279 | task = pid_task(proc_pid(inode), PIDTYPE_PID); |
271 | if (task) { | ||
272 | task = task_of_stack(task, vma, is_pid); | ||
273 | if (task) | 280 | if (task) |
274 | ret = task_pid_nr_ns(task, inode->i_sb->s_fs_info); | 281 | stack = vma_is_stack_for_task(vma, task); |
282 | rcu_read_unlock(); | ||
275 | } | 283 | } |
276 | rcu_read_unlock(); | 284 | return stack; |
277 | |||
278 | return ret; | ||
279 | } | 285 | } |
280 | 286 | ||
281 | static void | 287 | static void |
@@ -335,8 +341,6 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) | |||
335 | 341 | ||
336 | name = arch_vma_name(vma); | 342 | name = arch_vma_name(vma); |
337 | if (!name) { | 343 | if (!name) { |
338 | pid_t tid; | ||
339 | |||
340 | if (!mm) { | 344 | if (!mm) { |
341 | name = "[vdso]"; | 345 | name = "[vdso]"; |
342 | goto done; | 346 | goto done; |
@@ -348,21 +352,8 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) | |||
348 | goto done; | 352 | goto done; |
349 | } | 353 | } |
350 | 354 | ||
351 | tid = pid_of_stack(priv, vma, is_pid); | 355 | if (is_stack(priv, vma, is_pid)) |
352 | if (tid != 0) { | 356 | name = "[stack]"; |
353 | /* | ||
354 | * Thread stack in /proc/PID/task/TID/maps or | ||
355 | * the main process stack. | ||
356 | */ | ||
357 | if (!is_pid || (vma->vm_start <= mm->start_stack && | ||
358 | vma->vm_end >= mm->start_stack)) { | ||
359 | name = "[stack]"; | ||
360 | } else { | ||
361 | /* Thread stack in /proc/PID/maps */ | ||
362 | seq_pad(m, ' '); | ||
363 | seq_printf(m, "[stack:%d]", tid); | ||
364 | } | ||
365 | } | ||
366 | } | 357 | } |
367 | 358 | ||
368 | done: | 359 | done: |
@@ -1552,18 +1543,19 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr, | |||
1552 | static int gather_hugetlb_stats(pte_t *pte, unsigned long hmask, | 1543 | static int gather_hugetlb_stats(pte_t *pte, unsigned long hmask, |
1553 | unsigned long addr, unsigned long end, struct mm_walk *walk) | 1544 | unsigned long addr, unsigned long end, struct mm_walk *walk) |
1554 | { | 1545 | { |
1546 | pte_t huge_pte = huge_ptep_get(pte); | ||
1555 | struct numa_maps *md; | 1547 | struct numa_maps *md; |
1556 | struct page *page; | 1548 | struct page *page; |
1557 | 1549 | ||
1558 | if (!pte_present(*pte)) | 1550 | if (!pte_present(huge_pte)) |
1559 | return 0; | 1551 | return 0; |
1560 | 1552 | ||
1561 | page = pte_page(*pte); | 1553 | page = pte_page(huge_pte); |
1562 | if (!page) | 1554 | if (!page) |
1563 | return 0; | 1555 | return 0; |
1564 | 1556 | ||
1565 | md = walk->private; | 1557 | md = walk->private; |
1566 | gather_stats(page, md, pte_dirty(*pte), 1); | 1558 | gather_stats(page, md, pte_dirty(huge_pte), 1); |
1567 | return 0; | 1559 | return 0; |
1568 | } | 1560 | } |
1569 | 1561 | ||
@@ -1617,19 +1609,8 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) | |||
1617 | seq_file_path(m, file, "\n\t= "); | 1609 | seq_file_path(m, file, "\n\t= "); |
1618 | } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { | 1610 | } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { |
1619 | seq_puts(m, " heap"); | 1611 | seq_puts(m, " heap"); |
1620 | } else { | 1612 | } else if (is_stack(proc_priv, vma, is_pid)) { |
1621 | pid_t tid = pid_of_stack(proc_priv, vma, is_pid); | 1613 | seq_puts(m, " stack"); |
1622 | if (tid != 0) { | ||
1623 | /* | ||
1624 | * Thread stack in /proc/PID/task/TID/maps or | ||
1625 | * the main process stack. | ||
1626 | */ | ||
1627 | if (!is_pid || (vma->vm_start <= mm->start_stack && | ||
1628 | vma->vm_end >= mm->start_stack)) | ||
1629 | seq_puts(m, " stack"); | ||
1630 | else | ||
1631 | seq_printf(m, " stack:%d", tid); | ||
1632 | } | ||
1633 | } | 1614 | } |
1634 | 1615 | ||
1635 | if (is_vm_hugetlb_page(vma)) | 1616 | if (is_vm_hugetlb_page(vma)) |