Chapter 26. Improving CPU performance by using RCU callbacks
The Read-Copy-Update
(RCU
) system is a lockless mechanism for mutual exclusion of threads inside the kernel. As a consequence of performing RCU operations, call-backs are sometimes queued on CPUs to be performed at a future moment when removing memory is safe.
To improve CPU performance using RCU callbacks:
- You can remove CPUs from being candidates for running CPU callbacks.
- You can assign a CPU to handle all RCU callbacks. This CPU is called the housekeeping CPU.
- You can relieve CPUs from the responsibility of awakening RCU offload threads.
This combination reduces the interference on CPUs that are dedicated for the user’s workload.
Prerequisites
- You have administrator privileges.
-
The
tuna
package is installed
26.1. Offloading RCU callbacks
You can offload RCU
callbacks using the rcu_nocbs
and rcu_nocb_poll
kernel parameters.
Procedure
To remove one or more CPUs from the candidates for running RCU callbacks, specify the list of CPUs in the
rcu_nocbs
kernel parameter, for example:rcu_nocbs=1,4-6
or
rcu_nocbs=3
The second example instructs the kernel that CPU 3 is a no-callback CPU. This means that RCU callbacks will not be done in the
rcuc/$CPU
thread pinned to CPU 3, but in thercuo/$CPU
thread. You can move this trhead to a housekeeping CPU to relieve CPU 3 from being assigned RCU callback jobs.
26.2. Moving RCU callbacks
You can assign a housekeeping CPU to handle all RCU callback threads. To do this, use the tuna
command and move all RCU callbacks to the housekeeping CPU.
Procedure
Move RCU callback threads to the housekeeping CPU:
# tuna --threads=rcu --cpus=x --move
where
x
is the CPU number of the housekeeping CPU.
This action relieves all CPUs other than CPU X from handling RCU callback threads.
26.3. Relieving CPUs from awakening RCU offload threads
Although the RCU offload threads can perform the RCU callbacks on another CPU, each CPU is responsible for awakening the corresponding RCU offload thread. You can relieve a CPU from this responsibility,
Procedure
Set the
rcu_nocb_poll
kernel parameter.This command causes a timer to periodically raise the RCU offload threads to check if there are callbacks to run.
26.4. Additional resources
- Avoiding RCU Stalls in the real-time kernel (Red Hat Knowledgebase)