Skip to contentSkip to conversation

Patch for show_task

PATCH Pete Zaitcev 2 participants 4 messages Apr 4, 2003

lore
Share & tools
lore
#0 lore raw

Andrew, bkbits says you changed the line above to be p->thread_info. Unfortunately, there's another.

kernel/sched.c +1 -1
@@ -2197,7 +2197,7 @@
 		unsigned long * n = (unsigned long *) (p->thread_info+1);
 		while (!*n)
 			n++;
-		free = (unsigned long) n - (unsigned long)(p+1);
+		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)))

-- Pete

#1 lore raw
Quoted 8 lines · Pete Zaitcev

Andrew, bkbits says you changed the line above to be p->thread_info. Unfortunately, there's another.

kernel/sched.c line 2203

Quoted 8 lines
kernel/sched.c +1 -1
@@ -2197,7 +2197,7 @@
 		unsigned long * n = (unsigned long *) (p->thread_info+1);
 		while (!*n)
 			n++;
-		free = (unsigned long) n - (unsigned long)(p+1);
+		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)))

Yup. But the whole thing's dead anyway - we do not clear the kernel stack when it is allocated hence the attempt to work out how much was used cannot work.

That's what

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.5/2.5.66/2.5.66-mm3/broken-out/show_task-free-stack-fix.patch

is about, but it needs finishing off.

#2 lore raw
Quoted 4 lines

Date: Thu, 3 Apr 2003 22:43:46 -0800
From: Andrew Morton <[email protected]>

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.5/2.5.66/2.5.66-mm3/broken-out/show_task-free-stack-fix.patch

I see. What do you say to adding thread_saved_sp() in addition to thread_saved_pc()? E.g. on sparc that would return p->thread_info->ti_ksp, then you can calculate free stack.

-- Pete

#3 lore raw
Quoted 5 lines · Pete Zaitcev

I see. What do you say to adding thread_saved_sp() in addition to thread_saved_pc()? E.g. on sparc that would return p->thread_info->ti_ksp, then you can calculate free stack.

I don't think the current sp value is very interesting really.

What that code is trying to do is to tell you the minimum amount of stack which was *ever* available to that process. Now that is interesting. But it requires that the kernel stack be zeroed out when it is created, and there's no code in there to do that.

It is probably a useful thing to retain though. A new CONFIG_DEBUG_STACK would suit.