aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/array.c')
-rw-r--r--fs/proc/array.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 9cbab7e93557..965625a0977d 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -62,6 +62,8 @@
62#include <linux/mman.h> 62#include <linux/mman.h>
63#include <linux/proc_fs.h> 63#include <linux/proc_fs.h>
64#include <linux/ioport.h> 64#include <linux/ioport.h>
65#include <linux/uaccess.h>
66#include <linux/io.h>
65#include <linux/mm.h> 67#include <linux/mm.h>
66#include <linux/hugetlb.h> 68#include <linux/hugetlb.h>
67#include <linux/pagemap.h> 69#include <linux/pagemap.h>
@@ -76,9 +78,7 @@
76#include <linux/rcupdate.h> 78#include <linux/rcupdate.h>
77#include <linux/delayacct.h> 79#include <linux/delayacct.h>
78 80
79#include <asm/uaccess.h>
80#include <asm/pgtable.h> 81#include <asm/pgtable.h>
81#include <asm/io.h>
82#include <asm/processor.h> 82#include <asm/processor.h>
83#include "internal.h" 83#include "internal.h"
84 84
@@ -87,10 +87,10 @@
87do { memcpy(buffer, string, strlen(string)); \ 87do { memcpy(buffer, string, strlen(string)); \
88 buffer += strlen(string); } while (0) 88 buffer += strlen(string); } while (0)
89 89
90static inline char * task_name(struct task_struct *p, char * buf) 90static inline char *task_name(struct task_struct *p, char *buf)
91{ 91{
92 int i; 92 int i;
93 char * name; 93 char *name;
94 char tcomm[sizeof(p->comm)]; 94 char tcomm[sizeof(p->comm)];
95 95
96 get_task_comm(tcomm, p); 96 get_task_comm(tcomm, p);
@@ -138,7 +138,7 @@ static const char *task_state_array[] = {
138 "X (dead)" /* 32 */ 138 "X (dead)" /* 32 */
139}; 139};
140 140
141static inline const char * get_task_state(struct task_struct *tsk) 141static inline const char *get_task_state(struct task_struct *tsk)
142{ 142{
143 unsigned int state = (tsk->state & (TASK_RUNNING | 143 unsigned int state = (tsk->state & (TASK_RUNNING |
144 TASK_INTERRUPTIBLE | 144 TASK_INTERRUPTIBLE |
@@ -156,7 +156,7 @@ static inline const char * get_task_state(struct task_struct *tsk)
156 return *p; 156 return *p;
157} 157}
158 158
159static inline char * task_state(struct task_struct *p, char *buffer) 159static inline char *task_state(struct task_struct *p, char *buffer)
160{ 160{
161 struct group_info *group_info; 161 struct group_info *group_info;
162 int g; 162 int g;
@@ -172,8 +172,8 @@ static inline char * task_state(struct task_struct *p, char *buffer)
172 "Uid:\t%d\t%d\t%d\t%d\n" 172 "Uid:\t%d\t%d\t%d\t%d\n"
173 "Gid:\t%d\t%d\t%d\t%d\n", 173 "Gid:\t%d\t%d\t%d\t%d\n",
174 get_task_state(p), 174 get_task_state(p),
175 p->tgid, p->pid, 175 p->tgid, p->pid,
176 pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0, 176 pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0,
177 pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0, 177 pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0,
178 p->uid, p->euid, p->suid, p->fsuid, 178 p->uid, p->euid, p->suid, p->fsuid,
179 p->gid, p->egid, p->sgid, p->fsgid); 179 p->gid, p->egid, p->sgid, p->fsgid);
@@ -191,15 +191,15 @@ static inline char * task_state(struct task_struct *p, char *buffer)
191 get_group_info(group_info); 191 get_group_info(group_info);
192 task_unlock(p); 192 task_unlock(p);
193 193
194 for (g = 0; g < min(group_info->ngroups,NGROUPS_SMALL); g++) 194 for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++)
195 buffer += sprintf(buffer, "%d ", GROUP_AT(group_info,g)); 195 buffer += sprintf(buffer, "%d ", GROUP_AT(group_info, g));
196 put_group_info(group_info); 196 put_group_info(group_info);
197 197
198 buffer += sprintf(buffer, "\n"); 198 buffer += sprintf(buffer, "\n");
199 return buffer; 199 return buffer;
200} 200}
201 201
202static char * render_sigset_t(const char *header, sigset_t *set, char *buffer) 202static char *render_sigset_t(const char *header, sigset_t *set, char *buffer)
203{ 203{
204 int i, len; 204 int i, len;
205 205
@@ -239,7 +239,7 @@ static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign,
239 } 239 }
240} 240}
241 241
242static inline char * task_sig(struct task_struct *p, char *buffer) 242static inline char *task_sig(struct task_struct *p, char *buffer)
243{ 243{
244 unsigned long flags; 244 unsigned long flags;
245 sigset_t pending, shpending, blocked, ignored, caught; 245 sigset_t pending, shpending, blocked, ignored, caught;
@@ -298,14 +298,14 @@ static inline char *task_context_switch_counts(struct task_struct *p,
298 p->nivcsw); 298 p->nivcsw);
299} 299}
300 300
301int proc_pid_status(struct task_struct *task, char * buffer) 301int proc_pid_status(struct task_struct *task, char *buffer)
302{ 302{
303 char * orig = buffer; 303 char *orig = buffer;
304 struct mm_struct *mm = get_task_mm(task); 304 struct mm_struct *mm = get_task_mm(task);
305 305
306 buffer = task_name(task, buffer); 306 buffer = task_name(task, buffer);
307 buffer = task_state(task, buffer); 307 buffer = task_state(task, buffer);
308 308
309 if (mm) { 309 if (mm) {
310 buffer = task_mem(mm, buffer); 310 buffer = task_mem(mm, buffer);
311 mmput(mm); 311 mmput(mm);
@@ -342,7 +342,7 @@ static clock_t task_utime(struct task_struct *p)
342 342
343static clock_t task_stime(struct task_struct *p) 343static clock_t task_stime(struct task_struct *p)
344{ 344{
345 clock_t stime = cputime_to_clock_t(p->stime); 345 clock_t stime;
346 346
347 /* 347 /*
348 * Use CFS's precise accounting. (we subtract utime from 348 * Use CFS's precise accounting. (we subtract utime from
@@ -354,8 +354,7 @@ static clock_t task_stime(struct task_struct *p)
354 return stime; 354 return stime;
355} 355}
356 356
357 357static int do_task_stat(struct task_struct *task, char *buffer, int whole)
358static int do_task_stat(struct task_struct *task, char * buffer, int whole)
359{ 358{
360 unsigned long vsize, eip, esp, wchan = ~0UL; 359 unsigned long vsize, eip, esp, wchan = ~0UL;
361 long priority, nice; 360 long priority, nice;
@@ -363,7 +362,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
363 sigset_t sigign, sigcatch; 362 sigset_t sigign, sigcatch;
364 char state; 363 char state;
365 int res; 364 int res;
366 pid_t ppid = 0, pgid = -1, sid = -1; 365 pid_t ppid = 0, pgid = -1, sid = -1;
367 int num_threads = 0; 366 int num_threads = 0;
368 struct mm_struct *mm; 367 struct mm_struct *mm;
369 unsigned long long start_time; 368 unsigned long long start_time;
@@ -434,7 +433,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
434 } 433 }
435 rcu_read_unlock(); 434 rcu_read_unlock();
436 435
437 if (!whole || num_threads<2) 436 if (!whole || num_threads < 2)
438 wchan = get_wchan(task); 437 wchan = get_wchan(task);
439 if (!whole) { 438 if (!whole) {
440 min_flt = task->min_flt; 439 min_flt = task->min_flt;
@@ -456,7 +455,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
456 /* convert nsec -> ticks */ 455 /* convert nsec -> ticks */
457 start_time = nsec_to_clock_t(start_time); 456 start_time = nsec_to_clock_t(start_time);
458 457
459 res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %u %lu \ 458 res = sprintf(buffer, "%d (%s) %c %d %d %d %d %d %u %lu \
460%lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ 459%lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
461%lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n", 460%lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n",
462 task->pid, 461 task->pid,
@@ -482,7 +481,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
482 start_time, 481 start_time,
483 vsize, 482 vsize,
484 mm ? get_mm_rss(mm) : 0, 483 mm ? get_mm_rss(mm) : 0,
485 rsslim, 484 rsslim,
486 mm ? mm->start_code : 0, 485 mm ? mm->start_code : 0,
487 mm ? mm->end_code : 0, 486 mm ? mm->end_code : 0,
488 mm ? mm->start_stack : 0, 487 mm ? mm->start_stack : 0,
@@ -504,17 +503,17 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
504 task->rt_priority, 503 task->rt_priority,
505 task->policy, 504 task->policy,
506 (unsigned long long)delayacct_blkio_ticks(task)); 505 (unsigned long long)delayacct_blkio_ticks(task));
507 if(mm) 506 if (mm)
508 mmput(mm); 507 mmput(mm);
509 return res; 508 return res;
510} 509}
511 510
512int proc_tid_stat(struct task_struct *task, char * buffer) 511int proc_tid_stat(struct task_struct *task, char *buffer)
513{ 512{
514 return do_task_stat(task, buffer, 0); 513 return do_task_stat(task, buffer, 0);
515} 514}
516 515
517int proc_tgid_stat(struct task_struct *task, char * buffer) 516int proc_tgid_stat(struct task_struct *task, char *buffer)
518{ 517{
519 return do_task_stat(task, buffer, 1); 518 return do_task_stat(task, buffer, 1);
520} 519}
@@ -523,12 +522,12 @@ int proc_pid_statm(struct task_struct *task, char *buffer)
523{ 522{
524 int size = 0, resident = 0, shared = 0, text = 0, lib = 0, data = 0; 523 int size = 0, resident = 0, shared = 0, text = 0, lib = 0, data = 0;
525 struct mm_struct *mm = get_task_mm(task); 524 struct mm_struct *mm = get_task_mm(task);
526 525
527 if (mm) { 526 if (mm) {
528 size = task_statm(mm, &shared, &text, &data, &resident); 527 size = task_statm(mm, &shared, &text, &data, &resident);
529 mmput(mm); 528 mmput(mm);
530 } 529 }
531 530
532 return sprintf(buffer,"%d %d %d %d %d %d %d\n", 531 return sprintf(buffer, "%d %d %d %d %d %d %d\n",
533 size, resident, shared, text, lib, data, 0); 532 size, resident, shared, text, lib, data, 0);
534} 533}