From 87f095b8e4710137fd086ed28c3b2b086dd4437e Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 18 Feb 2004 16:39:53 -0800 Subject: [PATCH] [PATCH] show_task() fix and cleanup 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 | 1 + kernel/sched.c | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 3f2e5d0714649..40170aa312a11 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -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 diff --git a/kernel/sched.c b/kernel/sched.c index d4c17922122b0..4d921e431216e 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -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) { -- 2.53.0