clean up kernel messages
PATCH 1/1 clean up kernel messages
This patch tidies up those annoying kernel messages. A typical kernel boot now looks like this:
Loading Linux... Uncompressing kernel...
#
See? Much nicer. This patch saves about 375k on my laptop config and nearly 100k on minimal configs.
include/linux/kernel.h +9 -0
@@ -115,10 +115,19 @@ extern int __kernel_text_address(unsigneextern int kernel_text_address (unsigned long addr);extern int session_of_pgrp (int pgrp); +#ifdef CONFIG_PRINTK asmlinkage int vprintk(const char *fmt, va_list args) __attribute__ ((format (printf,1 ,0 ))); asmlinkage int printk(const char * fmt, ...) __attribute__ ((format (printf,1 ,2 ))); +#else +static inline int vprintk (const char *s,va_list args) + __attribute__ ((format (printf,1 ,0 ))); +static inline int vprintk (const char *s,va_list args) {return 0 ; } +static inline int printk (const char *s, ...) + __attribute__ ((format (printf,1 ,2 ))); +static inline int printk (const char *s, ...) {return 0 ; } +#endif unsigned long int_sqrt (unsigned long );
init/Kconfig +11 -0
@@ -275,6 +275,17 @@ config KALLSYMS_EXTRA_PASS reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while you wait for kallsyms to be fixed. + +config PRINTK + default y + bool "Enable support for printk" if EMBEDDED + help + This option enables normal printk support. Removing it + eliminates most of the message strings from the kernel image + and makes the kernel more or less silent. As this makes it + very difficult to diagnose system problems, saying N here is + strongly discouraged. + config BUG bool "BUG() support" if EMBEDDED default y
kernel/printk.c +21 -6
@@ -80,10 +80,6 @@ static int console_locked;*/ static DEFINE_SPINLOCK (logbuf_lock); -static char __log_buf[__LOG_BUF_LEN]; -static char *log_buf = __log_buf; -static int log_buf_len = __LOG_BUF_LEN; -#define LOG_BUF_MASK (log_buf_len-1)#define LOG_BUF (idx) (log_buf[(idx) & LOG_BUF_MASK])
@@ -94,7 +90,6 @@ static int log_buf_len = __LOG_BUF_LEN;static unsigned long log_start;/* Index into log_buf: next char to be read by syslog() */ static unsigned long con_start;/* Index into log_buf: next char to be sent to consoles */ static unsigned long log_end;/* Index into log_buf: most-recently-written-char + 1 */ -static unsigned long logged_chars;/* Number of chars produced since last read+clear operation */ /* * Array of consoles built from command line options (console=)
@@ -115,6 +110,13 @@ static int preferred_console = -1;/* Flag: console code may call schedule() */ static int console_may_schedule; +#ifdef CONFIG_PRINTK + +static char __log_buf[__LOG_BUF_LEN]; +static char *log_buf = __log_buf; +static int log_buf_len = __LOG_BUF_LEN; +static unsigned long logged_chars;/* Number of chars produced since last read+clear operation */ +/* * Setup a list of consoles. Called from init/main.c */
@@ -530,6 +532,7 @@ __setup("time", printk_time_setup);* then changes console_loglevel may break. This is because console_loglevel * is inspected when the actual printing occurs. */ + asmlinkage int printk(const char *fmt, ...) {va_list args;
@@ -650,6 +653,18 @@ out:EXPORT_SYMBOL (printk);EXPORT_SYMBOL (vprintk); +#else + +asmlinkage long sys_syslog (int type,char __user * buf,int len) +{ +return 0 ; +} + +int do_syslog (int type,char __user * buf,int len) {return 0 ; } +static void call_console_drivers (unsigned long start,unsigned long end) {} + +#endif +/** * acquire_console_sem - lock the console system for exclusive use. *
@@ -923,7 +938,7 @@ int unregister_console(struct console *return res; }EXPORT_SYMBOL (unregister_console); - +/** * tty_write_message - write a message to a certain tty, not just the console. *
arch/i386/kernel/head.S +2 -0
@@ -380,6 +380,7 @@ rp_sidt: ALIGN ignore_int: cld +#ifdef CONFIG_PRINTK pushl %eax pushl %ecx pushl %edx
@@ -400,6 +401,7 @@ ignore_int: popl %edx popl %ecx popl %eax +#endif iret /*
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 10 lines · Matt Mackall
This patch tidies up those annoying kernel messages. A typical kernel
boot now looks like this:Loading Linux... Uncompressing kernel...
#See? Much nicer. This patch saves about 375k on my laptop config and nearly 100k on minimal configs.
heh. Please take a look at
http://www.uwsg.iu.edu/hypermail/linux/kernel/0004.2/0709.html, see if Graham did anything which you missed.
One problem was that
printk("foo");will still cause the string "foo\0" to appear in the kernel image. That was fixed in later gcc's, but it would be interesting to know which compilers get it right.
Quoted 9 lines
Index:
af/include/linux/kernel.h
===================================================================
---af.orig/include/linux/kernel.h2005-04-01 00:32:18.000000000 -0800
+++af/include/linux/kernel.h2005-04-01 10:38:43.000000000 -0800
@@ -115,10 +115,19 @@ extern int __kernel_text_address(unsigne
extern intkernel_text_address(unsigned long addr); extern intsession_of_pgrp(int pgrp);
Quoted 13 lines
+#ifdef
CONFIG_PRINTK
asmlinkage intvprintk(const char *fmt, va_list args)
__attribute__((format (printf, 1, 0)));
asmlinkage intprintk(const char * fmt, ...)
__attribute__((format (printf, 1, 2)));
+#else
+static inline intvprintk(const char *s, va_list args)
+__attribute__((format (printf, 1, 0)));
+static inline intvprintk(const char *s, va_list args){ return 0; } +static inline intprintk(const char *s, ...)
+__attribute__((format (printf, 1, 2)));
+static inline intprintk(const char *s, ...){ return 0; } +#endif
Actually printk() is supposed to return the number of chars which it printed. So if someone is doing:
while (len < 40)
len += printk("something");you've gone and made them lock up.
But I think the number of places where we examine the printk return value is near zero.
Quoted 8 lines · Andrew Morton
Quoted 7 lines · Matt Mackall
This patch tidies up those annoying kernel messages. A typical kernel
boot now looks like this:Loading Linux... Uncompressing kernel...
#
Quoted 7 lines
Quoted 3 lines
See? Much nicer. This patch saves about 375k on my laptop config and nearly 100k on minimal configs.
heh. Please take a look at
http://www.uwsg.iu.edu/hypermail/linux/kernel/0004.2/0709.html, see if Graham did anything which you missed.
He's got a bunch of stuff that's not strictly related in there and stuff I've already dealt with (vprintk and the like) and stuff that's still forthcoming (panic tweaks, etc.). I also leave in all the APIs like dmesg, they just no longer do anything.
Quoted 7 lines
One problem was that
printk("foo");will still cause the string "foo\0" to appear in the kernel image. That was fixed in later gcc's, but it would be interesting to know which compilers get it right.
Haven't encountered this. I think it should be fine for any compiler that can handle 2.6. This has been in -tiny for nearly a year and a half and no one's complained.
Quoted 5 lines
Quoted 1 line
+static inline int
printk(const char *s, ...){ return 0; }Actually
printk()is supposed to return the number of chars which it printed. So if someone is doing:
Quoted 7 lines
while (len < 40) len += printk("something");you've gone and made them lock up.
But I think the number of places where we examine the printk return value is near zero.
Well in some sense 0 is the proper return but I suppose this could be made to return 1. Small enough not break anything, big enough so that things like the above get unstuck.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 13 lines · Matt Mackall
Quoted 12 lines · Andrew Morton
Quoted 10 lines · Matt Mackall
This patch tidies up those annoying kernel messages. A typical kernel
boot now looks like this:Loading Linux... Uncompressing kernel...
#See? Much nicer. This patch saves about 375k on my laptop config and nearly 100k on minimal configs.
Quoted 8 lines
Quoted 3 lines
heh. Please take a look at
http://www.uwsg.iu.edu/hypermail/linux/kernel/0004.2/0709.html, see if Graham did anything which you missed.He's got a bunch of stuff that's not strictly related in there and stuff I've already dealt with (vprintk and the like) and stuff that's still forthcoming (panic tweaks, etc.). I also leave in all the APIs like dmesg, they just no longer do anything.
Looking at your other patches, I'm assuming that this is just another April 1st type of patch. Is it?
-- Steve
Quoted 18 lines · Steven Rostedt
Quoted 17 lines · Matt Mackall
Quoted 15 lines · Andrew Morton
Quoted 10 lines · Matt Mackall
This patch tidies up those annoying kernel messages. A typical kernel
boot now looks like this:Loading Linux... Uncompressing kernel...
#See? Much nicer. This patch saves about 375k on my laptop config and nearly 100k on minimal configs.
heh. Please take a look at
http://www.uwsg.iu.edu/hypermail/linux/kernel/0004.2/0709.html, see if Graham did anything which you missed.
Quoted 7 lines
Quoted 4 lines
He's got a bunch of stuff that's not strictly related in there and stuff I've already dealt with (vprintk and the like) and stuff that's still forthcoming (panic tweaks, etc.). I also leave in all the APIs like dmesg, they just no longer do anything.
Looking at your other patches, I'm assuming that this is just another April 1st type of patch. Is it?
Arg! I'm too tired. I took another look at your other patches and they look more legit now. On first glance, I thought you were just bluntly removing BUGs and error messages to quiet things down. But after taking another look, I see that they are more than that. I wouldn't of thought about that on any other day.
Sorry,
-- Steve
Quoted 33 lines · Steven Rostedt
Quoted 18 lines · Steven Rostedt
Quoted 17 lines · Matt Mackall
Quoted 15 lines · Andrew Morton
Quoted 10 lines · Matt Mackall
This patch tidies up those annoying kernel messages. A typical kernel
boot now looks like this:Loading Linux... Uncompressing kernel...
#See? Much nicer. This patch saves about 375k on my laptop config and nearly 100k on minimal configs.
heh. Please take a look at
http://www.uwsg.iu.edu/hypermail/linux/kernel/0004.2/0709.html, see if Graham did anything which you missed.Quoted 7 lines
Quoted 4 lines
He's got a bunch of stuff that's not strictly related in there and stuff I've already dealt with (vprintk and the like) and stuff that's still forthcoming (panic tweaks, etc.). I also leave in all the APIs like dmesg, they just no longer do anything.
Looking at your other patches, I'm assuming that this is just another April 1st type of patch. Is it?
Arg! I'm too tired. I took another look at your other patches and they look more legit now. On first glance, I thought you were just bluntly removing BUGs and error messages to quiet things down. But after taking another look, I see that they are more than that. I wouldn't of thought about that on any other day.
Quoted 4 lines
Sorry,
-- Steve
Methinks he still is kidding. We have "quiet" as a parameter now to quiet things down on a boot. Now if he would just get rid of the annoying...
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Loading Linux... Uncompressing kernel...
He'd have something.
Cheers,
Dick Johnson
Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.
Quoted 12 lines · Richard B. Johnson
Quoted 12 lines
Quoted 2 lines
Looking at your other patches, I'm assuming that this is just another April 1st type of patch. Is it?
Arg! I'm too tired. I took another look at your other patches and they look more legit now. On first glance, I thought you were just bluntly removing BUGs and error messages to quiet things down. But after taking another look, I see that they are more than that. I wouldn't of thought about that on any other day.
Sorry,
Quoted 7 lines
Quoted 1 line
-- Steve
Methinks he still is kidding. We have "quiet" as a parameter now to quiet things down on a boot. Now if he would just get rid of the annoying...
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Loading Linux... Uncompressing kernel...
He'd have something.
I suppose this is intended for embedded builds for devices with no means whatsoever to send kernel log anywhere humanly visible. --
vda
Quoted 18 lines · Steven Rostedt
Quoted 17 lines · Matt Mackall
Quoted 15 lines · Andrew Morton
Quoted 10 lines · Matt Mackall
This patch tidies up those annoying kernel messages. A typical kernel
boot now looks like this:Loading Linux... Uncompressing kernel...
#See? Much nicer. This patch saves about 375k on my laptop config and nearly 100k on minimal configs.
heh. Please take a look at
http://www.uwsg.iu.edu/hypermail/linux/kernel/0004.2/0709.html, see if Graham did anything which you missed.
Quoted 7 lines
Quoted 4 lines
He's got a bunch of stuff that's not strictly related in there and stuff I've already dealt with (vprintk and the like) and stuff that's still forthcoming (panic tweaks, etc.). I also leave in all the APIs like dmesg, they just no longer do anything.
Looking at your other patches, I'm assuming that this is just another April 1st type of patch. Is it?
Both this and the previous one are in active use by various embedded systems folks and I hope to get them integrated into mainline. Comments welcome.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
On Fri, 2005-04-01 12:08:51 -0800, Matt Mackall <[email protected]> wrote in message <[email protected]>:
Quoted 8 lines
This patch tidies up those annoying kernel messages. A typical kernel boot now looks like this:
Loading Linux... Uncompressing kernel...
#See? Much nicer. This patch saves about 375k on my laptop config and nearly 100k on minimal configs.
Please also notice these space-savings in the Kconfig help text.
MfG, JBG
Signature · 4 lines
Jan-Benedict Glaw [email protected] . +49-172-7608481 _ O _ "Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));