diff options
Diffstat (limited to 'fs/proc/array.c')
| -rw-r--r-- | fs/proc/array.c | 96 |
1 files changed, 4 insertions, 92 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c index f560325c444f..e51f2ec2c5e5 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
| @@ -68,7 +68,6 @@ | |||
| 68 | #include <linux/hugetlb.h> | 68 | #include <linux/hugetlb.h> |
| 69 | #include <linux/pagemap.h> | 69 | #include <linux/pagemap.h> |
| 70 | #include <linux/swap.h> | 70 | #include <linux/swap.h> |
| 71 | #include <linux/slab.h> | ||
| 72 | #include <linux/smp.h> | 71 | #include <linux/smp.h> |
| 73 | #include <linux/signal.h> | 72 | #include <linux/signal.h> |
| 74 | #include <linux/highmem.h> | 73 | #include <linux/highmem.h> |
| @@ -270,8 +269,10 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p) | |||
| 270 | blocked = p->blocked; | 269 | blocked = p->blocked; |
| 271 | collect_sigign_sigcatch(p, &ignored, &caught); | 270 | collect_sigign_sigcatch(p, &ignored, &caught); |
| 272 | num_threads = atomic_read(&p->signal->count); | 271 | num_threads = atomic_read(&p->signal->count); |
| 272 | rcu_read_lock(); /* FIXME: is this correct? */ | ||
| 273 | qsize = atomic_read(&__task_cred(p)->user->sigpending); | 273 | qsize = atomic_read(&__task_cred(p)->user->sigpending); |
| 274 | qlim = p->signal->rlim[RLIMIT_SIGPENDING].rlim_cur; | 274 | rcu_read_unlock(); |
| 275 | qlim = task_rlimit(p, RLIMIT_SIGPENDING); | ||
| 275 | unlock_task_sighand(p, &flags); | 276 | unlock_task_sighand(p, &flags); |
| 276 | } | 277 | } |
| 277 | 278 | ||
| @@ -327,94 +328,6 @@ static inline void task_context_switch_counts(struct seq_file *m, | |||
| 327 | p->nivcsw); | 328 | p->nivcsw); |
| 328 | } | 329 | } |
| 329 | 330 | ||
| 330 | #ifdef CONFIG_MMU | ||
| 331 | |||
| 332 | struct stack_stats { | ||
| 333 | struct vm_area_struct *vma; | ||
| 334 | unsigned long startpage; | ||
| 335 | unsigned long usage; | ||
| 336 | }; | ||
| 337 | |||
| 338 | static int stack_usage_pte_range(pmd_t *pmd, unsigned long addr, | ||
| 339 | unsigned long end, struct mm_walk *walk) | ||
| 340 | { | ||
| 341 | struct stack_stats *ss = walk->private; | ||
| 342 | struct vm_area_struct *vma = ss->vma; | ||
| 343 | pte_t *pte, ptent; | ||
| 344 | spinlock_t *ptl; | ||
| 345 | int ret = 0; | ||
| 346 | |||
| 347 | pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); | ||
| 348 | for (; addr != end; pte++, addr += PAGE_SIZE) { | ||
| 349 | ptent = *pte; | ||
| 350 | |||
| 351 | #ifdef CONFIG_STACK_GROWSUP | ||
| 352 | if (pte_present(ptent) || is_swap_pte(ptent)) | ||
| 353 | ss->usage = addr - ss->startpage + PAGE_SIZE; | ||
| 354 | #else | ||
| 355 | if (pte_present(ptent) || is_swap_pte(ptent)) { | ||
| 356 | ss->usage = ss->startpage - addr + PAGE_SIZE; | ||
| 357 | pte++; | ||
| 358 | ret = 1; | ||
| 359 | break; | ||
| 360 | } | ||
| 361 | #endif | ||
| 362 | } | ||
| 363 | pte_unmap_unlock(pte - 1, ptl); | ||
| 364 | cond_resched(); | ||
| 365 | return ret; | ||
| 366 | } | ||
| 367 | |||
| 368 | static inline unsigned long get_stack_usage_in_bytes(struct vm_area_struct *vma, | ||
| 369 | struct task_struct *task) | ||
| 370 | { | ||
| 371 | struct stack_stats ss; | ||
| 372 | struct mm_walk stack_walk = { | ||
| 373 | .pmd_entry = stack_usage_pte_range, | ||
| 374 | .mm = vma->vm_mm, | ||
| 375 | .private = &ss, | ||
| 376 | }; | ||
| 377 | |||
| 378 | if (!vma->vm_mm || is_vm_hugetlb_page(vma)) | ||
| 379 | return 0; | ||
| 380 | |||
| 381 | ss.vma = vma; | ||
| 382 | ss.startpage = task->stack_start & PAGE_MASK; | ||
| 383 | ss.usage = 0; | ||
| 384 | |||
| 385 | #ifdef CONFIG_STACK_GROWSUP | ||
| 386 | walk_page_range(KSTK_ESP(task) & PAGE_MASK, vma->vm_end, | ||
| 387 | &stack_walk); | ||
| 388 | #else | ||
| 389 | walk_page_range(vma->vm_start, (KSTK_ESP(task) & PAGE_MASK) + PAGE_SIZE, | ||
| 390 | &stack_walk); | ||
| 391 | #endif | ||
| 392 | return ss.usage; | ||
| 393 | } | ||
| 394 | |||
| 395 | static inline void task_show_stack_usage(struct seq_file *m, | ||
| 396 | struct task_struct *task) | ||
| 397 | { | ||
| 398 | struct vm_area_struct *vma; | ||
| 399 | struct mm_struct *mm = get_task_mm(task); | ||
| 400 | |||
| 401 | if (mm) { | ||
| 402 | down_read(&mm->mmap_sem); | ||
| 403 | vma = find_vma(mm, task->stack_start); | ||
| 404 | if (vma) | ||
| 405 | seq_printf(m, "Stack usage:\t%lu kB\n", | ||
| 406 | get_stack_usage_in_bytes(vma, task) >> 10); | ||
| 407 | |||
| 408 | up_read(&mm->mmap_sem); | ||
| 409 | mmput(mm); | ||
| 410 | } | ||
| 411 | } | ||
| 412 | #else | ||
| 413 | static void task_show_stack_usage(struct seq_file *m, struct task_struct *task) | ||
| 414 | { | ||
| 415 | } | ||
| 416 | #endif /* CONFIG_MMU */ | ||
| 417 | |||
| 418 | static void task_cpus_allowed(struct seq_file *m, struct task_struct *task) | 331 | static void task_cpus_allowed(struct seq_file *m, struct task_struct *task) |
| 419 | { | 332 | { |
| 420 | seq_printf(m, "Cpus_allowed:\t"); | 333 | seq_printf(m, "Cpus_allowed:\t"); |
| @@ -445,7 +358,6 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, | |||
| 445 | task_show_regs(m, task); | 358 | task_show_regs(m, task); |
| 446 | #endif | 359 | #endif |
| 447 | task_context_switch_counts(m, task); | 360 | task_context_switch_counts(m, task); |
| 448 | task_show_stack_usage(m, task); | ||
| 449 | return 0; | 361 | return 0; |
| 450 | } | 362 | } |
| 451 | 363 | ||
| @@ -507,7 +419,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
| 507 | cutime = sig->cutime; | 419 | cutime = sig->cutime; |
| 508 | cstime = sig->cstime; | 420 | cstime = sig->cstime; |
| 509 | cgtime = sig->cgtime; | 421 | cgtime = sig->cgtime; |
| 510 | rsslim = sig->rlim[RLIMIT_RSS].rlim_cur; | 422 | rsslim = ACCESS_ONCE(sig->rlim[RLIMIT_RSS].rlim_cur); |
| 511 | 423 | ||
| 512 | /* add up live thread stats at the group level */ | 424 | /* add up live thread stats at the group level */ |
| 513 | if (whole) { | 425 | if (whole) { |
