Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sys_info: add a default kernel sys_info mask

Which serves as a global default sys_info mask. When users want the same
system information for many error cases (panic, hung, lockup ...), they
can chose to set this global knob only once, while not setting up each
individual sys_info knobs.

This just adds a 'lazy' option, and doesn't change existing kernel
behavior as the mask is 0 by default.

Link: https://lkml.kernel.org/r/20251113111039.22701-5-feng.tang@linux.alibaba.com
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Lance Yang <ioworker0@gmail.com>
Cc: "Paul E . McKenney" <paulmck@kernel.org>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Feng Tang and committed by
Andrew Morton
03ef32d6 a9af76a7

+39 -1
+9
Documentation/admin-guide/sysctl/kernel.rst
··· 521 521 io_uring instances. 522 522 523 523 524 + kernel_sys_info 525 + =============== 526 + A comma separated list of extra system information to be dumped when 527 + soft/hard lockup is detected, for example, "tasks,mem,timers,locks,...". 528 + Refer 'panic_sys_info' section below for more details. 529 + 530 + It serves as the default kernel control knob, which will take effect 531 + when a kernel module calls sys_info() with parameter==0. 532 + 524 533 kexec_load_disabled 525 534 =================== 526 535
+30 -1
lib/sys_info.c
··· 24 24 [ilog2(SYS_INFO_BLOCKED_TASKS)] = "blocked_tasks", 25 25 }; 26 26 27 + /* 28 + * Default kernel sys_info mask. 29 + * If a kernel module calls sys_info() with "parameter == 0", then 30 + * this mask will be used. 31 + */ 32 + static unsigned long kernel_si_mask; 33 + 27 34 /* Expecting string like "xxx_sys_info=tasks,mem,timers,locks,ftrace,..." */ 28 35 unsigned long sys_info_parse_param(char *str) 29 36 { ··· 117 110 else 118 111 return sys_info_read_handler(&table, buffer, lenp, ppos, ro_table->data); 119 112 } 113 + 114 + static const struct ctl_table sys_info_sysctls[] = { 115 + { 116 + .procname = "kernel_sys_info", 117 + .data = &kernel_si_mask, 118 + .maxlen = sizeof(kernel_si_mask), 119 + .mode = 0644, 120 + .proc_handler = sysctl_sys_info_handler, 121 + }, 122 + }; 123 + 124 + static int __init sys_info_sysctl_init(void) 125 + { 126 + register_sysctl_init("kernel", sys_info_sysctls); 127 + return 0; 128 + } 129 + subsys_initcall(sys_info_sysctl_init); 120 130 #endif 121 131 122 - void sys_info(unsigned long si_mask) 132 + static void __sys_info(unsigned long si_mask) 123 133 { 124 134 if (si_mask & SYS_INFO_TASKS) 125 135 show_state(); ··· 158 134 159 135 if (si_mask & SYS_INFO_BLOCKED_TASKS) 160 136 show_state_filter(TASK_UNINTERRUPTIBLE); 137 + } 138 + 139 + void sys_info(unsigned long si_mask) 140 + { 141 + __sys_info(si_mask ? : kernel_si_mask); 161 142 }