X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fproc%2Farray.c;h=41990f07d875de2c83f3dc16d94659fa0cf128a8;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=190ba24f30b518c6d271cc4e9195426351fa25d1;hpb=a2c21200f1c81b08cb55e417b68150bba439b646;p=linux-2.6.git diff --git a/fs/proc/array.c b/fs/proc/array.c index 190ba24f3..41990f07d 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -92,10 +92,13 @@ static inline char * task_name(struct task_struct *p, char * buf) { int i; char * name; + char tcomm[sizeof(p->comm)]; + + get_task_comm(tcomm, p); ADDBUF(buf, "Name:\t"); - name = p->comm; - i = sizeof(p->comm); + name = tcomm; + i = sizeof(tcomm); do { unsigned char c = *name; name++; @@ -131,9 +134,10 @@ static const char *task_state_array[] = { "S (sleeping)", /* 1 */ "D (disk sleep)", /* 2 */ "T (stopped)", /* 4 */ - "Z (zombie)", /* 8 */ - "X (dead)", /* 16 */ - "H (on hold)" /* 32 */ + "T (tracing stop)", /* 8 */ + "Z (zombie)", /* 16 */ + "X (dead)", /* 32 */ + "H (on hold)" /* 64 */ }; static inline const char * get_task_state(struct task_struct *tsk) @@ -144,6 +148,7 @@ static inline const char * get_task_state(struct task_struct *tsk) TASK_ZOMBIE | TASK_DEAD | TASK_STOPPED | + TASK_TRACED | TASK_ONHOLD); const char **p = &task_state_array[0]; @@ -158,12 +163,13 @@ static inline char * task_state(struct task_struct *p, char *buffer) { struct group_info *group_info; int g; - pid_t pid, ppid, tgid; + pid_t pid, ppid, tppid, tgid; read_lock(&tasklist_lock); - tgid = vx_map_tgid(current->vx_info, p->tgid); - pid = vx_map_tgid(current->vx_info, p->pid); - ppid = vx_map_tgid(current->vx_info, p->real_parent->pid); + tgid = vx_map_tgid(p->tgid); + pid = vx_map_pid(p->pid); + ppid = vx_map_pid(p->real_parent->pid); + tppid = vx_map_pid(p->parent->pid); buffer += sprintf(buffer, "State:\t%s\n" "SleepAVG:\t%lu%%\n" @@ -175,8 +181,8 @@ static inline char * task_state(struct task_struct *p, char *buffer) "Gid:\t%d\t%d\t%d\t%d\n", get_task_state(p), (p->sleep_avg/1024)*100/(1020000000/1024), - tgid, pid, p->pid ? ppid : 0, - p->pid && p->ptrace ? p->parent->pid : 0, + tgid, pid, (pid > 1) ? ppid : 0, + p->pid && p->ptrace ? tppid : 0, p->uid, p->euid, p->suid, p->fsuid, p->gid, p->egid, p->sgid, p->fsgid); read_unlock(&tasklist_lock); @@ -284,11 +290,10 @@ static inline char *task_cap(struct task_struct *p, char *buffer) cap_t(p->cap_effective)); } -extern char *task_mem(struct mm_struct *, char *); int proc_pid_status(struct task_struct *task, char * buffer) { char * orig = buffer; -#ifdef CONFIG_VSERVER_LEGACY +#ifdef CONFIG_VSERVER_LEGACY struct vx_info *vxi; struct nx_info *nxi; #endif @@ -304,7 +309,7 @@ int proc_pid_status(struct task_struct *task, char * buffer) buffer = task_sig(task, buffer); buffer = task_cap(task, buffer); -#ifdef CONFIG_VSERVER_LEGACY +#ifdef CONFIG_VSERVER_LEGACY buffer += sprintf (buffer,"s_context: %d\n", vx_task_xid(task)); vxi = task_get_vx_info(task); if (vxi) { @@ -342,12 +347,11 @@ int proc_pid_status(struct task_struct *task, char * buffer) return buffer - orig; } -extern unsigned long task_vsize(struct mm_struct *); int proc_pid_stat(struct task_struct *task, char * buffer) { unsigned long vsize, eip, esp, wchan; long priority, nice; - unsigned long long bias_jiffies; + unsigned long long bias_uptime = 0; int tty_pgrp = -1, tty_nr = 0; sigset_t sigign, sigcatch; char state; @@ -356,32 +360,19 @@ int proc_pid_stat(struct task_struct *task, char * buffer) int num_threads = 0; struct mm_struct *mm; unsigned long long start_time; + unsigned long cmin_flt = 0, cmaj_flt = 0, cutime = 0, cstime = 0; + char tcomm[sizeof(task->comm)]; state = *get_task_state(task); vsize = eip = esp = 0; - bias_jiffies = INITIAL_JIFFIES; - - task_lock(task); - if (__vx_task_flags(task, VXF_VIRT_UPTIME, 0)) { - bias_jiffies = task->vx_info->cvirt.bias_jiffies; - /* hmm, do we need that? */ - if (bias_jiffies > task->start_time) - bias_jiffies = task->start_time; - } - pid = vx_map_tgid(task->vx_info, task->pid); - - mm = task->mm; - if(mm) - mm = mmgrab(mm); - task_unlock(task); + mm = get_task_mm(task); if (mm) { - down_read(&mm->mmap_sem); vsize = task_vsize(mm); eip = KSTK_EIP(task); esp = KSTK_ESP(task); - up_read(&mm->mmap_sem); } + get_task_comm(tcomm, task); wchan = get_wchan(task); sigemptyset(&sigign); @@ -400,6 +391,14 @@ int proc_pid_stat(struct task_struct *task, char * buffer) } pgid = process_group(task); sid = task->signal->session; + cmin_flt = task->signal->cmin_flt; + cmaj_flt = task->signal->cmaj_flt; + cutime = task->signal->cutime; + cstime = task->signal->cstime; + } + if (task_vx_flags(task, VXF_VIRT_UPTIME, 0)) { + bias_uptime = task->vx_info->cvirt.bias_uptime.tv_sec * NSEC_PER_SEC + + task->vx_info->cvirt.bias_uptime.tv_nsec; } read_unlock(&tasklist_lock); @@ -409,17 +408,24 @@ int proc_pid_stat(struct task_struct *task, char * buffer) nice = task_nice(task); read_lock(&tasklist_lock); - ppid = task->pid ? task->real_parent->pid : 0; + pid = vx_info_map_pid(task->vx_info, task->pid); + ppid = (!(pid > 1)) ? 0 : + vx_info_map_pid(task->vx_info, task->real_parent->pid); + pgid = vx_info_map_pid(task->vx_info, pgid); read_unlock(&tasklist_lock); /* Temporary variable needed for gcc-2.96 */ - start_time = jiffies_64_to_clock_t(task->start_time - bias_jiffies); + /* convert timespec -> nsec*/ + start_time = (unsigned long long)task->start_time.tv_sec * NSEC_PER_SEC + + task->start_time.tv_nsec; + /* convert nsec -> ticks */ + start_time = nsec_to_clock_t(start_time - bias_uptime); res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ %lu %lu %lu %lu %lu %ld %ld %ld %ld %d %ld %llu %lu %ld %lu %lu %lu %lu %lu \ %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu\n", pid, - task->comm, + tcomm, state, ppid, pgid, @@ -428,13 +434,13 @@ int proc_pid_stat(struct task_struct *task, char * buffer) tty_pgrp, task->flags, task->min_flt, - task->cmin_flt, + cmin_flt, task->maj_flt, - task->cmaj_flt, + cmaj_flt, jiffies_to_clock_t(task->utime), jiffies_to_clock_t(task->stime), - jiffies_to_clock_t(task->cutime), - jiffies_to_clock_t(task->cstime), + jiffies_to_clock_t(cutime), + jiffies_to_clock_t(cstime), priority, nice, num_threads, @@ -468,17 +474,13 @@ int proc_pid_stat(struct task_struct *task, char * buffer) return res; } -extern int task_statm(struct mm_struct *, int *, int *, int *, int *); int proc_pid_statm(struct task_struct *task, char *buffer) { int size = 0, resident = 0, shared = 0, text = 0, lib = 0, data = 0; struct mm_struct *mm = get_task_mm(task); if (mm) { - down_read(&mm->mmap_sem); size = task_statm(mm, &shared, &text, &data, &resident); - up_read(&mm->mmap_sem); - mmput(mm); }