This hands-on lab will focus on CPU tuning and configuring `hugepages` on a lab system. You will be using `tuna` to view open CPU threads, filtering the output for a specific script, then isolating the script to a specific CPU. When CPU tuning is complete, you will set a value for `hugepages` and disable transparent `hugepages`, then confirm the changes after loading the new configuration.
*This course is not approved or sponsored by Red Hat.*
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Manage CPU Affinity Using a PID or Process Name
- Install the
tuna
package. - Launch the
affinity.sh
script in the background.- The script spawns a
dd
process in the background.
- The script spawns a
- Use tuna to show open threads, filtering for
dd
.- Make note of the current thread affinity.
- Use tuna to move the
dd
instance to CPU 0. - Confirm the process has moved using
tuna
, filtering fordd
.- Verify the current thread affinity is set to
0
.
- Verify the current thread affinity is set to
- Kill the
dd
process.
- Install the
- Manage CPU Affinity Using Systemd
- Enable and start the
evodd
service.- The service spawns a
dd
process in the background.
- The service spawns a
- Use
systecmctl
to create an override file for theevodd
service.- Under
[Service]
, and an entryCPUAffinity
and set the value to CPU 0. - Execute the
daemon-reload
. - Cycle the
evodd
service.
- Under
- Confirm the process has moved using
tuna
, filtering fordd
.- Verify the current thread affinity is set to
0
.
- Verify the current thread affinity is set to
- Stop and disable the
evodd
service.
- Enable and start the
- Review the System’s Hugepages Configuration
- Check for any kernel configurations.
- Check the values in
/proc/cmdline
. - Check the
grub
configuration file.
- Check the values in
- Review the current hugepages values.
- Review the values in
/proc/meminfo
. - Check the values using
sysctl
.
- Review the values in
- Determine if transparent hugepages are enabled.
- Check the value of
/sys/kernel/mm/transparent_hugepage/enabled
.
- Check the value of
- Check for any kernel configurations.
- Configure a Hugepages Value and Disable Transparent Hugepages
- Option 1: Create a control file in
/etc/sysctl.d/
.- Enter new hugepages value.
- Save the file.
- Load changes using
sysctl -p
- Not the solution used in this lab.
- Option 2: Add the kernel options to the
grub
configuration.- Edit
/etc/default/grub
. - Scroll down to the
GRUB_CMDLINE_LINUX
row in the file.- To enable and set the number of hugepages, scroll to the end of the line and add
hugepages=
, followed by the value. - To set the default hugepages size, you can added
default_hugepagesz=
. - To disable transparent hugepages, you would add
transparent_hugepages=never
.
- To enable and set the number of hugepages, scroll to the end of the line and add
- Save the file and complete the
grub
updates steps, then reboot the system to pick up the changes. - Not the final solution for the lab.
- Edit
- Option 3: Use
tuned
to manage hugepages.- Create a
tuned
profile calledhuge_profile
. - Create the configuration file and open it for editing.
- Create the
[main]
section andinclude
thevirtual-guest
profile. - To enable huge pages, go to the
[sysctl]
section, add thevm.nr_hugepages
entry and set the value to10
. - To disable transparent huge pages, add a section called
[vm]
, add an entry calledtransparent_hugepages
and set the value tonever
.
- Create the
- Enable and validate the custom profile.
- Using the appropriate
tuned
command, enable the profile. - Verify the profile has been loaded and settings applied using the appropriate
tuned
command.
- Using the appropriate
- Validate the changes on the system.
- Create a
- Review the current hugepages values.
- Review the values in
/proc/meminfo
. - Check the values using
sysctl
.
- Review the values in
- Confirm transparent hugepages are disabled.
- This will be the option focused on for the lab.
- Option 1: Create a control file in
- Reboot the Lab and Confirm Changes Persist
- Verify the custom profile is active.
- Validate the changes on the system.
- Review the current hugepages values.
- Review the values in
/proc/meminfo
. - Check the values using
sysctl
.
- Review the values in
- Confirm transparent hugepages are disabled.
- Review the current hugepages values.