Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 00-tuned.conf.systemd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Manager]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this file be completely unnecessary after the change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I guess it's still useful to have it there so that it is removed together with the whole package and wouldn't leave a random configuration file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I guess it's still useful to have it there so that it is removed together with the whole package and wouldn't leave a random configuration file.

Yes, it's always better to have the package manager to handle it - it will also backup the file in case user already has there his own configuration file with the same name.

The code in the plugin is just a fallback for special cases when the template file is not installed by RPM or make install, e.g. it could happen on some non RPM distro. IMHO in such case it's better if the plugin works OK and creates the file that could be a leftover later than if it doesn't work.

File renamed without changes.
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
NAME = tuned
# set to devel for nightly GIT snapshot
BUILD = release
SYSTEMD_SUPPORT = 1
# which config to use in mock-build target
MOCK_CONFIG = rhel-7-x86_64
# scratch-build for triggering Jenkins
Expand Down Expand Up @@ -72,9 +73,9 @@ release-cp: release-dir
cp -a AUTHORS COPYING INSTALL README.md $(VERSIONED_NAME)

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

ifeq ($(SYSTEMD_SUPPORT), 1)
# systemd units
install -Dpm 0644 tuned.service $(DESTDIR)$(UNITDIR)/tuned.service
endif

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

# grub template
install -Dpm 0755 00_tuned $(DESTDIR)$(SYSCONFDIR)/grub.d/00_tuned
install -Dpm 0755 00_tuned.grub $(DESTDIR)$(SYSCONFDIR)/grub.d/00_tuned

ifeq ($(SYSTEMD_SUPPORT), 1)
# systemd template
install -Dpm 0644 00-tuned.conf.systemd $(DESTDIR)$(SYSCONFDIR)/systemd/system.conf.d/00-tuned.conf
endif

# kernel install hook
install -Dpm 0755 92-tuned.install $(DESTDIR)$(KERNELINSTALLHOOKDIR)/92-tuned.install
Expand Down
4 changes: 2 additions & 2 deletions profiles/cpu-partitioning/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ start() {
else
DRACUT_HOOK_DIR="/usr/lib/dracut/hooks/pre-udev"
fi
mkdir -p "${TUNED_tmpdir}/etc/systemd"
mkdir -p "${TUNED_tmpdir}/etc/systemd/system.conf.d"
mkdir -p "${TUNED_tmpdir}${DRACUT_HOOK_DIR}"
cp /etc/systemd/system.conf "${TUNED_tmpdir}/etc/systemd/"
cp /etc/systemd/system.conf.d/00-tuned.conf "${TUNED_tmpdir}/etc/systemd/system.conf.d/00-tuned.conf"
cp 00-tuned-pre-udev.sh "${TUNED_tmpdir}${DRACUT_HOOK_DIR}"
setup_kvm_mod_low_latency
disable_ksm
Expand Down
2 changes: 1 addition & 1 deletion profiles/cpu-partitioning/tuned.conf
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ priority=10
initrd_remove_dir=True
initrd_dst_img=tuned-initrd.img
initrd_add_dir=${tmpdir}
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
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
3 changes: 3 additions & 0 deletions tuned.spec
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ fi
%config(noreplace) %{_sysconfdir}/tuned/tuned-main.conf
%config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/tuned/bootcmdline
%verify(not size mtime md5) %{_sysconfdir}/modprobe.d/tuned.conf
# https://bugzilla.redhat.com/show_bug.cgi?id=2444143
%dir %{_sysconfdir}/systemd/system.conf.d
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this will be there until the systemd package actually starts to provide the system.conf.d directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I hope they will add it. If not, we can keep it. Even in case they add it and we forget to drop it, it will be still according to the Fedora packaging guidelines, because co-ownership of directories is allowed.

%verify(not size mtime md5) %{_sysconfdir}/systemd/system.conf.d/00-tuned.conf
%{_tmpfilesdir}/tuned.conf
%{_unitdir}/tuned.service
%dir %{_localstatedir}/log/tuned
Expand Down
8 changes: 6 additions & 2 deletions tuned/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,19 @@
DEF_CGROUP_MOUNT_POINT = "/sys/fs/cgroup/cpuset"
DEF_CGROUP_MODE = 0o770

# systemd paths used by multiple plugins
SYSTEMD_CFG_PATH = "/etc/systemd"

# service plugin configuration
SERVICE_SYSTEMD_CFG_PATH = "/etc/systemd/system/%s.service.d"
SERVICE_SYSTEMD_CFG_PATH = SYSTEMD_CFG_PATH + "/system/%s.service.d"
DEF_SERVICE_CFG_DIR_MODE = 0o755

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

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

# irqbalance plugin configuration
Expand Down
18 changes: 11 additions & 7 deletions tuned/plugins/plugin_systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class SystemdPlugin(base.Plugin):
Plug-in for tuning systemd options.
The [option]`cpu_affinity` option allows setting CPUAffinity in
`/etc/systemd/system.conf`. This configures the CPU affinity for the
service manager as well as the default CPU affinity for all forked
off processes. The option takes a comma-separated list of CPUs with
optional CPU ranges specified by the minus sign (`-`).
`/etc/systemd/system.conf.d/00-tuned.conf`. This configures the CPU
affinity for the service manager as well as the default CPU affinity
for all forked off processes. The option takes a comma-separated
list of CPUs with optional CPU ranges specified by the minus sign (`-`).
.Set the CPUAffinity for `systemd` to `0 1 2 3`
====
Expand All @@ -32,10 +32,15 @@ class SystemdPlugin(base.Plugin):
"""

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

def _instance_init(self, instance):
instance._has_dynamic_tuning = False
Expand Down Expand Up @@ -143,4 +148,3 @@ def _cmdline(self, enabling, value, verify, ignore_missing, instance):
self._write_systemd_system_conf(self._add_keyval(conf, consts.SYSTEMD_CPUAFFINITY_VAR, v_unpacked))
return True
return None

Loading