Chapter 19. Improving latency using the tuna CLI

You can use the tuna CLI to improve latency on your system. The tuna CLI, for RHEL 9, includes the command line interface, which is based on the argparse parsing module. The interface provides the following capabilities:

  • A more standardized menu of commands and options
  • With the interface, you can use predefined inputs and tuna ensures that the inputs are of the right type
  • Generates usage help messages automatically, on how to use parameters and provides error messages with invalid arguments

19.1. Prerequisites

  • The tuna and the python-linux-procfs packages are installed.
  • You have root permissions on the system.

19.2. The tuna CLI

The tuna command-line interface (CLI) is a tool to help you make tuning changes to your system.

The tuna tool is designed to be used on a running system, and changes take place immediately. This allows any application-specific measurement tools to see and analyze system performance immediately after changes have been made.

The tuna CLI now has a set of commands, which formerly were the action options. These commands are:

isolate
Move all threads and IRQs away from the CPU-LIST.
include
Configure all threads to run on a CPU-LIST.
move
Move specific entities to the CPU-LIST.
spread
Spread the selected entities over the CPU-LIST.
priority
Set the thread scheduler tunables, such as POLICY and RTPRIO.
run
Fork a new process and run the command.
save
Save kthreads sched tunables to FILENAME.
apply
Apply changes defined in the profile.
show_threads
Display a thread list.
show_irqs
Display the IRQ list.
show_configs
Display the existing profile list.
what_is
Provide help about selected entities.
gui
Start the graphical user interface (GUI).

You can view the commands with the tuna -h command. For each command, there are optional arguments, which you can view with the tuna <command> -h command. For example, with the tuna isolate -h command, you can view the options for isolate.

19.3. Isolating CPUs using the tuna CLI

You can use the tuna CLI to isolate interrupts (IRQs) from user processes on different dedicated CPUs to minimize latency in real-time environments. For more information about isolating CPUs, see Interrupt and process binding.

Prerequisites

  • The tuna and the python-linux-procfs packages are installed.
  • You have root permissions on the system.

Procedure

  • Isolate one or more CPUs.

    # tuna isolate --cpus=<cpu_list>

    cpu_list is a comma-separated list or a range of CPUs to isolate.

    For example:

    # tuna isolate --cpus=0,1

    or

    # tuna isolate --cpus=0-5

19.4. Moving interrupts to specified CPUs using the tuna CLI

You can use the tuna CLI to move interrupts (IRQs) to dedicated CPUs to minimize or eliminate latency in real-time environments. For more information about moving IRQs, see Interrupt and process binding.

Prerequisites

  • The tuna and python-linux-procfs packages are installed.
  • You have root permissions on the system.

Procedure

  1. List the CPUs to which a list of IRQs is attached.

    # tuna show_irqs --irqs=<irq_list>

    irq_list is a comma-separated list of the IRQs for which you want to list attached CPUs.

    For example:

    # tuna show_irqs --irqs=128
  2. Attach a list of IRQs to a list of CPUs.

    # tuna move --irqs=irq_list --cpus=<cpu_list>

    irq_list is a comma-separated list of the IRQs you want to attach and cpu_list is a comma-separated list of the CPUs to which they will be attached or a range of CPUs.

    For example:

    # tuna move --irqs=128 --cpus=3

Verification

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

    # tuna show_irqs --irqs=128

19.5. Changing process scheduling policies and priorities using the tuna CLI

You can use the tuna CLI to change process scheduling policy and priority.

Prerequisites

  • The tuna and python-linux-procfs packages are installed.
  • You have root permissions on the system.

    Note

    Assigning the OTHER and BATCH scheduling policies does not require root permissions.

Procedure

  1. View the information for a thread.

    # tuna show_threads --threads=<thread_list>

    thread_list is a comma-separated list of the processes you want to display.

    For example:

    # tuna show_threads --threads=42369,42416,43859
  2. Modify the process scheduling policy and the priority of the thread.

    # tuna priority scheduling_policy:priority_number --threads=<thread_list>
    • thread_list is a comma-separated list of the processes whose scheduling policy and priority you want to display.
    • scheduling_policy is one of the following:

      • OTHER
      • BATCH
      • FIFO - First In First Out
      • RR - Round Robin
    • priority_number is a priority number from 0 to 99, where 0 is no priority and 99 is the highest priority.

      Note

      The OTHER and BATCH scheduling policies do not require specifying a priority. In addition, the only valid priority (if specified) is 0. The FIFO and RR scheduling policies require a priority of 1 or more.

      For example:

# tuna priority FIFO:1 --threads=42369,42416,43859

Verification

  • View the information for the thread to ensure that the information changes.
# tuna show_threads --threads=42369,42416,43859