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 | 30 ++++++++++-------------------- 2 files changed, 11 insertions(+), 20 deletions(-) diff -puN kernel/sched.c~show_task-free-stack-fix kernel/sched.c --- 25/kernel/sched.c~show_task-free-stack-fix 2003-04-02 00:41:09.000000000 -0800 +++ 25-akpm/kernel/sched.c 2003-04-02 00:41:09.000000000 -0800 @@ -2211,17 +2211,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 "); @@ -2233,13 +2232,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 @@ -2257,10 +2250,7 @@ static void show_task(task_t * p) else printk(" (NOTLB)\n"); - { - extern void show_trace_task(task_t *tsk); - show_trace_task(p); - } + show_trace_task(p); } void show_state(void) @@ -2269,12 +2259,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) { 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-04-02 00:41:09.000000000 -0800 +++ 25-akpm/include/linux/sched.h 2003-04-02 00:41:09.000000000 -0800 @@ -151,6 +151,7 @@ extern void show_state(void); extern void show_trace(unsigned long *stack); extern void show_stack(unsigned long *stack); extern void show_regs(struct pt_regs *); +extern void show_trace_task(task_t *tsk); void io_schedule(void); long io_schedule_timeout(long timeout); _