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.c68
1 files changed, 39 insertions, 29 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 98e78e2f18..965625a097 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;
@@ -289,14 +289,23 @@ static inline char *task_cap(struct task_struct *p, char *buffer)
289 cap_t(p->cap_effective)); 289 cap_t(p->cap_effective));
290} 290}
291 291
292int proc_pid_status(struct task_struct *task, char * buffer) 292static inline char *task_context_switch_counts(struct task_struct *p,
293 char *buffer)
293{ 294{
294 char * orig = buffer; 295 return buffer + sprintf(buffer, "voluntary_ctxt_switches:\t%lu\n"
296 "nonvoluntary_ctxt_switches:\t%lu\n",
297 p->nvcsw,
298 p->nivcsw);
299}
300
301int proc_pid_status(struct task_struct *task, char *buffer)
302{
303 char *orig = buffer;
295 struct mm_struct *mm = get_task_mm(task); 304 struct mm_struct *mm = get_task_mm(task);
296 305
297 buffer = task_name(task, buffer); 306 buffer = task_name(task, buffer);
298 buffer = task_state(task, buffer); 307 buffer = task_state(task, buffer);
299 308
300 if (mm) { 309 if (mm) {
301 buffer = task_mem(mm, buffer); 310 buffer = task_mem(mm, buffer);
302 mmput(mm); 311 mmput(mm);
@@ -307,6 +316,7 @@ int proc_pid_status(struct task_struct *task, char * buffer)
307#if defined(CONFIG_S390) 316#if defined(CONFIG_S390)
308 buffer = task_show_regs(task, buffer); 317 buffer = task_show_regs(task, buffer);
309#endif 318#endif
319 buffer = task_context_switch_counts(task, buffer);
310 return buffer - orig; 320 return buffer - orig;
311} 321}
312 322
@@ -332,7 +342,7 @@ static clock_t task_utime(struct task_struct *p)
332 342
333static clock_t task_stime(struct task_struct *p) 343static clock_t task_stime(struct task_struct *p)
334{ 344{
335 clock_t stime = cputime_to_clock_t(p->stime); 345 clock_t stime;
336 346
337 /* 347 /*
338 * Use CFS's precise accounting. (we subtract utime from 348 * Use CFS's precise accounting. (we subtract utime from
@@ -344,8 +354,7 @@ static clock_t task_stime(struct task_struct *p)
344 return stime; 354 return stime;
345} 355}
346 356
347 357static int do_task_stat(struct task_struct *task, char *buffer, int whole)
348static int do_task_stat(struct task_struct *task, char * buffer, int whole)
349{ 358{
350 unsigned long vsize, eip, esp, wchan = ~0UL; 359 unsigned long vsize, eip, esp, wchan = ~0UL;
351 long priority, nice; 360 long priority, nice;
@@ -353,7 +362,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
353 sigset_t sigign, sigcatch; 362 sigset_t sigign, sigcatch;
354 char state; 363 char state;
355 int res; 364 int res;
356 pid_t ppid = 0, pgid = -1, sid = -1; 365 pid_t ppid = 0, pgid = -1, sid = -1;
357 int num_threads = 0; 366 int num_threads = 0;
358 struct mm_struct *mm; 367 struct mm_struct *mm;
359 unsigned long long start_time; 368 unsigned long long start_time;
@@ -424,7 +433,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
424 } 433 }
425 rcu_read_unlock(); 434 rcu_read_unlock();
426 435
427 if (!whole || num_threads<2) 436 if (!whole || num_threads < 2)
428 wchan = get_wchan(task); 437 wchan = get_wchan(task);
429 if (!whole) { 438 if (!whole) {
430 min_flt = task->min_flt; 439 min_flt = task->min_flt;
@@ -440,12 +449,13 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
440 449
441 /* Temporary variable needed for gcc-2.96 */ 450 /* Temporary variable needed for gcc-2.96 */
442 /* convert timespec -> nsec*/ 451 /* convert timespec -> nsec*/
443 start_time = (unsigned long long)task->start_time.tv_sec * NSEC_PER_SEC 452 start_time =
444 + task->start_time.tv_nsec; 453 (unsigned long long)task->real_start_time.tv_sec * NSEC_PER_SEC
454 + task->real_start_time.tv_nsec;
445 /* convert nsec -> ticks */ 455 /* convert nsec -> ticks */
446 start_time = nsec_to_clock_t(start_time); 456 start_time = nsec_to_clock_t(start_time);
447 457
448 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 \
449%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 \
450%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",
451 task->pid, 461 task->pid,
@@ -471,7 +481,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
471 start_time, 481 start_time,
472 vsize, 482 vsize,
473 mm ? get_mm_rss(mm) : 0, 483 mm ? get_mm_rss(mm) : 0,
474 rsslim, 484 rsslim,
475 mm ? mm->start_code : 0, 485 mm ? mm->start_code : 0,
476 mm ? mm->end_code : 0, 486 mm ? mm->end_code : 0,
477 mm ? mm->start_stack : 0, 487 mm ? mm->start_stack : 0,
@@ -493,17 +503,17 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
493 task->rt_priority, 503 task->rt_priority,
494 task->policy, 504 task->policy,
495 (unsigned long long)delayacct_blkio_ticks(task)); 505 (unsigned long long)delayacct_blkio_ticks(task));
496 if(mm) 506 if (mm)
497 mmput(mm); 507 mmput(mm);
498 return res; 508 return res;
499} 509}
500 510
501int proc_tid_stat(struct task_struct *task, char * buffer) 511int proc_tid_stat(struct task_struct *task, char *buffer)
502{ 512{
503 return do_task_stat(task, buffer, 0); 513 return do_task_stat(task, buffer, 0);
504} 514}
505 515
506int proc_tgid_stat(struct task_struct *task, char * buffer) 516int proc_tgid_stat(struct task_struct *task, char *buffer)
507{ 517{
508 return do_task_stat(task, buffer, 1); 518 return do_task_stat(task, buffer, 1);
509} 519}
@@ -512,12 +522,12 @@ int proc_pid_statm(struct task_struct *task, char *buffer)
512{ 522{
513 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;
514 struct mm_struct *mm = get_task_mm(task); 524 struct mm_struct *mm = get_task_mm(task);
515 525
516 if (mm) { 526 if (mm) {
517 size = task_statm(mm, &shared, &text, &data, &resident); 527 size = task_statm(mm, &shared, &text, &data, &resident);
518 mmput(mm); 528 mmput(mm);
519 } 529 }
520 530
521 return sprintf(buffer,"%d %d %d %d %d %d %d\n", 531 return sprintf(buffer, "%d %d %d %d %d %d %d\n",
522 size, resident, shared, text, lib, data, 0); 532 size, resident, shared, text, lib, data, 0);
523} 533}