How to check if a performance profile is active in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to check if a performance profile is active in Linux using the tuned-adm command-line tool. This tool manages system performance by dynamically adjusting settings based on predefined profiles optimized for specific workloads.

You will explore how to identify the currently active tuned profile using tuned-adm active and tuned-adm status. You'll also learn how to interpret the output to determine which profile is active, or if no profile is active, and understand the importance of sudo privileges when executing these commands. Furthermore, you will learn how to verify sysctl settings with sysctl -a and inspect tuned config with cat /etc/tuned.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/BasicSystemCommandsGroup(["Basic System Commands"]) linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux(("Linux")) -.-> linux/TextProcessingGroup(["Text Processing"]) linux(("Linux")) -.-> linux/SystemInformationandMonitoringGroup(["System Information and Monitoring"]) linux(("Linux")) -.-> linux/UserandGroupManagementGroup(["User and Group Management"]) linux/BasicSystemCommandsGroup -.-> linux/echo("Text Display") linux/BasicFileOperationsGroup -.-> linux/ls("Content Listing") linux/BasicFileOperationsGroup -.-> linux/cat("File Concatenating") linux/TextProcessingGroup -.-> linux/grep("Pattern Searching") linux/SystemInformationandMonitoringGroup -.-> linux/service("Service Managing") linux/UserandGroupManagementGroup -.-> linux/sudo("Privilege Granting") subgraph Lab Skills linux/echo -.-> lab-558892{{"How to check if a performance profile is active in Linux"}} linux/ls -.-> lab-558892{{"How to check if a performance profile is active in Linux"}} linux/cat -.-> lab-558892{{"How to check if a performance profile is active in Linux"}} linux/grep -.-> lab-558892{{"How to check if a performance profile is active in Linux"}} linux/service -.-> lab-558892{{"How to check if a performance profile is active in Linux"}} linux/sudo -.-> lab-558892{{"How to check if a performance profile is active in Linux"}} end

Check profile with tuned-adm active

In this step, we'll explore how to check the currently active profile using tuned-adm. tuned-adm is a command-line tool used to manage system performance by dynamically adjusting system settings based on predefined profiles. These profiles optimize the system for specific workloads, such as throughput, latency, or power saving.

First, let's understand what a tuned profile is. A tuned profile is a collection of settings that optimize your system for a particular workload. These settings can include CPU frequency scaling, disk I/O scheduling, and network tuning parameters.

To check the currently active tuned profile, open your terminal. Remember, the terminal is your command center for interacting with the Linux system. You can find the Xfce Terminal icon on the left side of your desktop.

Now, type the following command and press Enter:

sudo tuned-adm active

This command queries the tuned daemon and displays the name of the active profile. You should see output similar to this:

Current active profile: virtual-guest

The output virtual-guest indicates that the virtual-guest profile is currently active. This profile is typically used for virtual machines and optimizes the system for virtualized environments.

If no profile is active, the output will be:

No current active profile.

It's important to note that you need sudo privileges to run tuned-adm commands because they modify system settings. sudo allows you to execute commands with administrative privileges.

Now, let's try another command to get more information about the tuned daemon:

sudo tuned-adm status

This command provides a more detailed status report, including the active profile, any applied tuning plugins, and any warnings or errors. The output might look like this:

Currently active profile: virtual-guest
plugin: (...)
(...)

The tuned-adm status command is useful for troubleshooting and verifying that the tuned daemon is functioning correctly.

By checking the active profile, you can ensure that your system is optimized for its intended use. If you need to switch to a different profile, you can use the tuned-adm profile command, which we'll explore in a later step.

Verify sysctl settings with sysctl -a

In this step, we'll use the sysctl command to view the current system settings. sysctl is a powerful tool that allows you to configure kernel parameters at runtime. These parameters control various aspects of the system's behavior, such as networking, memory management, and security.

Think of sysctl as a way to fine-tune your Linux system without having to reboot. It's like adjusting the settings on a car to optimize its performance.

To view all current sysctl settings, open your terminal and type the following command:

sudo sysctl -a

This command will display a long list of kernel parameters and their current values. The output will be similar to this:

kernel.domainname = (none)
kernel.osrelease = (...)
kernel.ostype = Linux
kernel.panic = 60
(...)
net.ipv4.ip_forward = 0
net.ipv4.tcp_rmem = 4096    131072  6291456
(...)
vm.swappiness = 60
vm.vfs_cache_pressure = 100

The output is structured as parameter = value. Each line represents a specific kernel parameter and its current setting.

Let's break down some of the common parameters you might see:

  • kernel.domainname: The domain name of the system.
  • net.ipv4.ip_forward: Controls IP forwarding (routing) for IPv4. A value of 0 disables forwarding, while 1 enables it.
  • vm.swappiness: Defines how aggressively the kernel will swap memory pages to disk. A lower value reduces swapping, while a higher value increases it.
  • vm.vfs_cache_pressure: Controls how aggressively the kernel reclaims memory used for caching directory and inode information.

You can use grep to filter the output and find specific settings. For example, to find the value of vm.swappiness, you can use the following command:

sudo sysctl -a | grep vm.swappiness

This will display only the line containing vm.swappiness:

vm.swappiness = 60

The sysctl -a command is a valuable tool for understanding the current configuration of your Linux system. It allows you to inspect a wide range of kernel parameters and identify potential areas for optimization.

In later steps, we'll explore how to modify these settings using sysctl and how tuned profiles can automate this process.

Inspect tuned config with cat /etc/tuned

In this step, we'll examine the tuned configuration files located in the /etc/tuned directory. These files define the various profiles that tuned uses to optimize system performance.

The tuned configuration is organized into profiles, each represented by a subdirectory within /etc/tuned. Each profile directory contains an tuned.conf file that specifies the tuning parameters for that profile.

To view the contents of the /etc/tuned directory, open your terminal and type the following command:

ls /etc/tuned

This command will list the available tuned profiles. You should see output similar to this:

acceleratorcard  desktop  latency-performance  network-latency  network-throughput  powersave  profile_includes  README  throughput-performance  virtual-guest  virtual-host

These are the names of the different profiles that tuned can activate. Each profile is designed for a specific type of workload or environment.

Now, let's inspect the configuration file for the virtual-guest profile, which we identified as the active profile in the first step. To view the contents of the tuned.conf file for the virtual-guest profile, use the following command:

cat /etc/tuned/virtual-guest/tuned.conf

This command will display the contents of the tuned.conf file. The output will be a text file containing various configuration settings. The file is divided into sections, each defining a set of tuning parameters.

[main]
include = virtual-server

[sysctl]
vm.swappiness = 30

[vm]
transparent_hugepages = never

Let's break down the key sections:

  • [main]: This section defines general settings for the profile, such as which other profiles to include. In this case, it includes the virtual-server profile, meaning it inherits settings from that profile as well.
  • [sysctl]: This section defines sysctl parameters to be set when the profile is activated. In this example, it sets vm.swappiness to 30. This reduces the tendency of the system to swap memory to disk, which can improve performance in virtualized environments.
  • [vm]: This section defines virtual memory settings. In this example, it disables transparent hugepages, which can improve memory management in some virtualized environments.

You can explore the configuration files for other profiles to see how they differ. For example, the throughput-performance profile might prioritize disk I/O performance, while the powersave profile might focus on reducing power consumption.

By inspecting the tuned configuration files, you can gain a deeper understanding of how tuned optimizes your system for different workloads. This knowledge can be valuable for troubleshooting performance issues and customizing your system for specific needs.

Summary

In this lab, we learned how to check the currently active performance profile in Linux using the tuned-adm command-line tool. We used sudo tuned-adm active to identify the active profile, which optimizes the system for specific workloads. The output displays the name of the active profile, such as virtual-guest, or indicates if no profile is active.

Furthermore, we explored the sudo tuned-adm status command to obtain a more detailed status report, including the active profile, applied tuning plugins, and any warnings or errors. This provides a comprehensive overview of the tuned daemon's configuration and operation.