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 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 tuna tool: Verification Display the available tuna CLI options: Additional resources tuna(8) man page on your system 4.2. Viewing the system status using tuna tool 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: To view a specific thread corresponding to a PID or matching a command name: The pid_or_cmd_list argument is a list of comma-separated PIDs or command-name patterns. To tune CPUs using the tuna CLI, see Tuning CPUs using tuna tool . To tune the IRQs using the tuna tool, see Tuning IRQs using tuna tool . To save the changed configuration: This command saves only currently running kernel threads. Processes that are not running are not saved. Additional resources tuna(8) man page on your system 4.3. Tuning CPUs using tuna tool 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 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 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: 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: To include a CPU: 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 http threads on CPU 2 and 3 : # tuna --cpus= 0,1 --threads=ssh\* \ --move --cpus= 2,3 --threads=http\* --move 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 ssh to 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 http to 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: # tuna --threads=gnome-sc\* --show_threads \ --cpus= 0 --move --show_threads --cpus= 1 \ --move --show_threads --cpus= +0 --move --show_threads thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 3861 OTHER 0 0,1 33997 58 gnome-screensav thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 3861 OTHER 0 0 33997 58 gnome-screensav thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 3861 OTHER 0 1 33997 58 gnome-screensav thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 3861 OTHER 0 0,1 33997 58 gnome-screensav This command performs the following operations sequentially: Selects all threads that begin with the gnome-sc threads. Displays the selected threads to enable the user to verify their affinity mask and RT priority. Selects CPU 0 . Moves the gnome-sc threads to the specified CPU, CPU 0 . Shows the result of the move. Resets the CPU list to CPU 1 . Moves the gnome-sc threads to the specified CPU, CPU 1 . Displays the result of the move. Adds CPU 0 to the CPU list. Moves the gnome-sc threads to the specified CPUs, CPUs 0 and 1 . Displays the result of the move. Additional resources /proc/cpuinfo file tuna(8) man page on your system 4.4. Tuning IRQs using tuna tool 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: To specify the list of IRQs to be affected by a command: 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: 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: Additional resources /procs/interrupts file tuna(8) man page on your system

Commands:
yum install tuna
tuna -h
tuna --show_threads thread pid SCHED_ rtpri affinity cmd 1 OTHER 0 0,1 init 2 FIFO 99 0 migration/0 3 OTHER 0 0 ksoftirqd/0 4 FIFO 99 0 watchdog/0
tuna --threads= pid_or_cmd_list --show_threads
tuna --save=filename
tuna --cpus= cpu_list [ command ]
tuna --cpus=cpu_list --isolate
tuna --cpus=cpu_list --include
tuna --cpus= 0,1 --threads=ssh\* --move --cpus= 2,3 --threads=http\* --move
tuna --threads=gnome-sc\* --show_threads --cpus= 0 --move --show_threads --cpus= 1 --move --show_threads --cpus= +0 --move --show_threads thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 3861 OTHER 0 0,1 33997 58 gnome-screensav thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 3861 OTHER 0 0 33997 58 gnome-screensav thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 3861 OTHER 0 1 33997 58 gnome-screensav thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 3861 OTHER 0 0,1 33997 58 gnome-screensav
tuna --show_irqs users affinity 0 timer 0 1 i8042 0 7 parport0 0
tuna --irqs= irq_list [ command ]
tuna --irqs= 128 --show_irqs # users affinity 128 iwlwifi 0,1,2,3 tuna --irqs= 128 --cpus=3 --move
tuna --irqs= 128 --show_irqs # users affinity 128 iwlwifi 3