linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] core_pattern: add CPU specifier
@ 2022-09-03  6:43 Oleksandr Natalenko
  2022-09-03  7:20 ` Oleg Nesterov
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Oleksandr Natalenko @ 2022-09-03  6:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-doc, linux-fsdevel, Jonathan Corbet, Alexander Viro,
	Andrew Morton, Huang Ying, Jason A . Donenfeld, Will Deacon,
	Guilherme G . Piccoli, Laurent Dufour, Stephen Kitt, Rob Herring,
	Joel Savitz, Eric W . Biederman, Kees Cook, Xiaoming Ni,
	Luis Chamberlain, Renaud Métrich, Oleg Nesterov,
	Grzegorz Halat, Qi Guo

Statistically, in a large deployment regular segfaults may indicate a CPU issue.

Currently, it is not possible to find out what CPU the segfault happened on.
There are at least two attempts to improve segfault logging with this regard,
but they do not help in case the logs rotate.

Hence, lets make sure it is possible to permanently record a CPU
the task ran on using a new core_pattern specifier.

Suggested-by: Renaud Métrich <rmetrich@redhat.com>
Signed-off-by: Oleksandr Natalenko <oleksandr@redhat.com>
---
 Documentation/admin-guide/sysctl/kernel.rst | 1 +
 fs/coredump.c                               | 5 +++++
 include/linux/coredump.h                    | 1 +
 3 files changed, 7 insertions(+)

diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst
index 835c8844bba48..b566fff04946b 100644
--- a/Documentation/admin-guide/sysctl/kernel.rst
+++ b/Documentation/admin-guide/sysctl/kernel.rst
@@ -169,6 +169,7 @@ core_pattern
 	%f      	executable filename
 	%E		executable path
 	%c		maximum size of core file by resource limit RLIMIT_CORE
+	%C		CPU the task ran on
 	%<OTHER>	both are dropped
 	========	==========================================
 
diff --git a/fs/coredump.c b/fs/coredump.c
index a8661874ac5b6..166d1f84a9b17 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -325,6 +325,10 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm,
 				err = cn_printf(cn, "%lu",
 					      rlimit(RLIMIT_CORE));
 				break;
+			/* CPU the task ran on */
+			case 'C':
+				err = cn_printf(cn, "%d", cprm->cpu);
+				break;
 			default:
 				break;
 			}
@@ -535,6 +539,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)
 		 */
 		.mm_flags = mm->flags,
 		.vma_meta = NULL,
+		.cpu = raw_smp_processor_id(),
 	};
 
 	audit_core_dumps(siginfo->si_signo);
diff --git a/include/linux/coredump.h b/include/linux/coredump.h
index 08a1d3e7e46d0..191dcf5af6cb9 100644
--- a/include/linux/coredump.h
+++ b/include/linux/coredump.h
@@ -22,6 +22,7 @@ struct coredump_params {
 	struct file *file;
 	unsigned long limit;
 	unsigned long mm_flags;
+	int cpu;
 	loff_t written;
 	loff_t pos;
 	loff_t to_skip;
-- 
2.37.2


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

end of thread, other threads:[~2022-09-08  6:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-03  6:43 [PATCH] core_pattern: add CPU specifier Oleksandr Natalenko
2022-09-03  7:20 ` Oleg Nesterov
2022-09-04 18:27 ` Andrew Morton
2022-09-04 19:38   ` Oleg Nesterov
2022-09-06 22:22 ` Eric W. Biederman
2022-09-07  6:15   ` Oleksandr Natalenko
2022-09-07 17:34     ` Oleg Nesterov
2022-09-07 22:00       ` Eric W. Biederman
2022-09-08  6:11         ` Oleksandr Natalenko
2022-09-07 15:53 ` Luis Chamberlain
2022-09-08  6:45   ` Renaud Métrich

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).