Red Hat Training

A Red Hat training course is available for RHEL 8

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:

    # yum install tuna

Verification steps

  • Display the available tuna CLI options:

    # tuna -h

Additional resources

  • tuna(8) man page

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

Procedure

  • To view the current policies and priorities:

    # 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
  • To view a specific thread corresponding to a PID or matching a command name:

    # tuna --threads=pid_or_cmd_list --show_threads

    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:

    # tuna --save=filename

    This command saves only currently running kernel threads. Processes that are not running are not saved.

Additional resources

  • tuna(8) man page

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

Procedure

  • To specify the list of CPUs to be affected by a command:

    # tuna --cpus=cpu_list [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:

    # tuna --cpus=cpu_list --isolate
  • To include a CPU:

    # tuna --cpus=cpu_list --include
  • 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:

    1. Selects CPUs 0 and 1.
    2. Selects all threads that begin with ssh.
    3. 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.
    4. Resets the CPU list to 2 and 3.
    5. Selects all threads that begin with http.
    6. 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 steps

  • 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:

    1. Selects all threads that begin with the gnome-sc threads.
    2. Displays the selected threads to enable the user to verify their affinity mask and RT priority.
    3. Selects CPU 0.
    4. Moves the gnome-sc threads to the specified CPU, CPU 0.
    5. Shows the result of the move.
    6. Resets the CPU list to CPU 1.
    7. Moves the gnome-sc threads to the specified CPU, CPU 1.
    8. Displays the result of the move.
    9. Adds CPU 0 to the CPU list.
    10. Moves the gnome-sc threads to the specified CPUs, CPUs 0 and 1.
    11. Displays the result of the move.

Additional resources

  • /proc/cpuinfo file
  • tuna(8) man page

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

Procedure

  • To view the current IRQs and their affinity:

    # tuna --show_irqs
    # users            affinity
    0 timer                   0
    1 i8042                   0
    7 parport0                0
  • To specify the list of IRQs to be affected by a command:

    # tuna --irqs=irq_list [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:

    # tuna --irqs=128 --show_irqs
       # users            affinity
     128 iwlwifi           0,1,2,3
    
    # tuna --irqs=128 --cpus=3 --move

    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 steps

  • Compare the state of the selected IRQs before and after moving any interrupt to a specified CPU:

    # tuna --irqs=128 --show_irqs
       # users            affinity
     128 iwlwifi                 3

Additional resources

  • /procs/interrupts file
  • tuna(8) man page