b677e7
From 8bdc512d2651b4600f7e744b06633a7524b64346 Mon Sep 17 00:00:00 2001
b677e7
From: Lennart Poettering <lennart@poettering.net>
b677e7
Date: Mon, 12 Oct 2020 16:31:42 +0200
b677e7
Subject: [PATCH] sysctl: set kernel.core_pipe_limit=16
b677e7
b677e7
We need to make sure that our coredump pattern handler manages to read
b677e7
process metadata from /proc/$PID/ before the kernel reaps the crashed
b677e7
process. By default the kernel will reap the process as soon as it can.
b677e7
By setting kernel.core_pipe_limit to a non-zero the kernel will wait for
b677e7
userspace to finish before reaping.
b677e7
b677e7
We'll set the value to 16, which allows 16 crashes to be
b677e7
processed in parallel. This matches the MaxConnections= setting in
b677e7
systemd-coredump.socket.
b677e7
b677e7
See: #17301
b677e7
b677e7
(This doesn't close 17301, since we probably should also gracefully
b677e7
handle if /proc/$PID/ vanished already while our coredump handler runs,
b677e7
just in case people loclly set the sysctl back to zero. i.e. we should
b677e7
collect what we can and rather issue an incomplete log record than
b677e7
none.)
b677e7
b677e7
(cherry picked from commit 2a9b9323cd844baae3229e9dba67e478bee70654)
b677e7
b677e7
Resolves: #1949729
b677e7
---
b677e7
 sysctl.d/50-coredump.conf.in | 11 +++++++++++
b677e7
 1 file changed, 11 insertions(+)
b677e7
b677e7
diff --git a/sysctl.d/50-coredump.conf.in b/sysctl.d/50-coredump.conf.in
b677e7
index ccd5c2cc56..8d6fbb718c 100644
b677e7
--- a/sysctl.d/50-coredump.conf.in
b677e7
+++ b/sysctl.d/50-coredump.conf.in
b677e7
@@ -10,3 +10,14 @@
b677e7
 # setting below.
b677e7
 
b677e7
 kernel.core_pattern=|@rootlibexecdir@/systemd-coredump %P %u %g %s %t %c %h %e
b677e7
+
b677e7
+# Allow that 16 coredumps are dispatched in parallel by the kernel. We want to
b677e7
+# be able to collect process metadata from /proc/%P/ while processing
b677e7
+# coredumps, and thus need to make sure the crashed processes are not reaped
b677e7
+# until we finished collecting what we need. The kernel default for this sysctl
b677e7
+# is "0" which means the kernel doesn't wait for userspace processes to finish
b677e7
+# processing before reaping the crashed processes — by setting this higher the
b677e7
+# kernel will delay reaping until we are done, but only for the specified
b677e7
+# number of crashes in parallel. The value of 16 is chosen to match
b677e7
+# systemd-coredump.socket's MaxConnections= value.
b677e7
+kernel.core_pipe_limit=16