Chapter 16. 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. By using the tuna CLI, you perform the following functions:

  • Modify the scheduler tunables
  • Tune a IRQ handlers and thread priorities
  • Isolate CPU cores and sockets
  • Reduce the complexity to tune tasks

16.1. Prerequisites

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

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

16.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 --cpus=<cpu_list> --isolate

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

    For example:

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

16.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 --irqs=<irq_list> --show_irqs

    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

    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 --irqs=128 --cpus=3 --move

Verification

  • 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

16.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 --threads=<thread_list> --show_threads

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

  • 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