Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

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.*

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Advanced
Duration
Clock icon 45m
Published
Clock icon Jun 30, 2021

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Manage CPU Affinity Using a PID or Process Name

    1. Install the tuna package.
    2. Launch the affinity.sh script in the background.
      • The script spawns a dd process in the background.
    3. Use tuna to show open threads, filtering for dd.
      • Make note of the current thread affinity.
    4. Use tuna to move the dd instance to CPU 0.
    5. Confirm the process has moved using tuna, filtering for dd.
      • Verify the current thread affinity is set to 0.
    6. Kill the dd process.
  2. Challenge

    Manage CPU Affinity Using Systemd

    1. Enable and start the evodd service.
      • The service spawns a dd process in the background.
    2. Use systecmctl to create an override file for the evodd service.
      • Under [Service], and an entry CPUAffinity and set the value to CPU 0.
      • Execute the daemon-reload.
      • Cycle the evodd service.
    3. Confirm the process has moved using tuna, filtering for dd.
      • Verify the current thread affinity is set to 0.
    4. Stop and disable the evodd service.
  3. Challenge

    Review the System's Hugepages Configuration

    1. Check for any kernel configurations.
      • Check the values in /proc/cmdline.
      • Check the grub configuration file.
    2. Review the current hugepages values.
      • Review the values in /proc/meminfo.
      • Check the values using sysctl.
    3. Determine if transparent hugepages are enabled.
      • Check the value of /sys/kernel/mm/transparent_hugepage/enabled.
  4. Challenge

    Configure a Hugepages Value and Disable Transparent Hugepages

    1. 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.
    2. 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.
      • 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.
    3. Option 3: Use tuned to manage hugepages.
      • Create a tuned profile called huge_profile.
      • Create the configuration file and open it for editing.
        • Create the [main] section and include the virtual-guest profile.
        • To enable huge pages, go to the [sysctl] section, add the vm.nr_hugepages entry and set the value to 10.
        • To disable transparent huge pages, add a section called [vm], add an entry called transparent_hugepages and set the value to never.
      • 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.
      • Validate the changes on the system.
    4. Review the current hugepages values.
      • Review the values in /proc/meminfo.
      • Check the values using sysctl.
    5. Confirm transparent hugepages are disabled.
    6. This will be the option focused on for the lab.
  5. Challenge

    Reboot the Lab and Confirm Changes Persist

    1. Verify the custom profile is active.
    2. Validate the changes on the system.
      • Review the current hugepages values.
        • Review the values in /proc/meminfo.
        • Check the values using sysctl.
      • Confirm transparent hugepages are disabled.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans