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