Skip to content

Commit e3eea25

Browse files
marcospspmladek
authored andcommitted
tty: sysrq: Use printk_force_console context on __handle_sysrq
By using the printk_force_console the loglevel workaround can be removed. The workaround existed to always send the sysrq header message to all consoles not matter what was the current loglevel, but it won't work for deferred messages, since the loglevel can be restore before the message is printed, suppressing the message that wasn't supposed to be suppressed by the workaround. Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> Reviewed-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20241105-printk-loud-con-v2-2-bd3ecdf7b0e4@suse.com Signed-off-by: Petr Mladek <pmladek@suse.com>
1 parent ed76c07 commit e3eea25

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

drivers/tty/sysrq.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ static void __sysrq_put_key_op(u8 key, const struct sysrq_key_op *op_p)
582582
void __handle_sysrq(u8 key, bool check_mask)
583583
{
584584
const struct sysrq_key_op *op_p;
585-
int orig_log_level;
586585
int orig_suppress_printk;
587586
int i;
588587

@@ -592,13 +591,12 @@ void __handle_sysrq(u8 key, bool check_mask)
592591
rcu_sysrq_start();
593592
rcu_read_lock();
594593
/*
595-
* Raise the apparent loglevel to maximum so that the sysrq header
596-
* is shown to provide the user with positive feedback. We do not
597-
* simply emit this at KERN_EMERG as that would change message
598-
* routing in the consumers of /proc/kmsg.
594+
* Enter in the force_console context so that sysrq header is shown to
595+
* provide the user with positive feedback. We do not simply emit this
596+
* at KERN_EMERG as that would change message routing in the consumers
597+
* of /proc/kmsg.
599598
*/
600-
orig_log_level = console_loglevel;
601-
console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
599+
printk_force_console_enter();
602600

603601
op_p = __sysrq_get_key_op(key);
604602
if (op_p) {
@@ -608,11 +606,11 @@ void __handle_sysrq(u8 key, bool check_mask)
608606
*/
609607
if (!check_mask || sysrq_on_mask(op_p->enable_mask)) {
610608
pr_info("%s\n", op_p->action_msg);
611-
console_loglevel = orig_log_level;
609+
printk_force_console_exit();
612610
op_p->handler(key);
613611
} else {
614612
pr_info("This sysrq operation is disabled.\n");
615-
console_loglevel = orig_log_level;
613+
printk_force_console_exit();
616614
}
617615
} else {
618616
pr_info("HELP : ");
@@ -630,7 +628,7 @@ void __handle_sysrq(u8 key, bool check_mask)
630628
}
631629
}
632630
pr_cont("\n");
633-
console_loglevel = orig_log_level;
631+
printk_force_console_exit();
634632
}
635633
rcu_read_unlock();
636634
rcu_sysrq_end();

0 commit comments

Comments
 (0)