From: Christophe Guerard Date: Tue, 6 Mar 2012 15:20:11 +0000 (+0100) Subject: [LOG] Add log level bypass support for logcat console X-Git-Tag: 2.1b_release~1200 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24cede26d88db875be71081a44ff6a31685a918d;p=kernel%2Fkernel-mfld-blackbay.git [LOG] Add log level bypass support for logcat console BZ: 25924 To collect all the kernel logs and ignore the log level set in the kernel command line for one specific console, a new console setting is created named CON_IGNORELEVEL meaning that all the logs whatever its level is displayed on this console. With this granularity, the consoles impacting power consumption do not set CON_IGNORELEVEL and the one used to save kernel logs into the file system (named logk) could set CON_IGNORELEVEL Change-Id: If9b7a0918ddd189ffabdf87d7ad5b8a0f5281d86 Signed-off-by: Christophe Guerard Reviewed-on: http://android.intel.com:8080/37736 Reviewed-by: Rocher, JeremyX Reviewed-by: Hogander, Jouni Reviewed-by: Continente, Christophe Reviewed-by: Tardy, Pierre Reviewed-by: buildbot Tested-by: buildbot --- diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c index 6f9b00a..ee8e7a2 100755 --- a/drivers/staging/android/logger.c +++ b/drivers/staging/android/logger.c @@ -758,10 +758,14 @@ logger_console_write(struct console *console, const char *s, unsigned int count) schedule_work(&write_console_wq); } +/* logger console uses CON_IGNORELEVEL that provides a way to ignore + * the log level set in the kernel command line + */ + static struct console logger_console = { .name = "logk", .write = logger_console_write, - .flags = CON_PRINTBUFFER, + .flags = CON_PRINTBUFFER | CON_IGNORELEVEL, .index = -1, }; diff --git a/include/linux/console.h b/include/linux/console.h index 7453cfd..ca9cd60 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -110,6 +110,7 @@ int con_debug_leave(void); #define CON_BOOT (8) #define CON_ANYTIME (16) /* Safe to call when cpu is offline */ #define CON_BRL (32) /* Used for a braille device */ +#define CON_IGNORELEVEL (64) /* Used to ignore log level for a console */ struct console { char name[16]; diff --git a/kernel/printk.c b/kernel/printk.c index dc5aefe..d5a692b 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -553,23 +553,6 @@ void kdb_syslog_data(char *syslog_data[4]) } #endif /* CONFIG_KGDB_KDB */ -/* - * Call the console drivers on a range of log_buf - */ -static void __call_console_drivers(unsigned start, unsigned end) -{ - struct console *con; - - for_each_console(con) { - if (exclusive_console && con != exclusive_console) - continue; - if ((con->flags & CON_ENABLED) && con->write && - (cpu_online(smp_processor_id()) || - (con->flags & CON_ANYTIME))) - con->write(con, &LOG_BUF(start), end - start); - } -} - static int __read_mostly ignore_loglevel; static int __init ignore_loglevel_setup(char *str) @@ -581,6 +564,24 @@ static int __init ignore_loglevel_setup(char *str) } early_param("ignore_loglevel", ignore_loglevel_setup); +/* + * Call the console drivers on a range of log_buf + */ +static void __call_console_drivers(unsigned start, unsigned end, int loglevel) +{ + struct console *con; + + for_each_console(con) { + if (exclusive_console && con != exclusive_console) + continue; + if (((con->flags & CON_IGNORELEVEL) || ignore_loglevel || + loglevel < console_loglevel) && + (con->flags & CON_ENABLED) && con->write && + (cpu_online(smp_processor_id()) || + (con->flags & CON_ANYTIME))) + con->write(con, &LOG_BUF(start), end - start); + } +} /* * Write out chars from start to end - 1 inclusive @@ -588,15 +589,15 @@ early_param("ignore_loglevel", ignore_loglevel_setup); static void _call_console_drivers(unsigned start, unsigned end, int msg_log_level) { - if ((msg_log_level < console_loglevel || ignore_loglevel) && - console_drivers && start != end) { + if (console_drivers && start != end) { if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) { /* wrapped write */ __call_console_drivers(start & LOG_BUF_MASK, - log_buf_len); - __call_console_drivers(0, end & LOG_BUF_MASK); + log_buf_len, msg_log_level); + __call_console_drivers(0, end & LOG_BUF_MASK, + msg_log_level); } else { - __call_console_drivers(start, end); + __call_console_drivers(start, end, msg_log_level); } } }