Chapter 22. Improving latency using the tuna CLI
You can use the tuna CLI to improve latency on your system. The tuna CLI for RHEL 10 is based on the argparse parsing module and provides a standardized menu of commands and options with automatic help messages.
The interface provides the following capabilities:
- A more standardized menu of commands and options
-
With the interface, you can use predefined inputs and
tunaensures 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
22.1. Prerequisites Copy linkLink copied to clipboard!
-
The
tunaand thepython-linux-procfspackages are installed. - You have root permissions on the system.
22.2. The tuna CLI Copy linkLink copied to clipboard!
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
POLICYandRTPRIO. - run
- Fork a new process and run the command.
- save
-
Save
kthreadsschedtunablestoFILENAME. - apply
- Apply changes defined in the profile.
- show_threads
- Display a thread list.
- show_irqs
-
Display the
IRQlist. - 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.
22.3. Isolating CPUs using the tuna CLI Copy linkLink copied to clipboard!
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
tunaand thepython-linux-procfspackages are installed. - You have root permissions on the system.
Procedure
Isolate one or more CPUs.
tuna isolate --cpus=<cpu_list>
# tuna isolate --cpus=<cpu_list>Copy to Clipboard Copied! Toggle word wrap Toggle overflow cpu_listis a comma-separated list or a range of CPUs to isolate.For example:
tuna isolate --cpus=0,1
# tuna isolate --cpus=0,1Copy to Clipboard Copied! Toggle word wrap Toggle overflow or
tuna isolate --cpus=0-5
# tuna isolate --cpus=0-5Copy to Clipboard Copied! Toggle word wrap Toggle overflow
22.4. Moving interrupts to specified CPUs using the tuna CLI Copy linkLink copied to clipboard!
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
tunaandpython-linux-procfspackages are installed. - You have root permissions on the system.
Procedure
List the CPUs to which a list of IRQs is attached.
tuna show_irqs --irqs=<irq_list>
# tuna show_irqs --irqs=<irq_list>Copy to Clipboard Copied! Toggle word wrap Toggle overflow irq_listis a comma-separated list of the IRQs for which you want to list attached CPUs.For example:
tuna show_irqs --irqs=128
# tuna show_irqs --irqs=128Copy to Clipboard Copied! Toggle word wrap Toggle overflow Attach a list of IRQs to a list of CPUs.
tuna move --irqs=irq_list --cpus=<cpu_list>
# tuna move --irqs=irq_list --cpus=<cpu_list>Copy to Clipboard Copied! Toggle word wrap Toggle overflow irq_listis a comma-separated list of the IRQs you want to attach andcpu_listis 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
# tuna move --irqs=128 --cpus=3Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Compare the state of the selected IRQs before and after moving any IRQ to a specified CPU.
tuna show_irqs --irqs=128
# tuna show_irqs --irqs=128Copy to Clipboard Copied! Toggle word wrap Toggle overflow
22.5. Changing process scheduling policies and priorities using the tuna CLI Copy linkLink copied to clipboard!
You can use the tuna CLI to change process scheduling policy and priority.
Prerequisites
-
The
tunaandpython-linux-procfspackages are installed. You have root permissions on the system.
NoteAssigning the
OTHERandBATCHscheduling policies does not require root permissions.
Procedure
View the information for a thread.
tuna show_threads --threads=<thread_list>
# tuna show_threads --threads=<thread_list>Copy to Clipboard Copied! Toggle word wrap Toggle overflow thread_listis a comma-separated list of the processes you want to display.For example:
tuna show_threads --threads=42369,42416,43859
# tuna show_threads --threads=42369,42416,43859Copy to Clipboard Copied! Toggle word wrap Toggle overflow Modify the process scheduling policy and the priority of the thread.
tuna priority scheduling_policy:priority_number --threads=<thread_list>
# tuna priority scheduling_policy:priority_number --threads=<thread_list>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
thread_listis a comma-separated list of the processes whose scheduling policy and priority you want to display. scheduling_policyis one of the following:- OTHER
- BATCH
- FIFO - First In First Out
- RR - Round Robin
priority_numberis a priority number from 0 to 99, where0is no priority and99is the highest priority.NoteThe
OTHERandBATCHscheduling policies do not require specifying a priority. In addition, the only valid priority (if specified) is0. TheFIFOandRRscheduling policies require a priority of1or more.For example:
tuna priority FIFO:1 --threads=42369,42416,43859
# tuna priority FIFO:1 --threads=42369,42416,43859Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Verification
View the information for the thread to ensure that the information changes.
tuna show_threads --threads=42369,42416,43859
# tuna show_threads --threads=42369,42416,43859Copy to Clipboard Copied! Toggle word wrap Toggle overflow