Chapter 15. Improving latency using the tuna CLI

You can use the tuna CLI to improve latency on your system. The options used with the tuna command determine the method invoked to improve latency.

15.1. Prerequisites

  • The RHEL for Real Time package group and the tuna package are installed.
  • You have root permissions on the system.

15.2. The tuna CLI

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

Note

A new graphical interface is being developed for tuna, but it has not yet been released.

The tuna CLI can be used to adjust scheduler tunables, tune thread priority, IRQ handlers, and isolate CPU cores and sockets. tuna aims to reduce the complexity of performing tuning tasks. The 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 has both action options and modifier options. Modifier options must be specified on the command-line before the actions they are intended to modify. All modifier options apply to the actions that follow until the modifier options are overridden.

15.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 RHEL for Real Time package group and the tuna package are installed.
  • You have root permissions on the system.

Procedure

  • Isolate one or more CPUs.

    # tuna --cpus=cpu_list --isolate

    where cpu_list is a comma-separated list of the CPUs to isolate.

    For example:

    # tuna --cpus=0,1 --isolate

15.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 RHEL for Real Time package group and the tuna package are installed.
  • You have root permissions on the system.

Procedure

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

    # tuna --irqs=irq_list --show_irqs

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

    For example:

    # tuna --irqs=128 --show_irqs
       # users         affinity
     128 iwlwifi          0,1,2,3
  2. Attach a list of IRQs to a list of CPUs.

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

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

    For example:

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

Verification steps

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

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

15.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 RHEL for Real Time package group and the tuna package are installed.
  • You have root permissions on the system.

    Note

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

Procedure

  1. View the information for a thread.

    # tuna --threads=thread_list --show_threads

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

    For example:

    # tuna --threads=rngd --show_threads
                          thread       ctxt_switches
        pid SCHED_ rtpri affinity voluntary nonvoluntary             cmd
      3571   OTHER     0  0,1,2,3    167697          134            rngd
  2. Modify the process scheduling policy and the priority of the thread.

    # tuna --threads=thread_list --priority scheduling_policy:priority_number

    where:

    • 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 --threads=rngd --priority FIFO:1

Verification steps

  • View the information for the thread to ensure that the information changes.
# tuna --threads=rngd --show_threads
                      thread       ctxt_switches
    pid SCHED_ rtpri affinity voluntary nonvoluntary             cmd
  3571   FIFO     1  0,1,2,3    167697          134            rngd