By using the printk_loud_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.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
drivers/tty/sysrq.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 930b04e3d148..1ff11cf6275a 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -583,7 +583,6 @@ static void __sysrq_put_key_op(u8 key, const struct sysrq_key_op *op_p)
void __handle_sysrq(u8 key, bool check_mask)
{
const struct sysrq_key_op *op_p;
- int orig_log_level;
int orig_suppress_printk;
int i;
@@ -593,13 +592,12 @@ void __handle_sysrq(u8 key, bool check_mask)
rcu_sysrq_start();
rcu_read_lock();
/*
- * Raise the apparent loglevel to maximum so that the sysrq header
- * is shown to provide the user with positive feedback. We do not
- * simply emit this at KERN_EMERG as that would change message
- * routing in the consumers of /proc/kmsg.
+ * Enter in the console_loud context so that sysrq header is shown to
+ * provide the user with positive feedback. We do not simply emit this
+ * at KERN_EMERG as that would change message routing in the consumers
+ * of /proc/kmsg.
*/
- orig_log_level = console_loglevel;
- console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
+ printk_loud_console_enter();
op_p = __sysrq_get_key_op(key);
if (op_p) {
@@ -609,11 +607,11 @@ void __handle_sysrq(u8 key, bool check_mask)
*/
if (!check_mask || sysrq_on_mask(op_p->enable_mask)) {
pr_info("%s\n", op_p->action_msg);
- console_loglevel = orig_log_level;
+ printk_loud_console_exit();
op_p->handler(key);
} else {
pr_info("This sysrq operation is disabled.\n");
- console_loglevel = orig_log_level;
+ printk_loud_console_exit();
}
} else {
pr_info("HELP : ");
@@ -631,7 +629,7 @@ void __handle_sysrq(u8 key, bool check_mask)
}
}
pr_cont("\n");
- console_loglevel = orig_log_level;
+ printk_loud_console_exit();
}
rcu_read_unlock();
rcu_sysrq_end();
--
2.46.1
Hi Marcos, kernel test robot noticed the following build errors: [auto build test ERROR on 1d227fcc72223cbdd34d0ce13541cbaab5e0d72f] url: https://github.com/intel-lab-lkp/linux/commits/Marcos-Paulo-de-Souza/printk-Introduce-LOUD_CON-flag/20241017-010521 base: 1d227fcc72223cbdd34d0ce13541cbaab5e0d72f patch link: https://lore.kernel.org/r/20241016-printk-loud-con-v1-2-065e4dad6632%40suse.com patch subject: [PATCH 2/2] tty: sysrq: Use printk_loud_console context on __handle_sysrq config: i386-buildonly-randconfig-001-20241018 (https://download.01.org/0day-ci/archive/20241018/202410181205.VT06PKmP-lkp@intel.com/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241018/202410181205.VT06PKmP-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410181205.VT06PKmP-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/tty/sysrq.c:600:2: error: call to undeclared function 'printk_loud_console_enter'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 600 | printk_loud_console_enter(); | ^ >> drivers/tty/sysrq.c:610:4: error: call to undeclared function 'printk_loud_console_exit'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 610 | printk_loud_console_exit(); | ^ drivers/tty/sysrq.c:614:4: error: call to undeclared function 'printk_loud_console_exit'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 614 | printk_loud_console_exit(); | ^ drivers/tty/sysrq.c:632:3: error: call to undeclared function 'printk_loud_console_exit'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 632 | printk_loud_console_exit(); | ^ 4 errors generated. vim +/printk_loud_console_enter +600 drivers/tty/sysrq.c 582 583 void __handle_sysrq(u8 key, bool check_mask) 584 { 585 const struct sysrq_key_op *op_p; 586 int orig_suppress_printk; 587 int i; 588 589 orig_suppress_printk = suppress_printk; 590 suppress_printk = 0; 591 592 rcu_sysrq_start(); 593 rcu_read_lock(); 594 /* 595 * Enter in the console_loud context so that sysrq header is shown to 596 * provide the user with positive feedback. We do not simply emit this 597 * at KERN_EMERG as that would change message routing in the consumers 598 * of /proc/kmsg. 599 */ > 600 printk_loud_console_enter(); 601 602 op_p = __sysrq_get_key_op(key); 603 if (op_p) { 604 /* 605 * Should we check for enabled operations (/proc/sysrq-trigger 606 * should not) and is the invoked operation enabled? 607 */ 608 if (!check_mask || sysrq_on_mask(op_p->enable_mask)) { 609 pr_info("%s\n", op_p->action_msg); > 610 printk_loud_console_exit(); 611 op_p->handler(key); 612 } else { 613 pr_info("This sysrq operation is disabled.\n"); 614 printk_loud_console_exit(); 615 } 616 } else { 617 pr_info("HELP : "); 618 /* Only print the help msg once per handler */ 619 for (i = 0; i < ARRAY_SIZE(sysrq_key_table); i++) { 620 if (sysrq_key_table[i]) { 621 int j; 622 623 for (j = 0; sysrq_key_table[i] != 624 sysrq_key_table[j]; j++) 625 ; 626 if (j != i) 627 continue; 628 pr_cont("%s ", sysrq_key_table[i]->help_msg); 629 } 630 } 631 pr_cont("\n"); 632 printk_loud_console_exit(); 633 } 634 rcu_read_unlock(); 635 rcu_sysrq_end(); 636 637 suppress_printk = orig_suppress_printk; 638 } 639 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Hi Marcos, kernel test robot noticed the following build errors: [auto build test ERROR on 1d227fcc72223cbdd34d0ce13541cbaab5e0d72f] url: https://github.com/intel-lab-lkp/linux/commits/Marcos-Paulo-de-Souza/printk-Introduce-LOUD_CON-flag/20241017-010521 base: 1d227fcc72223cbdd34d0ce13541cbaab5e0d72f patch link: https://lore.kernel.org/r/20241016-printk-loud-con-v1-2-065e4dad6632%40suse.com patch subject: [PATCH 2/2] tty: sysrq: Use printk_loud_console context on __handle_sysrq config: x86_64-buildonly-randconfig-004-20241018 (https://download.01.org/0day-ci/archive/20241018/202410181116.WA27FpBB-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241018/202410181116.WA27FpBB-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410181116.WA27FpBB-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/tty/sysrq.c: In function '__handle_sysrq': >> drivers/tty/sysrq.c:600:9: error: implicit declaration of function 'printk_loud_console_enter' [-Werror=implicit-function-declaration] 600 | printk_loud_console_enter(); | ^~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/tty/sysrq.c:610:25: error: implicit declaration of function 'printk_loud_console_exit' [-Werror=implicit-function-declaration] 610 | printk_loud_console_exit(); | ^~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors vim +/printk_loud_console_enter +600 drivers/tty/sysrq.c 582 583 void __handle_sysrq(u8 key, bool check_mask) 584 { 585 const struct sysrq_key_op *op_p; 586 int orig_suppress_printk; 587 int i; 588 589 orig_suppress_printk = suppress_printk; 590 suppress_printk = 0; 591 592 rcu_sysrq_start(); 593 rcu_read_lock(); 594 /* 595 * Enter in the console_loud context so that sysrq header is shown to 596 * provide the user with positive feedback. We do not simply emit this 597 * at KERN_EMERG as that would change message routing in the consumers 598 * of /proc/kmsg. 599 */ > 600 printk_loud_console_enter(); 601 602 op_p = __sysrq_get_key_op(key); 603 if (op_p) { 604 /* 605 * Should we check for enabled operations (/proc/sysrq-trigger 606 * should not) and is the invoked operation enabled? 607 */ 608 if (!check_mask || sysrq_on_mask(op_p->enable_mask)) { 609 pr_info("%s\n", op_p->action_msg); > 610 printk_loud_console_exit(); 611 op_p->handler(key); 612 } else { 613 pr_info("This sysrq operation is disabled.\n"); 614 printk_loud_console_exit(); 615 } 616 } else { 617 pr_info("HELP : "); 618 /* Only print the help msg once per handler */ 619 for (i = 0; i < ARRAY_SIZE(sysrq_key_table); i++) { 620 if (sysrq_key_table[i]) { 621 int j; 622 623 for (j = 0; sysrq_key_table[i] != 624 sysrq_key_table[j]; j++) 625 ; 626 if (j != i) 627 continue; 628 pr_cont("%s ", sysrq_key_table[i]->help_msg); 629 } 630 } 631 pr_cont("\n"); 632 printk_loud_console_exit(); 633 } 634 rcu_read_unlock(); 635 rcu_sysrq_end(); 636 637 suppress_printk = orig_suppress_printk; 638 } 639 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
© 2016 - 2024 Red Hat, Inc.