Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / fs / proc / array.c
index 9c3c781..715194f 100644 (file)
@@ -52,7 +52,6 @@
  *                      :  base.c too.
  */
 
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/time.h>
 #include <linux/highmem.h>
 #include <linux/file.h>
 #include <linux/times.h>
+#include <linux/cpuset.h>
+#include <linux/tracehook.h>
+#include <linux/rcupdate.h>
+#include <linux/delayacct.h>
 #include <linux/vs_context.h>
 #include <linux/vs_network.h>
-#include <linux/vs_cvirt.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -137,7 +139,8 @@ static const char *task_state_array[] = {
        "T (tracing stop)",     /*  8 */
        "Z (zombie)",           /* 16 */
        "X (dead)",             /* 32 */
-       "H (on hold)"           /* 64 */
+       "N (noninteractive)",   /* 64 */
+       "H (on hold)"           /* 128 */
 };
 
 static inline const char * get_task_state(struct task_struct *tsk)
@@ -161,15 +164,21 @@ static inline const char * get_task_state(struct task_struct *tsk)
 
 static inline char * task_state(struct task_struct *p, char *buffer)
 {
+       struct task_struct *tracer;
+       pid_t tracer_pid, pid, ptgid, tgid;
        struct group_info *group_info;
        int g;
-       pid_t pid, ptgid, tppid, tgid;
+       struct fdtable *fdt = NULL;
+
+       rcu_read_lock();
+       tracer = tracehook_tracer_task(p);
+       tracer_pid = tracer == NULL ? 0 : vx_map_pid(tracer->pid);
+       rcu_read_unlock();
 
        read_lock(&tasklist_lock);
        tgid = vx_map_tgid(p->tgid);
        pid = vx_map_pid(p->pid);
-       ptgid = vx_map_pid(p->group_leader->real_parent->tgid);
-       tppid = vx_map_pid(p->parent->pid);
+       ptgid = vx_map_pid(p->group_leader->parent->tgid);
        buffer += sprintf(buffer,
                "State:\t%s\n"
                "SleepAVG:\t%lu%%\n"
@@ -182,15 +191,19 @@ static inline char * task_state(struct task_struct *p, char *buffer)
                get_task_state(p),
                (p->sleep_avg/1024)*100/(1020000000/1024),
                tgid, pid, (pid > 1) ? ptgid : 0,
-               pid_alive(p) && p->ptrace ? tppid : 0,
+               tracer_pid,
                p->uid, p->euid, p->suid, p->fsuid,
                p->gid, p->egid, p->sgid, p->fsgid);
        read_unlock(&tasklist_lock);
        task_lock(p);
+       rcu_read_lock();
+       if (p->files)
+               fdt = files_fdtable(p->files);
        buffer += sprintf(buffer,
                "FDSize:\t%d\n"
                "Groups:\t",
-               p->files ? p->files->max_fds : 0);
+               fdt ? fdt->max_fds : 0);
+       rcu_read_unlock();
 
        group_info = p->group_info;
        get_group_info(group_info);
@@ -248,6 +261,8 @@ static inline char * task_sig(struct task_struct *p, char *buffer)
 {
        sigset_t pending, shpending, blocked, ignored, caught;
        int num_threads = 0;
+       unsigned long qsize = 0;
+       unsigned long qlim = 0;
 
        sigemptyset(&pending);
        sigemptyset(&shpending);
@@ -264,11 +279,14 @@ static inline char * task_sig(struct task_struct *p, char *buffer)
                blocked = p->blocked;
                collect_sigign_sigcatch(p, &ignored, &caught);
                num_threads = atomic_read(&p->signal->count);
+               qsize = atomic_read(&p->user->sigpending);
+               qlim = p->signal->rlim[RLIMIT_SIGPENDING].rlim_cur;
                spin_unlock_irq(&p->sighand->siglock);
        }
        read_unlock(&tasklist_lock);
 
        buffer += sprintf(buffer, "Threads:\t%d\n", num_threads);
+       buffer += sprintf(buffer, "SigQ:\t%lu/%lu\n", qsize, qlim);
 
        /* render them all */
        buffer = render_sigset_t("SigPnd:\t", &pending, buffer);
@@ -310,6 +328,7 @@ int proc_pid_status(struct task_struct *task, char * buffer)
        }
        buffer = task_sig(task, buffer);
        buffer = task_cap(task, buffer);
+       buffer = cpuset_task_status_allowed(task, buffer);
 
        if (task_vx_flags(task, VXF_INFO_HIDE, 0))
                goto skip;
@@ -350,7 +369,7 @@ int proc_pid_status(struct task_struct *task, char * buffer)
        put_nx_info(nxi);
 #endif
 skip:
-#if defined(CONFIG_ARCH_S390)
+#if defined(CONFIG_S390)
        buffer = task_show_regs(task, buffer);
 #endif
        return buffer - orig;
@@ -430,13 +449,17 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
        }
        pid = vx_info_map_pid(task->vx_info, pid_alive(task) ? task->pid : 0);
        ppid = (!(pid > 1)) ? 0 : vx_info_map_tgid(task->vx_info,
-               task->group_leader->real_parent->tgid);
+               task->group_leader->parent->tgid);
        pgid = vx_info_map_pid(task->vx_info, pgid);
 
        read_unlock(&tasklist_lock);
 
-       if (!whole || num_threads<2)
-               wchan = get_wchan(task);
+       if (!whole || num_threads<2) {
+               wchan = 0;
+               if (current->uid == task->uid || current->euid == task->uid ||
+                               capable(CAP_SYS_NICE))
+                       wchan = get_wchan(task);
+       }
        if (!whole) {
                min_flt = task->min_flt;
                maj_flt = task->maj_flt;
@@ -453,7 +476,6 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
        /* 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);
 
@@ -469,8 +491,8 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
        }
 
        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",
+%lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
+%lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu %llu\n",
                pid,
                tcomm,
                state,
@@ -491,10 +513,9 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
                priority,
                nice,
                num_threads,
-               jiffies_to_clock_t(task->it_real_value),
                start_time,
                vsize,
-               mm ? mm->rss : 0, /* you might want to shift this left 3 */
+               mm ? get_mm_rss(mm) : 0,
                rsslim,
                mm ? mm->start_code : 0,
                mm ? mm->end_code : 0,
@@ -515,7 +536,8 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
                task->exit_signal,
                task_cpu(task),
                task->rt_priority,
-               task->policy);
+               task->policy,
+               (unsigned long long)delayacct_blkio_ticks(task));
        if(mm)
                mmput(mm);
        return res;