Skip to content

Commit

Permalink
Migrate profiles to /etc/tuned/profiles/ and /usr/lib/tuned/profiles/
Browse files Browse the repository at this point in the history
  • Loading branch information
zacikpa committed Apr 3, 2024
1 parent 1fb7c80 commit 6d3aa94
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 94 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ifeq ($(PYTHON_SITELIB),)
$(error Failed to determine python library directory)
endif
KERNELINSTALLHOOKDIR = /usr/lib/kernel/install.d
TUNED_PROFILESDIR = /usr/lib/tuned
TUNED_PROFILESDIR = /usr/lib/tuned/profiles
TUNED_RECOMMEND_DIR = $(TUNED_PROFILESDIR)/recommend.d
TUNED_USER_RECOMMEND_DIR = $(SYSCONFDIR)/tuned/recommend.d
BASH_COMPLETIONS = $(DATADIR)/bash-completion/completions
Expand Down Expand Up @@ -134,6 +134,7 @@ install-dirs:
mkdir -p $(DESTDIR)/run/tuned
mkdir -p $(DESTDIR)$(DOCDIR)
mkdir -p $(DESTDIR)$(SYSCONFDIR)
mkdir -p $(DESTDIR)$(SYSCONFDIR)/tuned/profiles
mkdir -p $(DESTDIR)$(TUNED_RECOMMEND_DIR)
mkdir -p $(DESTDIR)$(TUNED_USER_RECOMMEND_DIR)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include=[replaceable]_parent_

All settings from the [replaceable]_parent_ profile are loaded in this _child_ profile. In the following sections, the _child_ profile can override certain settings inherited from the [replaceable]_parent_ profile or add new settings not present in the [replaceable]_parent_ profile.

You can create your own _child_ profile in the [filename]`/etc/tuned/` directory based on a pre-installed profile in [filename]`/usr/lib/tuned/` with only some parameters adjusted.
You can create your own _child_ profile in the [filename]`/etc/tuned/profiles/` directory based on a pre-installed profile in [filename]`/usr/lib/tuned/profiles/` with only some parameters adjusted.

If the [replaceable]_parent_ profile is updated, such as after a *TuneD* upgrade, the changes are reflected in the _child_ profile.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
[role="_abstract"]
*TuneD* stores profiles in the following directories:

[filename]`/usr/lib/tuned/`::
Distribution-specific profiles are stored in the [filename]`/usr/lib/tuned/` directory. Each profile has its own directory. The profile consists of the main configuration file called `tuned.conf`, and optionally other files, for example helper scripts.
[filename]`/usr/lib/tuned/profiles/`::
Distribution-specific profiles are stored in the [filename]`/usr/lib/tuned/profiles/` directory. Each profile has its own directory. The profile consists of the main configuration file called `tuned.conf`, and optionally other files, for example helper scripts.

[filename]`/etc/tuned/`::
If you need to customize a profile, copy the profile directory into the [filename]`/etc/tuned/` directory, which is used for custom profiles, and then adjust it. If there is a system profile and a custom profile of the same name, the custom profile located in [filename]`/etc/tuned/` is used.
[filename]`/etc/tuned/profiles/`::
If you need to customize a profile, copy the profile directory into the [filename]`/etc/tuned/profiles/` directory, which is used for custom profiles, and then adjust it. If there is a system profile and a custom profile of the same name, the custom profile located in [filename]`/etc/tuned/profiles` is used.

.User-defined profile directories
====
If you want to make TuneD load profiles from a directory other than [filename]`/usr/lib/tuned/` and [filename]`/etc/tuned/`, you can list it in [filename]`/etc/tuned/tuned-main.conf` as follows:
If you want to make TuneD load profiles from a directory other than [filename]`/usr/lib/tuned/profiles/` and [filename]`/etc/tuned/profiles/`, you can list it in [filename]`/etc/tuned/tuned-main.conf` as follows:
----
profile_dirs=/usr/lib/tuned,/etc/tuned,/my/custom/profiles
profile_dirs=/usr/lib/tuned/profiles,/etc/tuned/profiles,/my/custom/profiles
----
In this example, profiles are loaded also from [filename]`/my/custom/profiles/`. If two directories contain profiles with the same names, the one that is listed later takes precedence.
====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ endif::[]

.Procedure

. In the [filename]`/etc/tuned/` directory, create a new directory named the same as the profile that you want to create:
. In the [filename]`/etc/tuned/profiles/` directory, create a new directory named the same as the profile that you want to create:
+
[subs=+quotes]
----
# mkdir /etc/tuned/[replaceable]_my-profile_
# mkdir /etc/tuned/profiles/[replaceable]_my-profile_
----

. In the new directory, create a file named [filename]`tuned.conf`. Add a `[main]` section and plug-in definitions in it, according to your requirements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ endif::[]

.Procedure

. In the [filename]`/etc/tuned/` directory, create a new directory named the same as the profile that you want to create:
. In the [filename]`/etc/tuned/profiles/` directory, create a new directory named the same as the profile that you want to create:
+
[subs=+quotes]
----
# mkdir /etc/tuned/[replaceable]_modified-profile_
# mkdir /etc/tuned/profiles/[replaceable]_modified-profile_
----

. In the new directory, create a file named [filename]`tuned.conf`, and set the `[main]` section as follows:
Expand Down Expand Up @@ -75,13 +75,13 @@ See TuneD log file ('/var/log/tuned/tuned.log') for details.
----
// .An alternative approach
// . Alternatively, copy the directory with a system profile from /user/lib/tuned/ to /etc/tuned/. For example:
// . Alternatively, copy the directory with a system profile from /usr/lib/tuned/profiles/ to /etc/tuned/profiles/. For example:
// +
// ----
// # cp -r /usr/lib/tuned/throughput-performance /etc/tuned
// # cp -r /usr/lib/tuned/profiles/throughput-performance /etc/tuned/profiles
// ----
//
// . Then, edit the profile in /etc/tuned according to your needs. Note that if there are two profiles of the same name, the profile located in /etc/tuned/ is loaded. The disadvantage of this approach is that if a system profile is updated after a TuneD upgrade, the changes will not be reflected in the now-outdated modified version.
// . Then, edit the profile in /etc/tuned/profiles/ according to your needs. Note that if there are two profiles of the same name, the profile located in /etc/tuned/profiles/ is loaded. The disadvantage of this approach is that if a system profile is updated after a TuneD upgrade, the changes will not be reflected in the now-outdated modified version.
[role="_additional-resources"]
.Additional resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $ tuned-adm active
+
[subs=+quotes]
----
# mkdir /etc/tuned/[replaceable]__my-profile__
# mkdir /etc/tuned/profiles/[replaceable]__my-profile__
----

. Find the system unique identifier of the selected block device:
Expand All @@ -83,7 +83,7 @@ ID_SERIAL_SHORT=_20120501030900000_
The command in the this example will return all values identified as a World Wide Name (WWN) or serial number associated with the specified block device. Although it is preferred to use a WWN, the WWN is not always available for a given device and any values returned by the example command are acceptable to use as the _device system unique ID_.
====

. Create the `/etc/tuned/_my-profile_/tuned.conf` configuration file. In the file, set the following options:
. Create the `/etc/tuned/profiles/[replaceable]_my-profile_/tuned.conf` configuration file. In the file, set the following options:

.. Optional: Include an existing profile:
+
Expand Down
4 changes: 2 additions & 2 deletions man/tuned-adm.8
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ This command line utility allows you to switch between user definable tuning
profiles. Several predefined profiles are already included. You can even
create your own profile, either based on one of the existing ones by copying
it or make a completely new one. The distribution provided profiles are stored
in subdirectories below \fI/usr/lib/tuned\fP and the user defined profiles in
subdirectories below \fI/etc/tuned\fP. If there are profiles with the same name
in subdirectories below \fI/usr/lib/tuned/profiles/\fP and the user defined profiles in
subdirectories below \fI/etc/tuned/profiles/\fP. If there are profiles with the same name
in both places, user defined profiles have precedence.

.SH "OPTIONS"
Expand Down
10 changes: 5 additions & 5 deletions man/tuned-profiles.7
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ performance optimizations but there are also profiles targeted to
low power consumption, low latency and others. You can mostly deduce the
purpose of the profile by its name or you can see full description below.

The profiles are stored in subdirectories below \fI/usr/lib/tuned\fP. If you
need to customize the profiles, you can copy them to \fI/etc/tuned\fP and modify
them as you need. When loading profiles with the same name, the /etc/tuned takes
The profiles are stored in subdirectories below \fI/usr/lib/tuned/profiles/\fP. If you
need to customize the profiles, you can copy them to \fI/etc/tuned/profiles/\fP and modify
them as you need. When loading profiles with the same name, \fI/etc/tuned/profiles/\fP takes
precedence. In such case you will not lose your customized profiles between
TuneD updates.

Expand Down Expand Up @@ -143,8 +143,8 @@ throughput\-performance profile.

.SH "FILES"
.nf
.I /etc/tuned/*
.I /usr/lib/tuned/*
.I /etc/tuned/profiles/*
.I /usr/lib/tuned/profiles/*

.SH "SEE ALSO"
.BR tuned (8)
Expand Down
4 changes: 2 additions & 2 deletions man/tuned.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
tuned.conf - TuneD profile definition
.SH DESCRIPTION
This man page documents format of TuneD 2.0 profile definition files.
The profile definition is stored in /etc/tuned/<profile_name>/tuned.conf or in
/usr/lib/tuned/<profile_name>/tuned.conf file where the /etc/tuned/ directory has
The profile definition is stored in /etc/tuned/profiles/<profile_name>/tuned.conf or in
/usr/lib/tuned/profiles/<profile_name>/tuned.conf file where the /etc/tuned/profiles/ directory has
higher priority.

The \fBtuned.conf\fR configures the profile and it is in ini-file format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
. /usr/share/beakerlib/beakerlib.sh || exit 1

PACKAGE="tuned"
PROFILE_DIR="/etc/tuned/profiles"

rlJournalStart
rlPhaseStartSetup
Expand All @@ -31,15 +32,15 @@ rlJournalStart
rlFileBackup "/etc/tuned/active_profile"
rlFileBackup "/etc/tuned/profile_mode"

rlRun "mkdir /etc/tuned/test-profile"
rlRun "mkdir $PROFILE_DIR/test-profile"
rlServiceStart "tuned"
sleep 1
rlFileBackup "/var/log/tuned/tuned.log"
rlRun "rm -rf /var/log/tuned/tuned.log"
rlPhaseEnd

rlPhaseStartTest
rlRun "pushd /etc/tuned/test-profile"
rlRun "pushd $PROFILE_DIR/test-profile"
cat << EOF > tuned.conf
[scheduler]
runtime=0
Expand Down Expand Up @@ -67,7 +68,7 @@ EOF
rlFileRestore

rlServiceRestore "tuned"
rlRun "rm -rf /etc/tuned/test-profile"
rlRun "rm -rf $PROFILE_DIR/test-profile"
rlPhaseEnd

rlJournalPrintText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
. /usr/share/beakerlib/beakerlib.sh || exit 1

PACKAGE="tuned"
PROFILE_DIR=/etc/tuned
ACTIVE_PROFILE=/etc/tuned/active_profile
PROFILE_MODE=/etc/tuned/profile_mode
POST_LOADED_PROFILE=/etc/tuned/post_loaded_profile
SYSCONF_DIR=/etc/tuned
PROFILE_DIR=$SYSCONF_DIR/profiles
ACTIVE_PROFILE=$SYSCONF_DIR/active_profile
PROFILE_MODE=$SYSCONF_DIR/profile_mode
POST_LOADED_PROFILE=$SYSCONF_DIR/post_loaded_profile
SWAPPINESS=vm.swappiness
DIRTY_RATIO=vm.dirty_ratio
PID_FILE=/run/tuned/tuned.pid
Expand Down Expand Up @@ -64,7 +65,7 @@ rlJournalStart
rlImport "tuned/basic"
tunedDisableSystemdRateLimitingStart
rlRun "for PYTHON in $PYTHON_CHECK; do \$PYTHON --version 2>/dev/null && break; done" 0 "Detect python"
rlRun "rlFileBackup --clean $PROFILE_DIR"
rlRun "rlFileBackup --clean $SYSCONF_DIR"
rlRun "cp -r parent $PROFILE_DIR"
rlRun "cp -r parent2 $PROFILE_DIR"
rlRun "cp -r parent-vars $PROFILE_DIR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
. /usr/share/beakerlib/beakerlib.sh || exit 1

PACKAGE="tuned"
PROFILE_DIR=/etc/tuned/profiles

rlJournalStart
rlPhaseStartSetup
Expand All @@ -28,8 +29,8 @@ rlJournalStart
rlServiceStart "tuned"
tunedProfileBackup

rlRun "mkdir /etc/tuned/test-profile"
rlRun "pushd /etc/tuned/test-profile"
rlRun "mkdir $PROFILE_DIR/test-profile"
rlRun "pushd $PROFILE_DIR/test-profile"
cat << EOF > tuned.conf
[sysctl]
kernel.sem = 1250 256000 100 8192
Expand Down Expand Up @@ -63,7 +64,7 @@ EOF
tunedProfileRestore
rlServiceRestore "tuned"

rlRun "rm -rf /etc/tuned/test-profile"
rlRun "rm -rf $PROFILE_DIR/test-profile"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
5 changes: 3 additions & 2 deletions tests/beakerlib/error-messages/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
. /usr/share/beakerlib/beakerlib.sh || exit 1

PACKAGE="tuned"
PROFILE_DIR="/usr/lib/tuned/profiles"

rlJournalStart
rlPhaseStartSetup
Expand All @@ -29,7 +30,7 @@ rlJournalStart
rlPhaseEnd

rlPhaseStartTest "Test of profile balanced"
rlRun "cat /usr/lib/tuned/balanced/tuned.conf | grep alpm="
rlRun "cat $PROFILE_DIR/balanced/tuned.conf | grep alpm="
echo > /var/log/tuned/tuned.log
rlRun "tuned-adm profile balanced"
rlRun "tuned-adm active | grep balanced"
Expand All @@ -38,7 +39,7 @@ rlJournalStart
rlPhaseEnd

rlPhaseStartTest "Test of profile powersave"
rlRun "cat /usr/lib/tuned/powersave/tuned.conf | grep alpm="
rlRun "cat $PROFILE_DIR/powersave/tuned.conf | grep alpm="
echo > /var/log/tuned/tuned.log
rlRun "tuned-adm profile powersave"
rlRun "tuned-adm active | grep powersave"
Expand Down
7 changes: 4 additions & 3 deletions tests/beakerlib/variables-support-in-profiles/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
. /usr/share/beakerlib/beakerlib.sh || exit 1

PACKAGE="tuned"
PROFILE_DIR="/usr/lib/tuned/profiles"

rlJournalStart
rlPhaseStartSetup
Expand All @@ -28,7 +29,7 @@ rlJournalStart
rlRun "pushd $TmpDir"
rlServiceStart "tuned"
tunedProfileBackup
rlFileBackup "/usr/lib/tuned/balanced/tuned.conf"
rlFileBackup "$PROFILE_DIR/balanced/tuned.conf"

echo "
[variables]
Expand All @@ -37,9 +38,9 @@ SWAPPINESS2 = \${SWAPPINESS1}
[sysctl]
vm.swappiness = \${SWAPPINESS2}
" >> /usr/lib/tuned/balanced/tuned.conf
" >> "$PROFILE_DIR/balanced/tuned.conf"

rlRun "cat /usr/lib/tuned/balanced/tuned.conf"
rlRun "cat $PROFILE_DIR/balanced/tuned.conf"

OLD_SWAPPINESS=$(sysctl -n vm.swappiness)

Expand Down
2 changes: 1 addition & 1 deletion tuned-adm.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _tuned_adm()
if [[ "$cword" -eq 1 ]]; then
COMPREPLY=( $(compgen -W "$commands" -- "$cur" ) )
elif [[ "$cword" -eq 2 && ("$prev" == "profile" || "$prev" == "profile_info") ]]; then
COMPREPLY=( $(compgen -W "$(command find /usr/lib/tuned /etc/tuned -mindepth 1 -maxdepth 1 -type d -printf "%f\n")" -- "$cur" ) )
COMPREPLY=( $(compgen -W "$(command find /usr/lib/tuned/profiles /etc/tuned/profiles -mindepth 1 -maxdepth 1 -type d -printf "%f\n")" -- "$cur" ) )
else
COMPREPLY=()
fi
Expand Down
2 changes: 1 addition & 1 deletion tuned-main.conf
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ log_file_max_size = 1MB
# Directories to search for profiles separated by , or ;
# In case of conflicts in profile names, the later directory
# takes precedence
# profile_dirs = /usr/lib/tuned,/etc/tuned
# profile_dirs = /usr/lib/tuned/profiles,/etc/tuned/profiles
Loading

0 comments on commit 6d3aa94

Please sign in to comment.