From: Petr Mladek <pmladek@suse.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
linux-kernel@vger.kernel.org, Petr Mladek <pmladek@suse.com>
Subject: [RFC 3/3] sysrq: Warn about insufficient console_loglevel
Date: Fri, 11 Jan 2019 17:20:38 +0100 [thread overview]
Message-ID: <20190111162038.19771-4-pmladek@suse.com> (raw)
In-Reply-To: <20190111162038.19771-1-pmladek@suse.com>
People are sometimes confused that they do not see any output
on the console when trying to get some debugging information
using SysRq.
The messages are filtered by the current console_loglevel.
It makes some sense because a very long output might cause
troubles with a slow console.
Fortunately, the console_loglevel can be increased by SysRq
as well. The only problem is that people do not know that
they should do so and how to do so.
This patch adds a message to help users. It is printed only
once and only when the loglevel is not sufficient.
There is also a need to export suppress_message_printing()
function.
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
drivers/tty/sysrq.c | 26 ++++++++++++++++++++++++++
include/linux/printk.h | 7 +++++++
kernel/printk/printk.c | 7 +++----
3 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index fa0ce7dd9e24..e517113cecec 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -523,9 +523,33 @@ static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p)
sysrq_key_table[i] = op_p;
}
+static void warn_console(bool console_suppressed,
+ int orig_log_level,
+ struct sysrq_key_op *op_p)
+{
+ static int warned;
+
+ if (warned)
+ return;
+
+ /* Do not warn when people are already setting loglevel via sysrq */
+ if (op_p->enable_mask & SYSRQ_ENABLE_LOG) {
+ warned = 1;
+ return;
+ }
+
+ if (console_suppressed) {
+ pr_info("Messages filtered by console_loglevel (%d)%s\n",
+ orig_log_level,
+ sysrq_on_mask(SYSRQ_ENABLE_LOG) ? ", try SysRq+7" : "");
+ warned = 1;
+ }
+}
+
void __handle_sysrq(int key, bool check_mask)
{
struct sysrq_key_op *op_p;
+ bool console_suppressed;
int orig_log_level;
int i;
@@ -537,6 +561,7 @@ void __handle_sysrq(int key, bool check_mask)
* simply emit this at KERN_EMERG as that would change message
* routing in the consumers of /proc/kmsg.
*/
+ console_suppressed = console_suppress_message(LOGLEVEL_INFO);
orig_log_level = console_loglevel;
console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
@@ -548,6 +573,7 @@ void __handle_sysrq(int key, bool check_mask)
*/
if (!check_mask || sysrq_on_mask(op_p->enable_mask)) {
pr_info("%s\n", op_p->action_msg);
+ warn_console(console_suppressed, orig_log_level, op_p);
console_loglevel = orig_log_level;
op_p->handler(key);
} else {
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 77740a506ebb..917bd6ca784c 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -193,6 +193,8 @@ devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write, void __user *buf,
extern void wake_up_klogd(void);
+extern bool console_suppress_message(int level);
+
char *log_buf_addr_get(void);
u32 log_buf_len_get(void);
void log_buf_vmcoreinfo_setup(void);
@@ -234,6 +236,11 @@ static inline void wake_up_klogd(void)
{
}
+static bool console_suppress_message(int)
+{
+ return false;
+}
+
static inline char *log_buf_addr_get(void)
{
return NULL;
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index d3d170374ceb..b37c3513d7d8 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1164,7 +1164,7 @@ module_param(ignore_loglevel, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(ignore_loglevel,
"ignore loglevel setting (prints all kernel messages to the console)");
-static bool suppress_message_printing(int level)
+bool console_suppress_message(int level)
{
return (level >= console_loglevel && !ignore_loglevel);
}
@@ -1198,7 +1198,7 @@ static void boot_delay_msec(int level)
unsigned long timeout;
if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
- || suppress_message_printing(level)) {
+ || console_suppress_message(level)) {
return;
}
@@ -2025,7 +2025,6 @@ static void call_console_drivers(const char *ext_text, size_t ext_len,
const char *text, size_t len) {}
static size_t msg_print_text(const struct printk_log *msg, bool syslog,
bool time, char *buf, size_t size) { return 0; }
-static bool suppress_message_printing(int level) { return false; }
#endif /* CONFIG_PRINTK */
@@ -2363,7 +2362,7 @@ void console_unlock(void)
break;
msg = log_from_idx(console_idx);
- if (suppress_message_printing(msg->level)) {
+ if (console_suppress_message(msg->level)) {
/*
* Skip record we have buffered and already printed
* directly to the console when we received it, and
--
2.13.7
next prev parent reply other threads:[~2019-01-11 16:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-11 16:20 [PATCH 0/3] sysrq: Simple fixes and console visibility Petr Mladek
2019-01-11 16:20 ` [PATCH 1/3] sysrq: Restore original console_loglevel when sysrq disabled Petr Mladek
2019-01-11 16:20 ` [PATCH 2/3] sysrq: Remove duplicated sysrq message Petr Mladek
2019-01-14 5:51 ` Sergey Senozhatsky
2019-01-14 14:45 ` Petr Mladek
2019-01-11 16:20 ` Petr Mladek [this message]
2019-01-14 8:05 ` [RFC 3/3] sysrq: Warn about insufficient console_loglevel Sergey Senozhatsky
2019-01-14 14:59 ` Petr Mladek
2019-01-15 3:03 ` Sergey Senozhatsky
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=20190111162038.19771-4-pmladek@suse.com \
--to=pmladek@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
/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
all inboxes | Powered by JetHome®