[PATCH 1/3] printk: Use a flag to indicate console-private loglevel

From: Bruno PrÃmont
Date: Tue Dec 23 2014 - 16:22:18 EST


In order to set loglevel for a given console that is not affected by
global loglevel as adjusted via syslog(2), add a flag to the console and
choose the level to match against msg level depending on this flag.

Signed-off-by: Bruno PrÃmont <bonbons@xxxxxxxxxxxxxxxxx>
---
This depends on Daniel's patch "printk: add per console loglevel"
and modifies the way its filtering is applied.


include/linux/console.h | 1 +
kernel/printk/printk.c | 12 ++++++------
2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/linux/console.h b/include/linux/console.h
index 99020d5..f3a8996 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -115,6 +115,7 @@ static inline 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_LOGLEVEL (64) /* Per-console log-level filtering */

struct console {
char name[16];
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 218d94d..8f09f30 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1399,12 +1399,12 @@ static void call_console_drivers(int level, const char *text, size_t len)

trace_console(text, len);

- if (level >= console_loglevel && !ignore_loglevel)
- return;
if (!console_drivers)
return;

for_each_console(con) {
+ if (!ignore_loglevel && level >= (con->flags & CON_LOGLEVEL ? con->loglevel : console_loglevel))
+ continue;
if (exclusive_console && con != exclusive_console)
continue;
if (!(con->flags & CON_ENABLED))
@@ -1414,9 +1414,6 @@ static void call_console_drivers(int level, const char *text, size_t len)
if (!cpu_online(smp_processor_id()) &&
!(con->flags & CON_ANYTIME))
continue;
- if (con->loglevel && !ignore_loglevel &&
- level >= con->loglevel)
- continue;
con->write(con, text, len);
}
}
@@ -2512,7 +2509,10 @@ void register_console(struct console *newcon)
newcon->setup(newcon, console_cmdline[i].options) != 0)
break;

- newcon->loglevel = c->loglevel;
+ if (c->loglevel) {
+ newcon->loglevel = c->loglevel;
+ newcon->flags |= CON_LOGLEVEL;
+ }
newcon->flags |= CON_ENABLED;
newcon->index = c->index;
if (i == selected_console) {
--
2.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/