public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Bruno Prémont" <bonbons@linux-vserver.org>
To: dwalker@fifo99.com
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Joe Perches <joe@perches.com>
Subject: [PATCH 1/3] printk: Use a flag to indicate console-private loglevel
Date: Tue, 23 Dec 2014 22:22:10 +0100	[thread overview]
Message-ID: <20141223222210.76336cd5@neptune.home> (raw)
In-Reply-To: <20141220224908.GB4466@fifo99.com>

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@linux-vserver.org>
---
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


  parent reply	other threads:[~2014-12-23 21:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-20 22:49 [PATCH] printk: add per console loglevel dwalker
2014-12-21 18:47 ` Bruno Prémont
2014-12-21 19:03   ` Joe Perches
2014-12-22  1:49     ` Lennart Sorensen
2014-12-23 16:11     ` dwalker
2014-12-23 16:20   ` dwalker
2014-12-23 21:13     ` Bruno Prémont
2015-01-04 20:19       ` dwalker
2014-12-23 21:22 ` Bruno Prémont [this message]
2014-12-23 21:27 ` [PATCH 2/3] netconsole: make loglevel configurable per target Bruno Prémont
2014-12-23 21:37 ` [PATCH 3/3] netconsole: New console flag to dump full log buffer Bruno Prémont

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141223222210.76336cd5@neptune.home \
    --to=bonbons@linux-vserver.org \
    --cc=akpm@linux-foundation.org \
    --cc=dwalker@fifo99.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox