How to create a custom tuned profile in Red Hat Enterprise Linux?
Environment
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
- Red Hat Enterprise Linux 10
- Tuned
Issue
- What is the proper method for creating a new custom tuned profile in Red Hat Enterprise Linux?
- Although there are a number of different profiles within tuned, there may be a need for a customized profile that meets a specific tuning case.
Resolution
The steps to create a custom tuned profile varies based on the different RHEL version. There are different section created below for same:
- Creating a custom tuned profile in RHEL 6
- Creating a custom tuned profile in RHEL 7, RHEL 8 and RHEL 9
- Creating a custom tuned profile in RHEL 10
Steps to create a custom tuned profile in RHEL 6
The following steps could be used to create a custom tuned profile that would change the disk IO scheduler to deadline. More information available in the Red Hat's Performance Tuning Guides for 6.
-
Locate the tuned profile directory:
# cd /etc/tune-profiles -
Find a profile that closely matches the desired tuning (for example, "throughput-performance") and copy its contents into new directory for example "throughput-performance-custom":
# cp -rp throughput-performance throughput-performance-custom # cd throughput-performance-custom -
Make any required changes to the profile. For example, change the disk elevator from
cfqtodeadline:# vi ktune.sysconfig ELEVATOR="deadline"
-
Longer version of the example customized
tuned.confwith a call-out to an external script:# vi /etc/tuned/myprofile/tuned.conf [main] include=throughput-performance [cpu] force_latency=1 [vm] transparent_hugepages=never [disk] elevator=deadline [sysctl] kernel.sysrq=1 sysctl vm.nr_hugepages=4100 kernel.numa_balancing=0 [script] script=/etc/tuned/myprofile/myscript.sh -
The content of an example
myscript.shscript:#!/bin/sh OPERATION=$1 if [ $OPERATION -eq "start" ]; then touch /tmp/$OPERATION else touch /tmp/$OPERATION fi -
See the Red Hat Power Management Guide for more information on script functionality.
Steps to create a custom tuned profile in RHEL 7, RHEL 8 and RHEL 9
-
The tuned in RHEL 7 has been largely re-written and significantly extended to provide additional functionality and capabilities. Profiles have also been updated to account for new features delivered in RHEL 7. Please see Red Hat's Performance Tuning Guide for more information on tuned.
-
One of the most visible changes is the consolidation of configuration files from a set of 4 down to a single
tuned.conffile. The location of tuned profiles has also moved from/etc/tune-profilesto/usr/lib/tuned:./balanced/tuned.conf ./desktop/tuned.conf ./latency-performance/tuned.conf ./powersave/script.sh ./powersave/tuned.conf ./throughput-performance/tuned.conf ./virtual-guest/tuned.conf ./virtual-host/tuned.conf ./network-latency/tuned.conf ./network-throughput/tuned.conf -
When creating a custom tuned profile, it is important to understand tuned's RPM SPEC file and new 'inheritance' feature. Profiles that Red Hat ships currently have this relationship:
-
Tuned's RPM spec file intentionally does not mark profile
tuned.conffiles as local configuration files. This means that if the profiles included with tuned is to be adjusted, any local updates totuned.conffiles will be overwritten when the tuned RPM is updated via an errata. Tuned's new inheritance capability allows to 'include' an existing profile, then adjust and tune it further based on the workload requirement. -
Because of this, Red Hat recommends to avoid making local changes to the profiles that Red Hat ships, and instead create a new profile which either 'includes' one that Red Hat ships, or breaks inheritance entirely.
-
For example, using the
throughput-performanceprofile as a starting point, make several additional tunings:- limit C-state usage to C1
- disable transparent hugepages
- enable all sysrq functionality
- allocate 4100 2MB static hugepages
- disable automatic numa balancing
- run an arbitrary shell script
Here are the 3 steps required to create a new tuned profile:
-
Create a new directory to hold the new profile:
# mkdir /etc/tuned/myprofile -
Create a new
tuned.conffile formyprofile, and insert the new tuning info:# cat /etc/tuned/myprofile/tuned.conf [main] include=throughput-performance [cpu] force_latency=1 [vm] transparent_hugepages=never [sysctl] kernel.sysrq=1 vm.nr_hugepages=4100 kernel.numa_balancing=0 [script] script=/etc/tuned/myprofile/myscript.sh [sysfs] /sys/bus/workqueue/devices/writeback/cpumask = 1- Note: It is not necessary to have all the plugins defined in the above file, it should be based on requirement. The above one is just a example.
i. The content of an example
myscripts.sh:#!/bin/sh OPERATION=$1 if [ $OPERATION -eq "start" ]; then touch /tmp/$OPERATION else touch /tmp/$OPERATION fiii. Make the script executable:
# chmod +x /etc/tuned/myprofile/myscript.shiii. See the Red Hat Power Management Guide for more information on script functionality.
-
Enable
myprofileusing:# tuned-adm profile myprofile- Note: This change will immediately take effect and persist reboots.
-
To simply create a custom tuned profile without inheritance, follow the same above procedure but skip the
[main]andinclude=statements in the new profile. This will break any inheritance with the shipped profiles. -
Profiles under the
/etc/tunedwill not get overwritten by updates, and profiles in/etc/tunedtakes precedence over profiles in/usr/lib/tuned. -
Some example use-cases for creating own tuned profiles could be:
- Database server vendor recommends a different value for
vm.swappiness. - Web server/middleware that performs best with
tcp_tw_reuse=1. - Application that opens a large number of files and may exceed the default values of the kernel (i.e.
fs.file-maxorfs.file-nr). - Affine VM writeback threads to core 0.
- Database server vendor recommends a different value for
Steps to create a custom tuned profile in RHEL 10
-
The tuned profile location has been changed in RHEL 10 release compared to previous releases.
-
The distribution provided profiles are now stored in subdirectories below
/usr/lib/tuned/profiles/and the user defined profiles in subdirectories below/etc/tuned/profiles/. -
For example to create a new custom profile with name "my_workload":
-
Create a directory with the profile name under the path
/etc/tuned/profiles/:# mkdir /etc/tuned/profiles/my_workload -
Create a new file with name
tuned.confunder the above directory and modify it as per the requirement. For example, inherit existing profiles, modify sysctls, vm, etc plugins:# vi /etc/tuned/profiles/my_workload/tuned.conf [main] summary=Optimize for running custom application include=throughput-performance [vm] dirty_ratio = 10 [sysctl] vm.swappiness = 1 -
Active the new "my_workload" profile:
# tuned-adm profile my_workload
-
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.