linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] follow up patches for panic_print's generalization
@ 2025-08-25  2:56 Feng Tang
  2025-08-25  2:56 ` [PATCH v2 1/4] lib/sys_info: handle sys_info_mask==0 case Feng Tang
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Feng Tang @ 2025-08-25  2:56 UTC (permalink / raw)
  To: Andrew Morton, Petr Mladek, Steven Rostedt, Lance Yang,
	Jonathan Corbet, linux-kernel
  Cc: Askar Safin, paulmck, john.ogness, Feng Tang

Generalization of panic_print's dump function [1] has been merged, and
this patchset is to address some remaining issues, like adding note of
the obsoletion of 'panic_print' cmdline parameter, refining the kernel
document for panic_print, and hardening some string management.

Please help to review!

- Feng

Changelog:

  v2:
  * Add Petr's cleanup patch for obsoleting msg of 'panic_print'
  * Some comment and format cleanup
  * Collect review/test tags


Feng Tang (3):
  lib/sys_info: handle sys_info_mask==0 case
  panic: refine the document for 'panic_print'
  panic: add note that 'panic_print' parameter is deprecated

Petr Mladek (1):
  panic: Clean up message about deprecated 'panic_print' parameter

 .../admin-guide/kernel-parameters.txt         |  2 +-
 Documentation/admin-guide/sysctl/kernel.rst   |  2 +-
 include/linux/moduleparam.h                   | 13 ++++++++++
 kernel/panic.c                                | 26 +++++++++++++++++--
 lib/sys_info.c                                |  3 ++-
 5 files changed, 41 insertions(+), 5 deletions(-)

-- 
2.39.5 (Apple Git-154)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/4] lib/sys_info: handle sys_info_mask==0 case
  2025-08-25  2:56 [PATCH v2 0/4] follow up patches for panic_print's generalization Feng Tang
@ 2025-08-25  2:56 ` Feng Tang
  2025-08-25  2:56 ` [PATCH v2 2/4] panic: refine the document for 'panic_print' Feng Tang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Feng Tang @ 2025-08-25  2:56 UTC (permalink / raw)
  To: Andrew Morton, Petr Mladek, Steven Rostedt, Lance Yang,
	Jonathan Corbet, linux-kernel
  Cc: Askar Safin, paulmck, john.ogness, Feng Tang

It is a normal case that bitmask parameter is 0, so pre-initialize the
names[] to null string to cover this case.

Also remove the superfluous "+1" in names[sizeof(sys_info_avail) + 1],
which is needed for 'strlen()', but not for 'sizeof()'.

Suggested-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
---
 lib/sys_info.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/sys_info.c b/lib/sys_info.c
index 5bf503fd7ec1..496f9151c9b6 100644
--- a/lib/sys_info.c
+++ b/lib/sys_info.c
@@ -55,7 +55,7 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,
 					  void *buffer, size_t *lenp,
 					  loff_t *ppos)
 {
-	char names[sizeof(sys_info_avail) + 1];
+	char names[sizeof(sys_info_avail)];
 	struct ctl_table table;
 	unsigned long *si_bits_global;
 
@@ -81,6 +81,7 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,
 		char *delim = "";
 		int i, len = 0;
 
+		names[0] = '\0';
 		for (i = 0; i < ARRAY_SIZE(si_names); i++) {
 			if (*si_bits_global & si_names[i].bit) {
 				len += scnprintf(names + len, sizeof(names) - len,
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] panic: refine the document for 'panic_print'
  2025-08-25  2:56 [PATCH v2 0/4] follow up patches for panic_print's generalization Feng Tang
  2025-08-25  2:56 ` [PATCH v2 1/4] lib/sys_info: handle sys_info_mask==0 case Feng Tang
@ 2025-08-25  2:56 ` Feng Tang
  2025-08-25  2:57 ` [PATCH v2 3/4] panic: add note that 'panic_print' parameter is deprecated Feng Tang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Feng Tang @ 2025-08-25  2:56 UTC (permalink / raw)
  To: Andrew Morton, Petr Mladek, Steven Rostedt, Lance Yang,
	Jonathan Corbet, linux-kernel
  Cc: Askar Safin, paulmck, john.ogness, Feng Tang

User reported current document about SYS_INFO_PANIC_CONSOLE_REPLAY
is confusing, that people could expect all user space console messages
to be replayed.

Specify that only 'kernel' messages will be replayed to solve the confusion.

Reported-by: Askar Safin <safinaskar@zohomail.com>
Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
---
 Documentation/admin-guide/kernel-parameters.txt | 2 +-
 Documentation/admin-guide/sysctl/kernel.rst     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 747a55abf494..86f395f2933b 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4589,7 +4589,7 @@
 			bit 2: print timer info
 			bit 3: print locks info if CONFIG_LOCKDEP is on
 			bit 4: print ftrace buffer
-			bit 5: replay all messages on consoles at the end of panic
+			bit 5: replay all kernel messages on consoles at the end of panic
 			bit 6: print all CPUs backtrace (if available in the arch)
 			bit 7: print only tasks in uninterruptible (blocked) state
 			*Be aware* that this option may print a _lot_ of lines,
diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst
index 8b49eab937d0..f3ee807b5d8b 100644
--- a/Documentation/admin-guide/sysctl/kernel.rst
+++ b/Documentation/admin-guide/sysctl/kernel.rst
@@ -890,7 +890,7 @@ bit 1  print system memory info
 bit 2  print timer info
 bit 3  print locks info if ``CONFIG_LOCKDEP`` is on
 bit 4  print ftrace buffer
-bit 5  replay all messages on consoles at the end of panic
+bit 5  replay all kernel messages on consoles at the end of panic
 bit 6  print all CPUs backtrace (if available in the arch)
 bit 7  print only tasks in uninterruptible (blocked) state
 =====  ============================================
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/4] panic: add note that 'panic_print' parameter is deprecated
  2025-08-25  2:56 [PATCH v2 0/4] follow up patches for panic_print's generalization Feng Tang
  2025-08-25  2:56 ` [PATCH v2 1/4] lib/sys_info: handle sys_info_mask==0 case Feng Tang
  2025-08-25  2:56 ` [PATCH v2 2/4] panic: refine the document for 'panic_print' Feng Tang
@ 2025-08-25  2:57 ` Feng Tang
  2025-08-25  2:57 ` [PATCH v2 4/4] panic: Clean up message about deprecated 'panic_print' parameter Feng Tang
  2025-08-26  0:38 ` [PATCH v2 0/4] follow up patches for panic_print's generalization Andrew Morton
  4 siblings, 0 replies; 6+ messages in thread
From: Feng Tang @ 2025-08-25  2:57 UTC (permalink / raw)
  To: Andrew Morton, Petr Mladek, Steven Rostedt, Lance Yang,
	Jonathan Corbet, linux-kernel
  Cc: Askar Safin, paulmck, john.ogness, Feng Tang

Just like for 'panic_print's systcl interface, add similar note for
setup of kernel cmdline parameter and parameter under /sys/module/kernel/.

Also add __core_param_cb() macro, which enables to add special get/set
operation for a kernel parameter.

Suggested-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
---
 include/linux/moduleparam.h | 13 +++++++++++++
 kernel/panic.c              | 19 ++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 3a25122d83e2..6907aedc4f74 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -349,6 +349,19 @@ static inline void kernel_param_unlock(struct module *mod)
 	__module_param_call("", name, &param_ops_##type, &var, perm,	\
 			    -1, KERNEL_PARAM_FL_UNSAFE)
 
+/**
+ * __core_param_cb - similar like core_param, with a set/get ops instead of type.
+ * @name: the name of the cmdline and sysfs parameter (often the same as var)
+ * @var: the variable
+ * @ops: the set & get operations for this parameter.
+ * @perm: visibility in sysfs
+ *
+ * Ideally this should be called 'core_param_cb', but the name has been
+ * used for module core parameter, so add the '__' prefix
+ */
+#define __core_param_cb(name, ops, arg, perm) \
+	__module_param_call("", name, ops, arg, perm, -1, 0)
+
 #endif /* !MODULE */
 
 /**
diff --git a/kernel/panic.c b/kernel/panic.c
index 72fcbb5a071b..12a10e17ab4a 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -937,12 +937,29 @@ EXPORT_SYMBOL(__stack_chk_fail);
 #endif
 
 core_param(panic, panic_timeout, int, 0644);
-core_param(panic_print, panic_print, ulong, 0644);
 core_param(pause_on_oops, pause_on_oops, int, 0644);
 core_param(panic_on_warn, panic_on_warn, int, 0644);
 core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644);
 core_param(panic_console_replay, panic_console_replay, bool, 0644);
 
+static int panic_print_set(const char *val, const struct kernel_param *kp)
+{
+	pr_info_once("Kernel: 'panic_print' parameter will be obsoleted by both 'panic_sys_info' and 'panic_console_replay'\n");
+	return  param_set_ulong(val, kp);
+}
+
+static int panic_print_get(char *val, const struct kernel_param *kp)
+{
+	pr_info_once("Kernel: 'panic_print' parameter will be obsoleted by both 'panic_sys_info' and 'panic_console_replay'\n");
+	return  param_get_ulong(val, kp);
+}
+
+static const struct kernel_param_ops panic_print_ops = {
+	.set	= panic_print_set,
+	.get	= panic_print_get,
+};
+__core_param_cb(panic_print, &panic_print_ops, &panic_print, 0644);
+
 static int __init oops_setup(char *s)
 {
 	if (!s)
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 4/4] panic: Clean up message about deprecated 'panic_print' parameter
  2025-08-25  2:56 [PATCH v2 0/4] follow up patches for panic_print's generalization Feng Tang
                   ` (2 preceding siblings ...)
  2025-08-25  2:57 ` [PATCH v2 3/4] panic: add note that 'panic_print' parameter is deprecated Feng Tang
@ 2025-08-25  2:57 ` Feng Tang
  2025-08-26  0:38 ` [PATCH v2 0/4] follow up patches for panic_print's generalization Andrew Morton
  4 siblings, 0 replies; 6+ messages in thread
From: Feng Tang @ 2025-08-25  2:57 UTC (permalink / raw)
  To: Andrew Morton, Petr Mladek, Steven Rostedt, Lance Yang,
	Jonathan Corbet, linux-kernel
  Cc: Askar Safin, paulmck, john.ogness, Feng Tang

From: Petr Mladek <pmladek@suse.com>

Remove duplication of the message about deprecated 'panic_print'
parameter.

Also make the wording more direct. Make it clear that the new
parameters already exist and should be used instead.

Signed-off-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Tested-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Feng Tang <feng.tang@linux.alibaba.com>
---
 kernel/panic.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index 12a10e17ab4a..24bca263f896 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -77,6 +77,11 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
 
 EXPORT_SYMBOL(panic_notifier_list);
 
+static void panic_print_deprecated(void)
+{
+	pr_info_once("Kernel: The 'panic_print' parameter is now deprecated. Please use 'panic_sys_info' and 'panic_console_replay' instead.\n");
+}
+
 #ifdef CONFIG_SYSCTL
 
 /*
@@ -125,7 +130,7 @@ static int proc_taint(const struct ctl_table *table, int write,
 static int sysctl_panic_print_handler(const struct ctl_table *table, int write,
 			   void *buffer, size_t *lenp, loff_t *ppos)
 {
-	pr_info_once("Kernel: 'panic_print' sysctl interface will be obsoleted by both 'panic_sys_info' and 'panic_console_replay'\n");
+	panic_print_deprecated();
 	return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
 }
 
@@ -944,13 +949,13 @@ core_param(panic_console_replay, panic_console_replay, bool, 0644);
 
 static int panic_print_set(const char *val, const struct kernel_param *kp)
 {
-	pr_info_once("Kernel: 'panic_print' parameter will be obsoleted by both 'panic_sys_info' and 'panic_console_replay'\n");
+	panic_print_deprecated();
 	return  param_set_ulong(val, kp);
 }
 
 static int panic_print_get(char *val, const struct kernel_param *kp)
 {
-	pr_info_once("Kernel: 'panic_print' parameter will be obsoleted by both 'panic_sys_info' and 'panic_console_replay'\n");
+	panic_print_deprecated();
 	return  param_get_ulong(val, kp);
 }
 
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/4] follow up patches for panic_print's generalization
  2025-08-25  2:56 [PATCH v2 0/4] follow up patches for panic_print's generalization Feng Tang
                   ` (3 preceding siblings ...)
  2025-08-25  2:57 ` [PATCH v2 4/4] panic: Clean up message about deprecated 'panic_print' parameter Feng Tang
@ 2025-08-26  0:38 ` Andrew Morton
  4 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2025-08-26  0:38 UTC (permalink / raw)
  To: Feng Tang
  Cc: Petr Mladek, Steven Rostedt, Lance Yang, Jonathan Corbet,
	linux-kernel, Askar Safin, paulmck, john.ogness

On Mon, 25 Aug 2025 10:56:57 +0800 Feng Tang <feng.tang@linux.alibaba.com> wrote:

> Generalization of panic_print's dump function [1] has been merged, and
> this patchset is to address some remaining issues, like adding note of
> the obsoletion of 'panic_print' cmdline parameter, refining the kernel
> document for panic_print, and hardening some string management.

There was no [1].  I added

Link: Link: https://lkml.kernel.org/r/20250703021004.42328-1-feng.tang@linux.alibaba.com [1]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-26  0:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-25  2:56 [PATCH v2 0/4] follow up patches for panic_print's generalization Feng Tang
2025-08-25  2:56 ` [PATCH v2 1/4] lib/sys_info: handle sys_info_mask==0 case Feng Tang
2025-08-25  2:56 ` [PATCH v2 2/4] panic: refine the document for 'panic_print' Feng Tang
2025-08-25  2:57 ` [PATCH v2 3/4] panic: add note that 'panic_print' parameter is deprecated Feng Tang
2025-08-25  2:57 ` [PATCH v2 4/4] panic: Clean up message about deprecated 'panic_print' parameter Feng Tang
2025-08-26  0:38 ` [PATCH v2 0/4] follow up patches for panic_print's generalization Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).