diff options
author | Matt Mackall <mpm@selenic.com> | 2005-05-01 11:59:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-05-01 11:59:02 -0400 |
commit | d59745ce3e7aa13856bca16d3bcbb95041775ff6 (patch) | |
tree | 6e495bb6697d86534685bf813c43e210a8d8323a | |
parent | cd7619d6bf36564cf54ff7218ef54e558a741913 (diff) |
[PATCH] clean up kernel messages
Arrange for all kernel printks to be no-ops. Only available if
CONFIG_EMBEDDED.
This patch saves about 375k on my laptop config and nearly 100k on minimal
configs.
Signed-off-by: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/i386/kernel/head.S | 2 | ||||
-rw-r--r-- | include/linux/kernel.h | 9 | ||||
-rw-r--r-- | init/Kconfig | 11 | ||||
-rw-r--r-- | kernel/printk.c | 27 |
4 files changed, 43 insertions, 6 deletions
diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S index d273fd746192..e966fc8c44c4 100644 --- a/arch/i386/kernel/head.S +++ b/arch/i386/kernel/head.S | |||
@@ -380,6 +380,7 @@ rp_sidt: | |||
380 | ALIGN | 380 | ALIGN |
381 | ignore_int: | 381 | ignore_int: |
382 | cld | 382 | cld |
383 | #ifdef CONFIG_PRINTK | ||
383 | pushl %eax | 384 | pushl %eax |
384 | pushl %ecx | 385 | pushl %ecx |
385 | pushl %edx | 386 | pushl %edx |
@@ -400,6 +401,7 @@ ignore_int: | |||
400 | popl %edx | 401 | popl %edx |
401 | popl %ecx | 402 | popl %ecx |
402 | popl %eax | 403 | popl %eax |
404 | #endif | ||
403 | iret | 405 | iret |
404 | 406 | ||
405 | /* | 407 | /* |
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 7c1cba4a5278..e25b97062ce1 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -115,10 +115,19 @@ extern int __kernel_text_address(unsigned long addr); | |||
115 | extern int kernel_text_address(unsigned long addr); | 115 | extern int kernel_text_address(unsigned long addr); |
116 | extern int session_of_pgrp(int pgrp); | 116 | extern int session_of_pgrp(int pgrp); |
117 | 117 | ||
118 | #ifdef CONFIG_PRINTK | ||
118 | asmlinkage int vprintk(const char *fmt, va_list args) | 119 | asmlinkage int vprintk(const char *fmt, va_list args) |
119 | __attribute__ ((format (printf, 1, 0))); | 120 | __attribute__ ((format (printf, 1, 0))); |
120 | asmlinkage int printk(const char * fmt, ...) | 121 | asmlinkage int printk(const char * fmt, ...) |
121 | __attribute__ ((format (printf, 1, 2))); | 122 | __attribute__ ((format (printf, 1, 2))); |
123 | #else | ||
124 | static inline int vprintk(const char *s, va_list args) | ||
125 | __attribute__ ((format (printf, 1, 0))); | ||
126 | static inline int vprintk(const char *s, va_list args) { return 0; } | ||
127 | static inline int printk(const char *s, ...) | ||
128 | __attribute__ ((format (printf, 1, 2))); | ||
129 | static inline int printk(const char *s, ...) { return 0; } | ||
130 | #endif | ||
122 | 131 | ||
123 | unsigned long int_sqrt(unsigned long); | 132 | unsigned long int_sqrt(unsigned long); |
124 | 133 | ||
diff --git a/init/Kconfig b/init/Kconfig index 42dca393b94e..40d286d1d118 100644 --- a/init/Kconfig +++ b/init/Kconfig | |||
@@ -275,6 +275,17 @@ config KALLSYMS_EXTRA_PASS | |||
275 | reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while | 275 | reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while |
276 | you wait for kallsyms to be fixed. | 276 | you wait for kallsyms to be fixed. |
277 | 277 | ||
278 | |||
279 | config PRINTK | ||
280 | default y | ||
281 | bool "Enable support for printk" if EMBEDDED | ||
282 | help | ||
283 | This option enables normal printk support. Removing it | ||
284 | eliminates most of the message strings from the kernel image | ||
285 | and makes the kernel more or less silent. As this makes it | ||
286 | very difficult to diagnose system problems, saying N here is | ||
287 | strongly discouraged. | ||
288 | |||
278 | config BUG | 289 | config BUG |
279 | bool "BUG() support" if EMBEDDED | 290 | bool "BUG() support" if EMBEDDED |
280 | default y | 291 | default y |
diff --git a/kernel/printk.c b/kernel/printk.c index 1498689548d1..290a07ce2c8a 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -85,10 +85,6 @@ static int console_locked; | |||
85 | */ | 85 | */ |
86 | static DEFINE_SPINLOCK(logbuf_lock); | 86 | static DEFINE_SPINLOCK(logbuf_lock); |
87 | 87 | ||
88 | static char __log_buf[__LOG_BUF_LEN]; | ||
89 | static char *log_buf = __log_buf; | ||
90 | static int log_buf_len = __LOG_BUF_LEN; | ||
91 | |||
92 | #define LOG_BUF_MASK (log_buf_len-1) | 88 | #define LOG_BUF_MASK (log_buf_len-1) |
93 | #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK]) | 89 | #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK]) |
94 | 90 | ||
@@ -99,7 +95,6 @@ static int log_buf_len = __LOG_BUF_LEN; | |||
99 | static unsigned long log_start; /* Index into log_buf: next char to be read by syslog() */ | 95 | static unsigned long log_start; /* Index into log_buf: next char to be read by syslog() */ |
100 | static unsigned long con_start; /* Index into log_buf: next char to be sent to consoles */ | 96 | static unsigned long con_start; /* Index into log_buf: next char to be sent to consoles */ |
101 | static unsigned long log_end; /* Index into log_buf: most-recently-written-char + 1 */ | 97 | static unsigned long log_end; /* Index into log_buf: most-recently-written-char + 1 */ |
102 | static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */ | ||
103 | 98 | ||
104 | /* | 99 | /* |
105 | * Array of consoles built from command line options (console=) | 100 | * Array of consoles built from command line options (console=) |
@@ -120,6 +115,13 @@ static int preferred_console = -1; | |||
120 | /* Flag: console code may call schedule() */ | 115 | /* Flag: console code may call schedule() */ |
121 | static int console_may_schedule; | 116 | static int console_may_schedule; |
122 | 117 | ||
118 | #ifdef CONFIG_PRINTK | ||
119 | |||
120 | static char __log_buf[__LOG_BUF_LEN]; | ||
121 | static char *log_buf = __log_buf; | ||
122 | static int log_buf_len = __LOG_BUF_LEN; | ||
123 | static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */ | ||
124 | |||
123 | /* | 125 | /* |
124 | * Setup a list of consoles. Called from init/main.c | 126 | * Setup a list of consoles. Called from init/main.c |
125 | */ | 127 | */ |
@@ -535,6 +537,7 @@ __setup("time", printk_time_setup); | |||
535 | * then changes console_loglevel may break. This is because console_loglevel | 537 | * then changes console_loglevel may break. This is because console_loglevel |
536 | * is inspected when the actual printing occurs. | 538 | * is inspected when the actual printing occurs. |
537 | */ | 539 | */ |
540 | |||
538 | asmlinkage int printk(const char *fmt, ...) | 541 | asmlinkage int printk(const char *fmt, ...) |
539 | { | 542 | { |
540 | va_list args; | 543 | va_list args; |
@@ -655,6 +658,18 @@ out: | |||
655 | EXPORT_SYMBOL(printk); | 658 | EXPORT_SYMBOL(printk); |
656 | EXPORT_SYMBOL(vprintk); | 659 | EXPORT_SYMBOL(vprintk); |
657 | 660 | ||
661 | #else | ||
662 | |||
663 | asmlinkage long sys_syslog(int type, char __user * buf, int len) | ||
664 | { | ||
665 | return 0; | ||
666 | } | ||
667 | |||
668 | int do_syslog(int type, char __user * buf, int len) { return 0; } | ||
669 | static void call_console_drivers(unsigned long start, unsigned long end) {} | ||
670 | |||
671 | #endif | ||
672 | |||
658 | /** | 673 | /** |
659 | * acquire_console_sem - lock the console system for exclusive use. | 674 | * acquire_console_sem - lock the console system for exclusive use. |
660 | * | 675 | * |
@@ -931,7 +946,7 @@ int unregister_console(struct console * console) | |||
931 | return res; | 946 | return res; |
932 | } | 947 | } |
933 | EXPORT_SYMBOL(unregister_console); | 948 | EXPORT_SYMBOL(unregister_console); |
934 | 949 | ||
935 | /** | 950 | /** |
936 | * tty_write_message - write a message to a certain tty, not just the console. | 951 | * tty_write_message - write a message to a certain tty, not just the console. |
937 | * | 952 | * |