Skip to content

Commit a8a9d38

Browse files
committed
systemd: used drop-ins for configuration
Resolves: RHEL-97580 Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
1 parent 04c6a0d commit a8a9d38

File tree

8 files changed

+36
-16
lines changed

8 files changed

+36
-16
lines changed

00-tuned.conf.systemd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[Manager]
File renamed without changes.

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
NAME = tuned
22
# set to devel for nightly GIT snapshot
33
BUILD = release
4+
SYSTEMD_SUPPORT = 1
45
# which config to use in mock-build target
56
MOCK_CONFIG = rhel-7-x86_64
67
# scratch-build for triggering Jenkins
@@ -72,9 +73,9 @@ release-cp: release-dir
7273
cp -a AUTHORS COPYING INSTALL README.md $(VERSIONED_NAME)
7374

7475
cp -a tuned.py tuned.spec tuned.service tuned.tmpfiles Makefile tuned-adm.py \
75-
tuned-adm.bash dbus.conf recommend.conf tuned-main.conf 00_tuned \
76-
92-tuned.install bootcmdline modules.conf com.redhat.tuned.policy \
77-
tuned-gui.py tuned-gui.glade tuned-ppd.py \
76+
tuned-adm.bash dbus.conf recommend.conf tuned-main.conf 00_tuned.grub \
77+
00-tuned.conf.systemd 92-tuned.install bootcmdline modules.conf \
78+
com.redhat.tuned.policy tuned-gui.py tuned-gui.glade tuned-ppd.py \
7879
tuned-gui.desktop functions $(VERSIONED_NAME)
7980
cp -a doc experiments libexec man profiles systemtap tuned contrib icons \
8081
tests $(VERSIONED_NAME)
@@ -210,14 +211,21 @@ install: install-dirs
210211
# runtime directory
211212
install -Dpm 0644 tuned.tmpfiles $(DESTDIR)$(TMPFILESDIR)/tuned.conf
212213

214+
ifeq ($(SYSTEMD_SUPPORT), 1)
213215
# systemd units
214216
install -Dpm 0644 tuned.service $(DESTDIR)$(UNITDIR)/tuned.service
217+
endif
215218

216219
# dbus configuration
217220
install -Dpm 0644 dbus.conf $(DESTDIR)$(DATADIR)/dbus-1/system.d/com.redhat.tuned.conf
218221

219222
# grub template
220-
install -Dpm 0755 00_tuned $(DESTDIR)$(SYSCONFDIR)/grub.d/00_tuned
223+
install -Dpm 0755 00_tuned.grub $(DESTDIR)$(SYSCONFDIR)/grub.d/00_tuned
224+
225+
ifeq ($(SYSTEMD_SUPPORT), 1)
226+
# systemd template
227+
install -Dpm 0644 00-tuned.conf.systemd $(DESTDIR)$(SYSCONFDIR)/systemd/system.conf.d/00-tuned.conf
228+
endif
221229

222230
# kernel install hook
223231
install -Dpm 0755 92-tuned.install $(DESTDIR)$(KERNELINSTALLHOOKDIR)/92-tuned.install

profiles/cpu-partitioning/script.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ start() {
1212
else
1313
DRACUT_HOOK_DIR="/usr/lib/dracut/hooks/pre-udev"
1414
fi
15-
mkdir -p "${TUNED_tmpdir}/etc/systemd"
15+
mkdir -p "${TUNED_tmpdir}/etc/systemd/system.conf.d"
1616
mkdir -p "${TUNED_tmpdir}${DRACUT_HOOK_DIR}"
17-
cp /etc/systemd/system.conf "${TUNED_tmpdir}/etc/systemd/"
17+
cp /etc/systemd/system.conf.d/00-tuned.conf "${TUNED_tmpdir}/etc/systemd/system.conf.d/00-tuned.conf"
1818
cp 00-tuned-pre-udev.sh "${TUNED_tmpdir}${DRACUT_HOOK_DIR}"
1919
setup_kvm_mod_low_latency
2020
disable_ksm

profiles/cpu-partitioning/tuned.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ priority=10
6363
initrd_remove_dir=True
6464
initrd_dst_img=tuned-initrd.img
6565
initrd_add_dir=${tmpdir}
66-
cmdline_cpu_part=+nohz=on${cmd_isolcpus} nohz_full=${isolated_cores} rcu_nocbs=${isolated_cores} tuned.non_isolcpus=${not_isolated_cpumask} systemd.cpu_affinity=${not_isolated_cores} intel_pstate=disable nosoftlockup
66+
cmdline_cpu_part=+nohz=on${cmd_isolcpus} nohz_full=${isolated_cores} rcu_nocbs=${isolated_cores} tuned.non_isolcpus=${not_isolated_cpumask} intel_pstate=disable nosoftlockup

tuned.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,9 @@ fi
519519
%config(noreplace) %{_sysconfdir}/tuned/tuned-main.conf
520520
%config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/tuned/bootcmdline
521521
%verify(not size mtime md5) %{_sysconfdir}/modprobe.d/tuned.conf
522+
# https://bugzilla.redhat.com/show_bug.cgi?id=2444143
523+
%dir %{_sysconfdir}/systemd/system.conf.d
524+
%verify(not size mtime md5) %{_sysconfdir}/systemd/system.conf.d/00-tuned.conf
522525
%{_tmpfilesdir}/tuned.conf
523526
%{_unitdir}/tuned.service
524527
%dir %{_localstatedir}/log/tuned

tuned/consts.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,19 @@
5757
DEF_CGROUP_MOUNT_POINT = "/sys/fs/cgroup/cpuset"
5858
DEF_CGROUP_MODE = 0o770
5959

60+
# systemd paths used by multiple plugins
61+
SYSTEMD_CFG_PATH = "/etc/systemd"
62+
6063
# service plugin configuration
61-
SERVICE_SYSTEMD_CFG_PATH = "/etc/systemd/system/%s.service.d"
64+
SERVICE_SYSTEMD_CFG_PATH = SYSTEMD_CFG_PATH + "/system/%s.service.d"
6265
DEF_SERVICE_CFG_DIR_MODE = 0o755
6366

6467
# modules plugin configuration
6568
MODULES_FILE = "/etc/modprobe.d/tuned.conf"
6669

6770
# systemd plugin configuration
68-
SYSTEMD_SYSTEM_CONF_FILE = "/etc/systemd/system.conf"
71+
SYSTEMD_SYSTEM_CONF_FILE = SYSTEMD_CFG_PATH + "/system.conf.d/00-tuned.conf"
72+
SYSTEMD_SYSTEM_CONF_HEADER = "[Manager]"
6973
SYSTEMD_CPUAFFINITY_VAR = "CPUAffinity"
7074

7175
# irqbalance plugin configuration

tuned/plugins/plugin_systemd.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class SystemdPlugin(base.Plugin):
1515
Plug-in for tuning systemd options.
1616
1717
The [option]`cpu_affinity` option allows setting CPUAffinity in
18-
`/etc/systemd/system.conf`. This configures the CPU affinity for the
19-
service manager as well as the default CPU affinity for all forked
20-
off processes. The option takes a comma-separated list of CPUs with
21-
optional CPU ranges specified by the minus sign (`-`).
18+
`/etc/systemd/system.conf.d/00-tuned.conf`. This configures the CPU
19+
affinity for the service manager as well as the default CPU affinity
20+
for all forked off processes. The option takes a comma-separated
21+
list of CPUs with optional CPU ranges specified by the minus sign (`-`).
2222
2323
.Set the CPUAffinity for `systemd` to `0 1 2 3`
2424
====
@@ -32,10 +32,15 @@ class SystemdPlugin(base.Plugin):
3232
"""
3333

3434
def __init__(self, *args, **kwargs):
35+
self._cmd = commands()
3536
if not os.path.isfile(consts.SYSTEMD_SYSTEM_CONF_FILE):
36-
raise exceptions.NotSupportedPluginException("Required systemd '%s' configuration file not found, disabling plugin." % consts.SYSTEMD_SYSTEM_CONF_FILE)
37+
if os.path.isdir(consts.SYSTEMD_CFG_PATH):
38+
log.info("Systemd configuration file '%s' not found, attempting to create it." % consts.SYSTEMD_SYSTEM_CONF_FILE)
39+
if not self._cmd.write_to_file(consts.SYSTEMD_SYSTEM_CONF_FILE, consts.SYSTEMD_SYSTEM_CONF_HEADER + "\n", makedir=True):
40+
raise exceptions.NotSupportedPluginException("Error creating systemd configuration file '%s', disabling plugin." % consts.SYSTEMD_SYSTEM_CONF_FILE)
41+
else:
42+
raise exceptions.NotSupportedPluginException("Systemd directory '%s' not found, systemd is not probably used, disabling plugin." % consts.SYSTEMD_CFG_PATH)
3743
super(SystemdPlugin, self).__init__(*args, **kwargs)
38-
self._cmd = commands()
3944

4045
def _instance_init(self, instance):
4146
instance._has_dynamic_tuning = False
@@ -143,4 +148,3 @@ def _cmdline(self, enabling, value, verify, ignore_missing, instance):
143148
self._write_systemd_system_conf(self._add_keyval(conf, consts.SYSTEMD_CPUAFFINITY_VAR, v_unpacked))
144149
return True
145150
return None
146-

0 commit comments

Comments
 (0)