Commit 87f095b8 authored by Andrew Morton's avatar Andrew Morton Committed by David S. Miller

[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.
parent a25a6d9a
...@@ -151,6 +151,7 @@ extern void init_idle(task_t *idle, int cpu); ...@@ -151,6 +151,7 @@ extern void init_idle(task_t *idle, int cpu);
extern void show_state(void); extern void show_state(void);
extern void show_regs(struct pt_regs *); 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 * TASK is a pointer to the task whose backtrace we want to see (or NULL for current
......
...@@ -2569,17 +2569,16 @@ static inline struct task_struct *younger_sibling(struct task_struct *p) ...@@ -2569,17 +2569,16 @@ static inline struct task_struct *younger_sibling(struct task_struct *p)
static void show_task(task_t * p) static void show_task(task_t * p)
{ {
unsigned long free = 0;
task_t *relative; task_t *relative;
int state; unsigned state;
static const char * stat_nam[] = { "R", "S", "D", "T", "Z", "W" }; static const char *stat_nam[] = { "R", "S", "D", "T", "Z", "W" };
printk("%-13.13s ", p->comm); printk("%-13.13s ", p->comm);
state = p->state ? __ffs(p->state) + 1 : 0; 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]); printk(stat_nam[state]);
else else
printk(" "); printk("?");
#if (BITS_PER_LONG == 32) #if (BITS_PER_LONG == 32)
if (p == current) if (p == current)
printk(" current "); printk(" current ");
...@@ -2591,13 +2590,7 @@ static void show_task(task_t * p) ...@@ -2591,13 +2590,7 @@ static void show_task(task_t * p)
else else
printk(" %016lx ", thread_saved_pc(p)); printk(" %016lx ", thread_saved_pc(p));
#endif #endif
{ printk("%5d %6d ", p->pid, p->parent->pid);
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);
if ((relative = eldest_child(p))) if ((relative = eldest_child(p)))
printk("%5d ", relative->pid); printk("%5d ", relative->pid);
else else
...@@ -2624,12 +2617,12 @@ void show_state(void) ...@@ -2624,12 +2617,12 @@ void show_state(void)
#if (BITS_PER_LONG == 32) #if (BITS_PER_LONG == 32)
printk("\n" printk("\n"
" free sibling\n"); " sibling\n");
printk(" task PC stack pid father child younger older\n"); printk(" task PC pid father child younger older\n");
#else #else
printk("\n" printk("\n"
" free sibling\n"); " sibling\n");
printk(" task PC stack pid father child younger older\n"); printk(" task PC pid father child younger older\n");
#endif #endif
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
do_each_thread(g, p) { do_each_thread(g, p) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment