* [PATCH -mm] constify sched.c stat_nam strings
@ 2006-06-13 19:55 Andreas Mohr
2006-06-13 21:22 ` Michael Tokarev
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Mohr @ 2006-06-13 19:55 UTC (permalink / raw)
To: Andrew Morton; +Cc: kernel list
Hi all,
Signed-off-by: Andreas Mohr <andi@lisas.de>
diff -urN linux-2.6.17-rc6-mm2.orig/kernel/sched.c linux-2.6.17-rc6-mm2.my/kernel/sched.c
--- linux-2.6.17-rc6-mm2.orig/kernel/sched.c 2006-06-13 19:28:17.000000000 +0200
+++ linux-2.6.17-rc6-mm2.my/kernel/sched.c 2006-06-13 19:32:03.000000000 +0200
@@ -4662,7 +4662,7 @@
task_t *relative;
unsigned state;
unsigned long free = 0;
- static const char *stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
+ static const char * const stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
printk("%-13.13s ", p->comm);
state = p->state ? __ffs(p->state) + 1 : 0;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -mm] constify sched.c stat_nam strings
2006-06-13 19:55 [PATCH -mm] constify sched.c stat_nam strings Andreas Mohr
@ 2006-06-13 21:22 ` Michael Tokarev
2006-06-29 19:43 ` Andreas Mohr
0 siblings, 1 reply; 5+ messages in thread
From: Michael Tokarev @ 2006-06-13 21:22 UTC (permalink / raw)
To: Andreas Mohr; +Cc: Andrew Morton, kernel list
Andreas Mohr wrote:
> Hi all,
>
> Signed-off-by: Andreas Mohr <andi@lisas.de>
>
>
> diff -urN linux-2.6.17-rc6-mm2.orig/kernel/sched.c linux-2.6.17-rc6-mm2.my/kernel/sched.c
> --- linux-2.6.17-rc6-mm2.orig/kernel/sched.c 2006-06-13 19:28:17.000000000 +0200
> +++ linux-2.6.17-rc6-mm2.my/kernel/sched.c 2006-06-13 19:32:03.000000000 +0200
> @@ -4662,7 +4662,7 @@
> task_t *relative;
> unsigned state;
> unsigned long free = 0;
> - static const char *stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
> + static const char * const stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
>
> printk("%-13.13s ", p->comm);
> state = p->state ? __ffs(p->state) + 1 : 0;
How about the following instead:
--- kernel/sched.c.orig 2006-05-31 22:23:53.000000000 +0400
+++ kernel/sched.c 2006-06-14 01:19:17.000000000 +0400
@@ -5287,14 +5287,11 @@ static void show_task(task_t *p)
task_t *relative;
unsigned state;
unsigned long free = 0;
- static const char *stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
+ static const char stat_nam[] = "RSDTtZX";
- printk("%-13.13s ", p->comm);
state = p->state ? __ffs(p->state) + 1 : 0;
- if (state < ARRAY_SIZE(stat_nam))
- printk(stat_nam[state]);
- else
- printk("?");
+ printk("%-13.13s %c", p->comm,
+ state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
#if (BITS_PER_LONG == 32)
printk(" %08lX ", (unsigned long)p);
#else
?
/mjt
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -mm] constify sched.c stat_nam strings
2006-06-13 21:22 ` Michael Tokarev
@ 2006-06-29 19:43 ` Andreas Mohr
2006-06-29 20:17 ` [PATCH -mm] small kernel/sched.c cleanup Andreas Mohr
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Mohr @ 2006-06-29 19:43 UTC (permalink / raw)
To: Michael Tokarev; +Cc: Andrew Morton, kernel list
Hi,
On Wed, Jun 14, 2006 at 01:22:31AM +0400, Michael Tokarev wrote:
> Andreas Mohr wrote:
> > Hi all,
> >
> > Signed-off-by: Andreas Mohr <andi@lisas.de>
> >
> >
> > diff -urN linux-2.6.17-rc6-mm2.orig/kernel/sched.c linux-2.6.17-rc6-mm2.my/kernel/sched.c
> > --- linux-2.6.17-rc6-mm2.orig/kernel/sched.c 2006-06-13 19:28:17.000000000 +0200
> > +++ linux-2.6.17-rc6-mm2.my/kernel/sched.c 2006-06-13 19:32:03.000000000 +0200
> > @@ -4662,7 +4662,7 @@
> > task_t *relative;
> > unsigned state;
> > unsigned long free = 0;
> > - static const char *stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
> > + static const char * const stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
> >
> > printk("%-13.13s ", p->comm);
> > state = p->state ? __ffs(p->state) + 1 : 0;
>
> How about the following instead:
>
> --- kernel/sched.c.orig 2006-05-31 22:23:53.000000000 +0400
> +++ kernel/sched.c 2006-06-14 01:19:17.000000000 +0400
> @@ -5287,14 +5287,11 @@ static void show_task(task_t *p)
> task_t *relative;
> unsigned state;
> unsigned long free = 0;
> - static const char *stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
> + static const char stat_nam[] = "RSDTtZX";
>
> - printk("%-13.13s ", p->comm);
> state = p->state ? __ffs(p->state) + 1 : 0;
> - if (state < ARRAY_SIZE(stat_nam))
> - printk(stat_nam[state]);
> - else
> - printk("?");
> + printk("%-13.13s %c", p->comm,
> + state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
> #if (BITS_PER_LONG == 32)
> printk(" %08lX ", (unsigned long)p);
> #else
>
> ?
Sounds nice, especially as it saves 124 Bytes compared to my version.
I'm planning to merge it into my sched.c cleanup with proper attribution.
Thanks!
Andreas Mohr
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH -mm] small kernel/sched.c cleanup
2006-06-29 19:43 ` Andreas Mohr
@ 2006-06-29 20:17 ` Andreas Mohr
2006-06-29 20:57 ` Ingo Molnar
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Mohr @ 2006-06-29 20:17 UTC (permalink / raw)
To: Andrew Morton; +Cc: Michael Tokarev, kernel list
- constify and optimize stat_nam (thanks to Michael Tokarev!)
- spelling and comment fixes
Run-tested on 2.6.17-mm4.
Signed-off-by: Andreas Mohr <andi@lisas.de>
diff -urN linux-2.6.17-mm4.orig/kernel/sched.c linux-2.6.17-mm4.my/kernel/sched.c
--- linux-2.6.17-mm4.orig/kernel/sched.c 2006-06-29 11:57:17.000000000 +0200
+++ linux-2.6.17-mm4.my/kernel/sched.c 2006-06-29 21:48:22.000000000 +0200
@@ -3418,7 +3418,7 @@
#ifdef CONFIG_PREEMPT
/*
- * this is is the entry point to schedule() from in-kernel preemption
+ * this is the entry point to schedule() from in-kernel preemption
* off of preempt_enable. Kernel preemptions off return from interrupt
* occur there and call schedule directly.
*/
@@ -3461,7 +3461,7 @@
EXPORT_SYMBOL(preempt_schedule);
/*
- * this is is the entry point to schedule() from kernel preemption
+ * this is the entry point to schedule() from kernel preemption
* off of irq context.
* Note, that this is called and return with irqs disabled. This will
* protect us against recursive calling from irq.
@@ -3473,7 +3473,7 @@
struct task_struct *task = current;
int saved_lock_depth;
#endif
- /* Catch callers which need to be fixed*/
+ /* Catch callers which need to be fixed */
BUG_ON(ti->preempt_count || !irqs_disabled());
need_resched:
@@ -4689,7 +4689,7 @@
return list_entry(p->sibling.next,struct task_struct,sibling);
}
-static const char *stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
+static const char stat_nam[] = "RSDTtZX";
static void show_task(struct task_struct *p)
{
@@ -4697,12 +4697,9 @@
unsigned long free = 0;
unsigned state;
- printk("%-13.13s ", p->comm);
state = p->state ? __ffs(p->state) + 1 : 0;
- if (state < ARRAY_SIZE(stat_nam))
- printk(stat_nam[state]);
- else
- printk("?");
+ printk("%-13.13s %c", p->comm,
+ state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
#if (BITS_PER_LONG == 32)
if (state == TASK_RUNNING)
printk(" running ");
@@ -5929,7 +5926,7 @@
cache = vmalloc(max_size);
if (!cache) {
printk("could not vmalloc %d bytes for cache!\n", 2*max_size);
- return 1000000; // return 1 msec on very small boxen
+ return 1000000; /* return 1 msec on very small boxen */
}
while (size <= max_size) {
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -mm] small kernel/sched.c cleanup
2006-06-29 20:17 ` [PATCH -mm] small kernel/sched.c cleanup Andreas Mohr
@ 2006-06-29 20:57 ` Ingo Molnar
0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2006-06-29 20:57 UTC (permalink / raw)
To: Andreas Mohr; +Cc: Andrew Morton, Michael Tokarev, kernel list
* Andreas Mohr <andi@rhlx01.fht-esslingen.de> wrote:
> - constify and optimize stat_nam (thanks to Michael Tokarev!)
> - spelling and comment fixes
>
> Run-tested on 2.6.17-mm4.
>
> Signed-off-by: Andreas Mohr <andi@lisas.de>
looks good to me.
Acked-by: Ingo Molnar <mingo@elte.hu>
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-06-29 21:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-13 19:55 [PATCH -mm] constify sched.c stat_nam strings Andreas Mohr
2006-06-13 21:22 ` Michael Tokarev
2006-06-29 19:43 ` Andreas Mohr
2006-06-29 20:17 ` [PATCH -mm] small kernel/sched.c cleanup Andreas Mohr
2006-06-29 20:57 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox