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. include/linux/sched.h | 1 + kernel/sched.c | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff -puN include/linux/sched.h~show_task-free-stack-fix include/linux/sched.h --- 25/include/linux/sched.h~show_task-free-stack-fix 2003-07-25 20:08:28.000000000 -0700 +++ 25-akpm/include/linux/sched.h 2003-07-25 20:08:30.000000000 -0700 @@ -151,6 +151,7 @@ extern void init_idle(task_t *idle, int 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 diff -puN kernel/sched.c~show_task-free-stack-fix kernel/sched.c --- 25/kernel/sched.c~show_task-free-stack-fix 2003-07-25 20:08:28.000000000 -0700 +++ 25-akpm/kernel/sched.c 2003-07-25 20:08:28.000000000 -0700 @@ -2168,17 +2168,16 @@ static inline struct task_struct *younge 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 "); @@ -2190,13 +2189,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+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 @@ -2223,12 +2216,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) { _