diff options
| -rw-r--r-- | Documentation/filesystems/proc.txt | 26 | ||||
| -rw-r--r-- | fs/proc/task_mmu.c | 29 | ||||
| -rw-r--r-- | fs/proc/task_nommu.c | 28 |
3 files changed, 20 insertions, 63 deletions
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 219ffd41a911..74329fd0add2 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt | |||
| @@ -395,32 +395,6 @@ is not associated with a file: | |||
| 395 | 395 | ||
| 396 | or if empty, the mapping is anonymous. | 396 | or if empty, the mapping is anonymous. |
| 397 | 397 | ||
| 398 | The /proc/PID/task/TID/maps is a view of the virtual memory from the viewpoint | ||
| 399 | of the individual tasks of a process. In this file you will see a mapping marked | ||
| 400 | as [stack] if that task sees it as a stack. Hence, for the example above, the | ||
| 401 | task-level map, i.e. /proc/PID/task/TID/maps for thread 1001 will look like this: | ||
| 402 | |||
| 403 | 08048000-08049000 r-xp 00000000 03:00 8312 /opt/test | ||
| 404 | 08049000-0804a000 rw-p 00001000 03:00 8312 /opt/test | ||
| 405 | 0804a000-0806b000 rw-p 00000000 00:00 0 [heap] | ||
| 406 | a7cb1000-a7cb2000 ---p 00000000 00:00 0 | ||
| 407 | a7cb2000-a7eb2000 rw-p 00000000 00:00 0 | ||
| 408 | a7eb2000-a7eb3000 ---p 00000000 00:00 0 | ||
| 409 | a7eb3000-a7ed5000 rw-p 00000000 00:00 0 [stack] | ||
| 410 | a7ed5000-a8008000 r-xp 00000000 03:00 4222 /lib/libc.so.6 | ||
| 411 | a8008000-a800a000 r--p 00133000 03:00 4222 /lib/libc.so.6 | ||
| 412 | a800a000-a800b000 rw-p 00135000 03:00 4222 /lib/libc.so.6 | ||
| 413 | a800b000-a800e000 rw-p 00000000 00:00 0 | ||
| 414 | a800e000-a8022000 r-xp 00000000 03:00 14462 /lib/libpthread.so.0 | ||
| 415 | a8022000-a8023000 r--p 00013000 03:00 14462 /lib/libpthread.so.0 | ||
| 416 | a8023000-a8024000 rw-p 00014000 03:00 14462 /lib/libpthread.so.0 | ||
| 417 | a8024000-a8027000 rw-p 00000000 00:00 0 | ||
| 418 | a8027000-a8043000 r-xp 00000000 03:00 8317 /lib/ld-linux.so.2 | ||
| 419 | a8043000-a8044000 r--p 0001b000 03:00 8317 /lib/ld-linux.so.2 | ||
| 420 | a8044000-a8045000 rw-p 0001c000 03:00 8317 /lib/ld-linux.so.2 | ||
| 421 | aff35000-aff4a000 rw-p 00000000 00:00 0 | ||
| 422 | ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso] | ||
| 423 | |||
| 424 | The /proc/PID/smaps is an extension based on maps, showing the memory | 398 | The /proc/PID/smaps is an extension based on maps, showing the memory |
| 425 | consumption for each of the process's mappings. For each of mappings there | 399 | consumption for each of the process's mappings. For each of mappings there |
| 426 | is a series of lines such as the following: | 400 | is a series of lines such as the following: |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 6909582ce5e5..35b92d81692f 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
| @@ -266,24 +266,15 @@ static int do_maps_open(struct inode *inode, struct file *file, | |||
| 266 | * /proc/PID/maps that is the stack of the main task. | 266 | * /proc/PID/maps that is the stack of the main task. |
| 267 | */ | 267 | */ |
| 268 | static int is_stack(struct proc_maps_private *priv, | 268 | static int is_stack(struct proc_maps_private *priv, |
| 269 | struct vm_area_struct *vma, int is_pid) | 269 | struct vm_area_struct *vma) |
| 270 | { | 270 | { |
| 271 | int stack = 0; | 271 | /* |
| 272 | 272 | * We make no effort to guess what a given thread considers to be | |
| 273 | if (is_pid) { | 273 | * its "stack". It's not even well-defined for programs written |
| 274 | stack = vma->vm_start <= vma->vm_mm->start_stack && | 274 | * languages like Go. |
| 275 | vma->vm_end >= vma->vm_mm->start_stack; | 275 | */ |
| 276 | } else { | 276 | return vma->vm_start <= vma->vm_mm->start_stack && |
| 277 | struct inode *inode = priv->inode; | 277 | vma->vm_end >= vma->vm_mm->start_stack; |
| 278 | struct task_struct *task; | ||
| 279 | |||
| 280 | rcu_read_lock(); | ||
| 281 | task = pid_task(proc_pid(inode), PIDTYPE_PID); | ||
| 282 | if (task) | ||
| 283 | stack = vma_is_stack_for_task(vma, task); | ||
| 284 | rcu_read_unlock(); | ||
| 285 | } | ||
| 286 | return stack; | ||
| 287 | } | 278 | } |
| 288 | 279 | ||
| 289 | static void | 280 | static void |
| @@ -354,7 +345,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) | |||
| 354 | goto done; | 345 | goto done; |
| 355 | } | 346 | } |
| 356 | 347 | ||
| 357 | if (is_stack(priv, vma, is_pid)) | 348 | if (is_stack(priv, vma)) |
| 358 | name = "[stack]"; | 349 | name = "[stack]"; |
| 359 | } | 350 | } |
| 360 | 351 | ||
| @@ -1669,7 +1660,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) | |||
| 1669 | seq_file_path(m, file, "\n\t= "); | 1660 | seq_file_path(m, file, "\n\t= "); |
| 1670 | } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { | 1661 | } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { |
| 1671 | seq_puts(m, " heap"); | 1662 | seq_puts(m, " heap"); |
| 1672 | } else if (is_stack(proc_priv, vma, is_pid)) { | 1663 | } else if (is_stack(proc_priv, vma)) { |
| 1673 | seq_puts(m, " stack"); | 1664 | seq_puts(m, " stack"); |
| 1674 | } | 1665 | } |
| 1675 | 1666 | ||
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index faacb0c0d857..37175621e890 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c | |||
| @@ -124,25 +124,17 @@ unsigned long task_statm(struct mm_struct *mm, | |||
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | static int is_stack(struct proc_maps_private *priv, | 126 | static int is_stack(struct proc_maps_private *priv, |
| 127 | struct vm_area_struct *vma, int is_pid) | 127 | struct vm_area_struct *vma) |
| 128 | { | 128 | { |
| 129 | struct mm_struct *mm = vma->vm_mm; | 129 | struct mm_struct *mm = vma->vm_mm; |
| 130 | int stack = 0; | 130 | |
| 131 | 131 | /* | |
| 132 | if (is_pid) { | 132 | * We make no effort to guess what a given thread considers to be |
| 133 | stack = vma->vm_start <= mm->start_stack && | 133 | * its "stack". It's not even well-defined for programs written |
| 134 | vma->vm_end >= mm->start_stack; | 134 | * languages like Go. |
| 135 | } else { | 135 | */ |
| 136 | struct inode *inode = priv->inode; | 136 | return vma->vm_start <= mm->start_stack && |
| 137 | struct task_struct *task; | 137 | vma->vm_end >= mm->start_stack; |
| 138 | |||
| 139 | rcu_read_lock(); | ||
| 140 | task = pid_task(proc_pid(inode), PIDTYPE_PID); | ||
| 141 | if (task) | ||
| 142 | stack = vma_is_stack_for_task(vma, task); | ||
| 143 | rcu_read_unlock(); | ||
| 144 | } | ||
| 145 | return stack; | ||
| 146 | } | 138 | } |
| 147 | 139 | ||
| 148 | /* | 140 | /* |
| @@ -184,7 +176,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, | |||
| 184 | if (file) { | 176 | if (file) { |
| 185 | seq_pad(m, ' '); | 177 | seq_pad(m, ' '); |
| 186 | seq_file_path(m, file, ""); | 178 | seq_file_path(m, file, ""); |
| 187 | } else if (mm && is_stack(priv, vma, is_pid)) { | 179 | } else if (mm && is_stack(priv, vma)) { |
| 188 | seq_pad(m, ' '); | 180 | seq_pad(m, ' '); |
| 189 | seq_printf(m, "[stack]"); | 181 | seq_printf(m, "[stack]"); |
| 190 | } | 182 | } |
