- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
Tuning CPUs and Hugepages on a Linux System
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.*
Lab Info
Table of Contents
-
Challenge
Manage CPU Affinity Using a PID or Process Name
- Install the
tunapackage. - Launch the
affinity.shscript in the background.- The script spawns a
ddprocess 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
ddinstance 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
ddprocess.
- Install the
-
Challenge
Manage CPU Affinity Using Systemd
- Enable and start the
evoddservice.- The service spawns a
ddprocess in the background.
- The service spawns a
- Use
systecmctlto create an override file for theevoddservice.- Under
[Service], and an entryCPUAffinityand set the value to CPU 0. - Execute the
daemon-reload. - Cycle the
evoddservice.
- 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
evoddservice.
- Enable and start the
-
Challenge
Review the System's Hugepages Configuration
- Check for any kernel configurations.
- Check the values in
/proc/cmdline. - Check the
grubconfiguration 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.
-
Challenge
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
grubconfiguration.- Edit
/etc/default/grub. - Scroll down to the
GRUB_CMDLINE_LINUXrow 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
grubupdates steps, then reboot the system to pick up the changes. - Not the final solution for the lab.
- Edit
- Option 3: Use
tunedto manage hugepages.- Create a
tunedprofile calledhuge_profile. - Create the configuration file and open it for editing.
- Create the
[main]section andincludethevirtual-guestprofile. - To enable huge pages, go to the
[sysctl]section, add thevm.nr_hugepagesentry and set the value to10. - To disable transparent huge pages, add a section called
[vm], add an entry calledtransparent_hugepagesand set the value tonever.
- Create the
- Enable and validate the custom profile.
- Using the appropriate
tunedcommand, enable the profile. - Verify the profile has been loaded and settings applied using the appropriate
tunedcommand.
- 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
-
Challenge
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.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.