valeriyvdovin / rpms / systemd

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