提交 d59745ce 编写于 作者: M Matt Mackall 提交者: Linus Torvalds

[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: NMatt Mackall <mpm@selenic.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 cd7619d6
...@@ -380,6 +380,7 @@ rp_sidt: ...@@ -380,6 +380,7 @@ rp_sidt:
ALIGN ALIGN
ignore_int: ignore_int:
cld cld
#ifdef CONFIG_PRINTK
pushl %eax pushl %eax
pushl %ecx pushl %ecx
pushl %edx pushl %edx
...@@ -400,6 +401,7 @@ ignore_int: ...@@ -400,6 +401,7 @@ ignore_int:
popl %edx popl %edx
popl %ecx popl %ecx
popl %eax popl %eax
#endif
iret iret
/* /*
......
...@@ -115,10 +115,19 @@ extern int __kernel_text_address(unsigned long addr); ...@@ -115,10 +115,19 @@ extern int __kernel_text_address(unsigned long addr);
extern int kernel_text_address(unsigned long addr); extern int kernel_text_address(unsigned long addr);
extern int session_of_pgrp(int pgrp); extern int session_of_pgrp(int pgrp);
#ifdef CONFIG_PRINTK
asmlinkage int vprintk(const char *fmt, va_list args) asmlinkage int vprintk(const char *fmt, va_list args)
__attribute__ ((format (printf, 1, 0))); __attribute__ ((format (printf, 1, 0)));
asmlinkage int printk(const char * fmt, ...) asmlinkage int printk(const char * fmt, ...)
__attribute__ ((format (printf, 1, 2))); __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); unsigned long int_sqrt(unsigned long);
......
...@@ -275,6 +275,17 @@ config KALLSYMS_EXTRA_PASS ...@@ -275,6 +275,17 @@ config KALLSYMS_EXTRA_PASS
reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while
you wait for kallsyms to be fixed. 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 config BUG
bool "BUG() support" if EMBEDDED bool "BUG() support" if EMBEDDED
default y default y
......
...@@ -85,10 +85,6 @@ static int console_locked; ...@@ -85,10 +85,6 @@ static int console_locked;
*/ */
static DEFINE_SPINLOCK(logbuf_lock); 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_MASK (log_buf_len-1)
#define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK]) #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK])
...@@ -99,7 +95,6 @@ static int log_buf_len = __LOG_BUF_LEN; ...@@ -99,7 +95,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 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 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 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=) * Array of consoles built from command line options (console=)
...@@ -120,6 +115,13 @@ static int preferred_console = -1; ...@@ -120,6 +115,13 @@ static int preferred_console = -1;
/* Flag: console code may call schedule() */ /* Flag: console code may call schedule() */
static int console_may_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 * Setup a list of consoles. Called from init/main.c
*/ */
...@@ -535,6 +537,7 @@ __setup("time", printk_time_setup); ...@@ -535,6 +537,7 @@ __setup("time", printk_time_setup);
* then changes console_loglevel may break. This is because console_loglevel * then changes console_loglevel may break. This is because console_loglevel
* is inspected when the actual printing occurs. * is inspected when the actual printing occurs.
*/ */
asmlinkage int printk(const char *fmt, ...) asmlinkage int printk(const char *fmt, ...)
{ {
va_list args; va_list args;
...@@ -655,6 +658,18 @@ asmlinkage int vprintk(const char *fmt, va_list args) ...@@ -655,6 +658,18 @@ asmlinkage int vprintk(const char *fmt, va_list args)
EXPORT_SYMBOL(printk); EXPORT_SYMBOL(printk);
EXPORT_SYMBOL(vprintk); 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. * acquire_console_sem - lock the console system for exclusive use.
* *
...@@ -931,7 +946,7 @@ int unregister_console(struct console * console) ...@@ -931,7 +946,7 @@ int unregister_console(struct console * console)
return res; return res;
} }
EXPORT_SYMBOL(unregister_console); EXPORT_SYMBOL(unregister_console);
/** /**
* tty_write_message - write a message to a certain tty, not just the console. * tty_write_message - write a message to a certain tty, not just the console.
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册