mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2.6.19-rc6] sched: cleanup output of show_state/show_task
@ 2006-11-25  4:48 Chris Caputo
  2006-11-27 22:38 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Caputo @ 2006-11-25  4:48 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, trivial

From: Chris Caputo <ccaputo@alt.net>
[PATCH 2.6.19-rc6] sched: cleanup output of show_state/show_task

This patch cleans up the output of show_state/task() (aka magic-sysrq-t) 
so that free stack space is printed as appropriate based on 
CONFIG_DEBUG_STACK_USAGE.

Also, without this patch the header is not aligned with the data and is 
thus confusing.  Free stack is labeled as pid, pid is labeled as father, 
and so on.

Signed-off-by: Chris Caputo <ccaputo@alt.net>
---

diff -uprN a/kernel/sched.c b/kernel/sched.c
--- a/kernel/sched.c	2006-11-25 04:11:12.000000000 +0000
+++ b/kernel/sched.c	2006-11-25 04:13:07.000000000 +0000
@@ -4757,7 +4757,6 @@ static const char stat_nam[] = "RSDTtZX"
 static void show_task(struct task_struct *p)
 {
 	struct task_struct *relative;
-	unsigned long free = 0;
 	unsigned state;
 
 	state = p->state ? __ffs(p->state) + 1 : 0;
@@ -4779,10 +4778,10 @@ static void show_task(struct task_struct
 		unsigned long *n = end_of_stack(p);
 		while (!*n)
 			n++;
-		free = (unsigned long)n - (unsigned long)end_of_stack(p);
+		printk("%5lu ", (unsigned long)n - (unsigned long)end_of_stack(p));
 	}
 #endif
-	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
@@ -4808,14 +4807,18 @@ void show_state(void)
 {
 	struct task_struct *g, *p;
 
-#if (BITS_PER_LONG == 32)
+#ifdef CONFIG_DEBUG_STACK_USAGE
 	printk("\n"
-	       "                                               sibling\n");
-	printk("  task             PC      pid father child younger older\n");
+	       "                %s free                        sibling\n",
+	       BITS_PER_LONG == 32 ? "        " : "                ");
+	printk("  task          %s stack   pid father child younger older\n",
+	       BITS_PER_LONG == 32 ? "   PC   " : "       PC       ");
 #else
 	printk("\n"
-	       "                                                       sibling\n");
-	printk("  task                 PC          pid father child younger older\n");
+	       "                %s                       sibling\n",
+	       BITS_PER_LONG == 32 ? "        " : "                ");
+	printk("  task          %s   pid father child younger older\n",
+	       BITS_PER_LONG == 32 ? "   PC   " : "       PC       ");
 #endif
 	read_lock(&tasklist_lock);
 	do_each_thread(g, p) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2.6.19-rc6] sched: cleanup output of show_state/show_task
  2006-11-25  4:48 [PATCH 2.6.19-rc6] sched: cleanup output of show_state/show_task Chris Caputo
@ 2006-11-27 22:38 ` Andrew Morton
  2006-11-27 23:32   ` Chris Caputo
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2006-11-27 22:38 UTC (permalink / raw)
  To: Chris Caputo; +Cc: Ingo Molnar, linux-kernel, trivial

On Sat, 25 Nov 2006 04:48:15 +0000 (GMT)
Chris Caputo <ccaputo@alt.net> wrote:

> 
> This patch cleans up the output of show_state/task() (aka magic-sysrq-t) 
> so that free stack space is printed as appropriate based on 
> CONFIG_DEBUG_STACK_USAGE.
> 
> Also, without this patch the header is not aligned with the data and is 
> thus confusing.  Free stack is labeled as pid, pid is labeled as father, 
> and so on.
> 
> Signed-off-by: Chris Caputo <ccaputo@alt.net>
> ---
> 
> diff -uprN a/kernel/sched.c b/kernel/sched.c
> --- a/kernel/sched.c	2006-11-25 04:11:12.000000000 +0000
> +++ b/kernel/sched.c	2006-11-25 04:13:07.000000000 +0000
> @@ -4757,7 +4757,6 @@ static const char stat_nam[] = "RSDTtZX"
>  static void show_task(struct task_struct *p)
>  {
>  	struct task_struct *relative;
> -	unsigned long free = 0;
>  	unsigned state;
>  
>  	state = p->state ? __ffs(p->state) + 1 : 0;
> @@ -4779,10 +4778,10 @@ static void show_task(struct task_struct
>  		unsigned long *n = end_of_stack(p);
>  		while (!*n)
>  			n++;
> -		free = (unsigned long)n - (unsigned long)end_of_stack(p);
> +		printk("%5lu ", (unsigned long)n - (unsigned long)end_of_stack(p));
>  	}
>  #endif
> -	printk("%5lu %5d %6d ", free, p->pid, p->parent->pid);
> +	printk("%5d %6d ", p->pid, p->parent->pid);

This will cause the output format to be dependent upon the setting of
CONFIG_DEBUG_STACK_USAGE.  So any code which attempts to parse the output
of this function will somehow need to work out whether or not the `free'
field is present.

Which is why we still print out a zero if CONFIG_DEBUG_STACK_USAGE=n.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2.6.19-rc6] sched: cleanup output of show_state/show_task
  2006-11-27 22:38 ` Andrew Morton
@ 2006-11-27 23:32   ` Chris Caputo
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Caputo @ 2006-11-27 23:32 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, trivial

On Mon, 27 Nov 2006, Andrew Morton wrote:
> On Sat, 25 Nov 2006 04:48:15 +0000 (GMT)
> Chris Caputo <ccaputo@alt.net> wrote:
> > This patch cleans up the output of show_state/task() (aka magic-sysrq-t) 
> > so that free stack space is printed as appropriate based on 
> > CONFIG_DEBUG_STACK_USAGE.
> > 
> > Also, without this patch the header is not aligned with the data and is 
> > thus confusing.  Free stack is labeled as pid, pid is labeled as father, 
> > and so on.
> > 
> > Signed-off-by: Chris Caputo <ccaputo@alt.net>
> > ---
> > 
> > diff -uprN a/kernel/sched.c b/kernel/sched.c
> > --- a/kernel/sched.c	2006-11-25 04:11:12.000000000 +0000
> > +++ b/kernel/sched.c	2006-11-25 04:13:07.000000000 +0000
> > @@ -4757,7 +4757,6 @@ static const char stat_nam[] = "RSDTtZX"
> >  static void show_task(struct task_struct *p)
> >  {
> >  	struct task_struct *relative;
> > -	unsigned long free = 0;
> >  	unsigned state;
> >  
> >  	state = p->state ? __ffs(p->state) + 1 : 0;
> > @@ -4779,10 +4778,10 @@ static void show_task(struct task_struct
> >  		unsigned long *n = end_of_stack(p);
> >  		while (!*n)
> >  			n++;
> > -		free = (unsigned long)n - (unsigned long)end_of_stack(p);
> > +		printk("%5lu ", (unsigned long)n - (unsigned long)end_of_stack(p));
> >  	}
> >  #endif
> > -	printk("%5lu %5d %6d ", free, p->pid, p->parent->pid);
> > +	printk("%5d %6d ", p->pid, p->parent->pid);
> 
> This will cause the output format to be dependent upon the setting of
> CONFIG_DEBUG_STACK_USAGE.  So any code which attempts to parse the output
> of this function will somehow need to work out whether or not the `free'
> field is present.
> 
> Which is why we still print out a zero if CONFIG_DEBUG_STACK_USAGE=n.

Ahh!

Should we make it so the header printed by show_state is aligned properly 
with the data?  If yes, please consider the below patch.

Chris

---
From: Chris Caputo <ccaputo@alt.net>
[PATCH 2.6.19-rc6] sched: correct output of show_state

At present show_state prints a header the does not match the output of 
show_task, as follows:

-
                                               sibling
  task             PC      pid father child younger older
init          S 00000000     0     1      0     2               (NOTLB)
-

This patch corrects the output of show_state so that the header is 
aligned with the data, ala:

-
                         free                        sibling
  task             PC    stack   pid father child younger older
init          S 00000000     0     1      0     2               (NOTLB)
-

Signed-off-by: Chris Caputo <ccaputo@alt.net>
---

--- a/kernel/sched.c	2006-11-27 08:40:56.000000000 +0000
+++ b/kernel/sched.c	2006-11-27 23:23:49.000000000 +0000
@@ -4810,12 +4810,12 @@ void show_state(void)
 
 #if (BITS_PER_LONG == 32)
 	printk("\n"
-	       "                                               sibling\n");
-	printk("  task             PC      pid father child younger older\n");
+	       "                         free                        sibling\n");
+	printk("  task             PC    stack   pid father child younger older\n");
 #else
 	printk("\n"
-	       "                                                       sibling\n");
-	printk("  task                 PC          pid father child younger older\n");
+	       "                                 free                        sibling\n");
+	printk("  task                 PC        stack   pid father child younger older\n");
 #endif
 	read_lock(&tasklist_lock);
 	do_each_thread(g, p) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-27 23:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-25  4:48 [PATCH 2.6.19-rc6] sched: cleanup output of show_state/show_task Chris Caputo
2006-11-27 22:38 ` Andrew Morton
2006-11-27 23:32   ` Chris Caputo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®