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 Copy linkLink copied to clipboard!
-
The
tunaand thepython-linux-procfspackages are installed. - You have root permissions on the system.
16.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 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 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 --cpus=<cpu_list> --isolatecpu_listis 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 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 --irqs=<irq_list> --show_irqsirq_listis 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,3Attach a list of IRQs to a list of CPUs.
# tuna --irqs=irq_list --cpus=<cpu_list> --moveirq_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 --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 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 --threads=<thread_list> --show_threadsthread_listis 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 rngdModify the process scheduling policy and the priority of the thread.
# tuna --threads=<thread_list> --priority scheduling_policy:priority_number-
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 --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