]> git.hungrycats.org Git - linux/commitdiff
[PATCH] show_task() fix and cleanup
authorAndrew Morton <akpm@osdl.org>
Thu, 19 Feb 2004 00:39:53 +0000 (16:39 -0800)
committerDavid S. Miller <davem@nuts.davemloft.net>
Thu, 19 Feb 2004 00:39:53 +0000 (16:39 -0800)
show_task() is preinting negative numbers for free stack due to arithmetic
against the wrong pointer.

Fix that up, and clean up a few related things.

show_task still has bogus code which atempts to work out how much stack the
task has ever used - it cannot work because we don't actually zero out the
stack pages when allocating them.  We should fix that, or take it out.

include/linux/sched.h
kernel/sched.c

index 3f2e5d0714649e51aa6fb8c4ff825af376521d65..40170aa312a1130e95628be32cea76bf83eea86a 100644 (file)
@@ -151,6 +151,7 @@ extern void init_idle(task_t *idle, int cpu);
 
 extern void show_state(void);
 extern void show_regs(struct pt_regs *);
+extern void show_trace_task(task_t *tsk);
 
 /*
  * TASK is a pointer to the task whose backtrace we want to see (or NULL for current
index d4c17922122b04eea2b5611a1e5b4d94c0b7441c..4d921e431216e393069291ccf4c78a2aa02448c7 100644 (file)
@@ -2569,17 +2569,16 @@ static inline struct task_struct *younger_sibling(struct task_struct *p)
 
 static void show_task(task_t * p)
 {
-       unsigned long free = 0;
        task_t *relative;
-       int state;
-       static const char * stat_nam[] = { "R", "S", "D", "T", "Z", "W" };
+       unsigned state;
+       static const char *stat_nam[] = { "R", "S", "D", "T", "Z", "W" };
 
        printk("%-13.13s ", p->comm);
        state = p->state ? __ffs(p->state) + 1 : 0;
-       if (((unsigned) state) < sizeof(stat_nam)/sizeof(char *))
+       if (state < ARRAY_SIZE(stat_nam))
                printk(stat_nam[state]);
        else
-               printk(" ");
+               printk("?");
 #if (BITS_PER_LONG == 32)
        if (p == current)
                printk(" current  ");
@@ -2591,13 +2590,7 @@ static void show_task(task_t * p)
        else
                printk(" %016lx ", thread_saved_pc(p));
 #endif
-       {
-               unsigned long * n = (unsigned long *) (p->thread_info+1);
-               while (!*n)
-                       n++;
-               free = (unsigned long) n - (unsigned long)(p->thread_info+1);
-       }
-       printk("%5lu %5d %6d ", free, p->pid, p->parent->pid);
+       printk("%5d %6d ", p->pid, p->parent->pid);
        if ((relative = eldest_child(p)))
                printk("%5d ", relative->pid);
        else
@@ -2624,12 +2617,12 @@ void show_state(void)
 
 #if (BITS_PER_LONG == 32)
        printk("\n"
-              "                         free                        sibling\n");
-       printk("  task             PC    stack   pid father child younger older\n");
+              "                                               sibling\n");
+       printk("  task             PC      pid father child younger older\n");
 #else
        printk("\n"
-              "                                 free                        sibling\n");
-       printk("  task                 PC        stack   pid father child younger older\n");
+              "                                                       sibling\n");
+       printk("  task                 PC          pid father child younger older\n");
 #endif
        read_lock(&tasklist_lock);
        do_each_thread(g, p) {