Chapter 4. Reviewing a system using tuna interface
Use the tuna tool to adjust scheduler tunables, tune thread priority, IRQ handlers, and isolate CPU cores and sockets. Tuna reduces the complexity of performing tuning tasks.
The tuna tool performs the following operations:
- Lists the CPUs on a system
- Lists the interrupt requests (IRQs) currently running on a system
- Changes policy and priority information about threads
- Displays the current policies and priorities of a system
4.1. Installing the tuna tool Copy linkLink copied to clipboard!
The tuna tool is designed to be used on a running system. This allows application-specific measurement tools to see and analyze system performance immediately after changes have been made.
Procedure
Install the
tunatool:yum install tuna
# yum install tunaCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Display the available
tunaCLI options:tuna -h
# tuna -hCopy to Clipboard Copied! Toggle word wrap Toggle overflow
4.2. Viewing the system status using tuna tool Copy linkLink copied to clipboard!
This procedure describes how to view the system status using the tuna command-line interface (CLI) tool.
Prerequisites
- The tuna tool is installed. For more information, see Installing tuna tool.
Procedure
To view the current policies and priorities:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To view a specific thread corresponding to a PID or matching a command name:
tuna --threads=pid_or_cmd_list --show_threads
# tuna --threads=pid_or_cmd_list --show_threadsCopy to Clipboard Copied! Toggle word wrap Toggle overflow The pid_or_cmd_list argument is a list of comma-separated PIDs or command-name patterns.
-
To tune CPUs using the
tunaCLI, see Tuning CPUs using tuna tool. -
To tune the IRQs using the
tunatool, see Tuning IRQs using tuna tool. To save the changed configuration:
tuna --save=filename
# tuna --save=filenameCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command saves only currently running kernel threads. Processes that are not running are not saved.
4.3. Tuning CPUs using tuna tool Copy linkLink copied to clipboard!
The tuna tool commands can target individual CPUs.
Using the tuna tool, you can:
Isolate CPUs- All tasks running on the specified CPU move to the next available CPU. Isolating a CPU makes it unavailable by removing it from the affinity mask of all threads.
Include CPUs- Allows tasks to run on the specified CPU
Restore CPUs- Restores the specified CPU to its previous configuration.
This procedure describes how to tune CPUs using the tuna CLI.
Prerequisites
- The tuna tool is installed. For more information, see Installing tuna tool.
Procedure
To specify the list of CPUs to be affected by a command:
tuna --cpus=cpu_list [command]
# tuna --cpus=cpu_list [command]Copy to Clipboard Copied! Toggle word wrap Toggle overflow The cpu_list argument is a list of comma-separated CPU numbers. For example,
--cpus=0,2. CPU lists can also be specified in a range, for example--cpus=”1-3”, which would select CPUs 1, 2, and 3.To add a specific CPU to the current cpu_list, for example, use
--cpus=+0.Replace [command] with, for example,
--isolate.To isolate a CPU:
tuna --cpus=cpu_list --isolate
# tuna --cpus=cpu_list --isolateCopy to Clipboard Copied! Toggle word wrap Toggle overflow To include a CPU:
tuna --cpus=cpu_list --include
# tuna --cpus=cpu_list --includeCopy to Clipboard Copied! Toggle word wrap Toggle overflow To use a system with four or more processors, display how to make all the ssh threads run on CPU 0 and 1, and all the
httpthreads on CPU 2 and 3:tuna --cpus=0,1 --threads=ssh\* \ --move --cpus=2,3 --threads=http\* --move
# tuna --cpus=0,1 --threads=ssh\* \ --move --cpus=2,3 --threads=http\* --moveCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command performs the following operations sequentially:
- Selects CPUs 0 and 1.
-
Selects all threads that begin with
ssh. -
Moves the selected threads to the selected CPUs. Tuna sets the affinity mask of threads starting with
sshto the appropriate CPUs. The CPUs can be expressed numerically as 0 and 1, in hex mask as 0x3, or in binary as 11. - Resets the CPU list to 2 and 3.
-
Selects all threads that begin with
http. -
Moves the selected threads to the specified CPUs. Tuna sets the affinity mask of threads starting with
httpto the specified CPUs. The CPUs can be expressed numerically as 2 and 3, in hex mask as 0xC, or in binary as 1100.
Verification
Display the current configuration and verify that the changes were performed as expected:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This command performs the following operations sequentially:
-
Selects all threads that begin with the
gnome-scthreads. - Displays the selected threads to enable the user to verify their affinity mask and RT priority.
- Selects CPU 0.
-
Moves the
gnome-scthreads to the specified CPU, CPU 0. - Shows the result of the move.
- Resets the CPU list to CPU 1.
-
Moves the
gnome-scthreads to the specified CPU, CPU 1. - Displays the result of the move.
- Adds CPU 0 to the CPU list.
-
Moves the
gnome-scthreads to the specified CPUs, CPUs 0 and 1. - Displays the result of the move.
-
Selects all threads that begin with the
4.4. Tuning IRQs using tuna tool Copy linkLink copied to clipboard!
The /proc/interrupts file records the number of interrupts per IRQ, the type of interrupt, and the name of the device that is located at that IRQ.
This procedure describes how to tune the IRQs using the tuna tool.
Prerequisites
- The tuna tool is installed. For more information, see Installing tuna tool.
Procedure
To view the current IRQs and their affinity:
tuna --show_irqs users affinity
# tuna --show_irqs # users affinity 0 timer 0 1 i8042 0 7 parport0 0Copy to Clipboard Copied! Toggle word wrap Toggle overflow To specify the list of IRQs to be affected by a command:
tuna --irqs=irq_list [command]
# tuna --irqs=irq_list [command]Copy to Clipboard Copied! Toggle word wrap Toggle overflow The irq_list argument is a list of comma-separated IRQ numbers or user-name patterns.
Replace [command] with, for example,
--spread.To move an interrupt to a specified CPU:
tuna --irqs=128 --show_irqs tuna --irqs=128 --cpus=3 --move
# tuna --irqs=128 --show_irqs # users affinity 128 iwlwifi 0,1,2,3 # tuna --irqs=128 --cpus=3 --moveCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace 128 with the irq_list argument and 3 with the cpu_list argument.
The cpu_list argument is a list of comma-separated CPU numbers, for example,
--cpus=0,2. For more information, see Tuning CPUs using tuna tool.
Verification
Compare the state of the selected IRQs before and after moving any interrupt to a specified CPU:
tuna --irqs=128 --show_irqs
# tuna --irqs=128 --show_irqs # users affinity 128 iwlwifi 3Copy to Clipboard Copied! Toggle word wrap Toggle overflow