daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
c2dfb7
From 82156850f6642a363aa2ff06677ad089a460104e Mon Sep 17 00:00:00 2001
c2dfb7
From: Lennart Poettering <lennart@poettering.net>
c2dfb7
Date: Tue, 26 Nov 2019 09:46:00 +0100
c2dfb7
Subject: [PATCH] pid1: add new kernel cmdline arg systemd.cpu_affinity=
c2dfb7
c2dfb7
Let's allow configuration of the CPU affinity via the kernel cmdline,
c2dfb7
overriding CPUAffinity= in /etc/systemd/system.conf
c2dfb7
c2dfb7
Prompted by:
c2dfb7
c2dfb7
https://lists.freedesktop.org/archives/systemd-devel/2019-November/043754.html
c2dfb7
c2dfb7
(cherry picked from commit 68d58f38693e586b5ce5785274f8e42a79625196)
c2dfb7
c2dfb7
Resolves: #1812894
c2dfb7
---
c2dfb7
 man/kernel-command-line.xml | 11 +++++++++++
c2dfb7
 src/core/main.c             |  9 +++++++++
c2dfb7
 2 files changed, 20 insertions(+)
c2dfb7
c2dfb7
diff --git a/man/kernel-command-line.xml b/man/kernel-command-line.xml
c2dfb7
index 0545f9d84b..4d8cb4e50e 100644
c2dfb7
--- a/man/kernel-command-line.xml
c2dfb7
+++ b/man/kernel-command-line.xml
c2dfb7
@@ -366,6 +366,17 @@
c2dfb7
         </listitem>
c2dfb7
       </varlistentry>
c2dfb7
 
c2dfb7
+      <varlistentry>
c2dfb7
+        <term><varname>systemd.cpu_affinity=</varname></term>
c2dfb7
+
c2dfb7
+        <listitem>
c2dfb7
+          <para>Overrides the CPU affinity mask for the service manager and the default for all child
c2dfb7
+          processes it forks. This takes precedence over <varname>CPUAffinity=</varname>, see
c2dfb7
+          <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
c2dfb7
+          for details.</para>
c2dfb7
+        </listitem>
c2dfb7
+      </varlistentry>
c2dfb7
+
c2dfb7
       <varlistentry>
c2dfb7
         <term><varname>modules_load=</varname></term>
c2dfb7
         <term><varname>rd.modules_load=</varname></term>
c2dfb7
diff --git a/src/core/main.c b/src/core/main.c
c2dfb7
index 45d09b1e11..9f238a8430 100644
c2dfb7
--- a/src/core/main.c
c2dfb7
+++ b/src/core/main.c
c2dfb7
@@ -472,6 +472,15 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
c2dfb7
                 if (arg_default_timeout_start_usec <= 0)
c2dfb7
                         arg_default_timeout_start_usec = USEC_INFINITY;
c2dfb7
 
c2dfb7
+        } else if (proc_cmdline_key_streq(key, "systemd.cpu_affinity")) {
c2dfb7
+
c2dfb7
+                if (proc_cmdline_value_missing(key, value))
c2dfb7
+                        return 0;
c2dfb7
+
c2dfb7
+                r = parse_cpu_set(value, &arg_cpu_affinity);
c2dfb7
+                if (r < 0)
c2dfb7
+                        log_warning_errno(r, "Failed to parse CPU affinity mask '%s', ignoring: %m", value);
c2dfb7
+
c2dfb7
         } else if (proc_cmdline_key_streq(key, "systemd.watchdog_device")) {
c2dfb7
 
c2dfb7
                 if (proc_cmdline_value_missing(key, value))