diff -urNp --exclude CVS --exclude BitKeeper --exclude {arch} --exclude .arch-ids x-ref/kernel/printk.c x/kernel/printk.c --- x-ref/kernel/printk.c 2003-10-02 00:09:47.000000000 +0200 +++ x/kernel/printk.c 2003-10-02 15:06:07.000000000 +0200 @@ -26,21 +26,22 @@ #include #include /* For in_interrupt() */ #include +#include #include #if !defined(CONFIG_LOG_BUF_SHIFT) || (CONFIG_LOG_BUF_SHIFT == 0) #if defined(CONFIG_MULTIQUAD) || defined(CONFIG_IA64) -#define LOG_BUF_LEN (65536) +#define __LOG_BUF_LEN (65536) #elif defined(CONFIG_ARCH_S390) -#define LOG_BUF_LEN (131072) +#define __LOG_BUF_LEN (131072) #elif defined(CONFIG_SMP) -#define LOG_BUF_LEN (32768) +#define __LOG_BUF_LEN (32768) #else -#define LOG_BUF_LEN (16384) /* This must be a power of two */ +#define __LOG_BUF_LEN (16384) /* This must be a power of two */ #endif #else /* CONFIG_LOG_BUF_SHIFT */ -#define LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT) +#define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT) #endif #define LOG_BUF_MASK (LOG_BUF_LEN-1) @@ -82,7 +83,9 @@ struct console *console_drivers; */ static spinlock_t logbuf_lock = SPIN_LOCK_UNLOCKED; -static char log_buf[LOG_BUF_LEN]; +static char __log_buf[__LOG_BUF_LEN]; +static char * log_buf = __log_buf; +static int LOG_BUF_LEN = __LOG_BUF_LEN; #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK]) /* @@ -155,6 +158,45 @@ static int __init console_setup(char *st __setup("console=", console_setup); +static int __init log_buf_len_setup(char *str) +{ + unsigned long size = memparse(str, &str); + + if (size > LOG_BUF_LEN) { + unsigned long start, dest_idx, offset; + char * new_log_buf; + + new_log_buf = alloc_bootmem(size); + if (!new_log_buf) { + printk("log_buf_len: allocation failed\n"); + goto out; + } + + spin_lock_irq(&logbuf_lock); + LOG_BUF_LEN = size; + log_buf = new_log_buf; + + offset = start = min(con_start, log_start); + dest_idx = 0; + while (start != log_end) { + log_buf[dest_idx] = __log_buf[start & (__LOG_BUF_LEN - 1)]; + start++; + dest_idx++; + } + log_start -= offset; + con_start -= offset; + log_end -= offset; + spin_unlock_irq(&logbuf_lock); + + printk("log_buf_len: %d\n", LOG_BUF_LEN); + } + out: + + return 1; +} + +__setup("log_buf_len=", log_buf_len_setup); + /* * Commands to do_syslog: *