On a PREEMPT_RT kernel, RCU priority boosting is enabled by default, and RCU’s grace-period, rcuc and rcub kthreads all run at SCHED_FIFO priority 1. Boosting raises a preempted reader to that same priority and no higher, so an application thread at any real-time priority above 1 can still hold a grace period open until the stall detector fires. The kernel’s documented remedy is the rcutree.kthread_prio boot parameter. This part traces where each of those numbers comes from in the source.
This series has worked through the parts of the kernel that PREEMPT_RT rebuilds, from sleeping spinlocks in Part 1 to the ktimers thread in Part 6, by way of priority inheritance, local_lock, forced interrupt threading and preemptible softirqs. This part covers RCU, and begins with a correction: the read-side primitive is not what PREEMPT_RT changes. What changes is who runs RCU’s work and at what priority. RCU priority boosting handles the preempted reader that holds a grace period open, and it is the first of four defaults an RT kernel flips.
A grace period that stops advancing only on the RT kernel
The situation is specific. A product boots a CONFIG_PREEMPT or CONFIG_PREEMPT_DYNAMIC kernel and behaves correctly. The same tree is rebuilt with CONFIG_PREEMPT_RT=y, the control loop starts as a SCHED_FIFO thread at priority 50 pinned to one CPU, and the system now reports RCU CPU stall warnings, or synchronize_rcu() takes far longer than before, or callbacks accumulate without being invoked. No driver code changed, and RCU priority boosting is now enabled where it was not before.
This is a documented failure mode. Documentation/RCU/stallwarn.rst at v7.3 states that on CONFIG_PREEMPT_RT kernels a CPU-bound real-time task running above RCU’s kthreads can prevent RCU callbacks from ever running, and that a high-priority process can starve RCU’s softirq handler. Its suggested response is the rcutree.kthread_prio boot parameter.
Scope: everything below applies to CONFIG_PREEMPT_RT=y kernels on arm64 or x86_64. The behaviour was verified in source at v6.12, v6.18 and v7.3 and is the same at all three. On 6.6 and earlier, upstream arm64 and x86 do not select ARCH_SUPPORTS_RT, the boundary established in Part 5.
Preemptible readers come from PREEMPT_RCU, not from PREEMPT_RT
rcu_read_lock() stopped disabling preemption long before anyone enabled PREEMPT_RT. In kernel/rcu/tree_plugin.h the preemptible implementation does almost nothing:
void __rcu_read_lock(void)
{
rcu_preempt_read_enter();
if (IS_ENABLED(CONFIG_PROVE_LOCKING))
WARN_ON_ONCE(rcu_preempt_depth() > RCU_NEST_PMAX);
if (IS_ENABLED(CONFIG_RCU_STRICT_GRACE_PERIOD) && rcu_state.gp_kthread)
WRITE_ONCE(current->rcu_read_unlock_special.b.need_qs, true);
barrier(); /* critical section after entry code. */
}rcu_preempt_read_enter() increments current->rcu_read_lock_nesting, and that is all. With no preempt_disable(), the reader can be scheduled out like any other task. The accounting happens on the way into the scheduler: if the outgoing task has a non-zero nesting count and is not already recorded as blocked, rcu_note_context_switch() sets t->rcu_read_unlock_special.b.blocked, records t->rcu_blocked_node, and calls rcu_preempt_ctxt_queue() to link the task’s rcu_node_entry into its leaf rcu_node‘s blkd_tasks list. The normal grace period waits on rnp->gp_tasks, a pointer into that list, and cannot complete until the entries predating it drain.
The exit is equally thin. __rcu_read_unlock() decrements the counter and calls rcu_read_unlock_special() only if the result is zero and t->rcu_read_unlock_special.s is non-zero. A reader that is never preempted leaves that flag word untouched, which is why it costs a counter increment and a compiler barrier.
None of that is RT-specific. Captured on a live 6.18.44 x86_64 kernel with two CPUs, built with PREEMPT_DYNAMIC and no RT patches:
raghu@techveda.org:~$ uname -v
#1 SMP PREEMPT_DYNAMIC @0
raghu@techveda.org:~$ zcat /proc/config.gz | grep -E "PREEMPT_RCU|RCU_BOOST|RCU_NOCB_CPU="
CONFIG_PREEMPT_RCU=y
# CONFIG_RCU_BOOST is not set
CONFIG_RCU_NOCB_CPU=y
raghu@techveda.org:~$ dmesg | grep "Preemptible hierarchical"
[ 0.279432] rcu: Preemptible hierarchical RCU implementation.CONFIG_PREEMPT_RCU defaults to y on PREEMPT, PREEMPT_RT and PREEMPT_DYNAMIC alike, so this kernel runs the same read-side code an RT kernel does. What it does not have is CONFIG_RCU_BOOST, and that is the difference that matters.
Four defaults that PREEMPT_RT flips
Turning on CONFIG_PREEMPT_RT changes four settings. Together they enable RCU priority boosting and move all of RCU’s work into real-time kthreads. Each was read at v7.3 and confirmed identical at v6.12.
| Setting | Value on PREEMPT_RT | Effect |
|---|---|---|
CONFIG_RCU_BOOST | default y if PREEMPT_RT | RCU priority boosting is on, and selectable without RCU_EXPERT: the clause is (RT_MUTEXES && PREEMPT_RCU && RCU_EXPERT) || PREEMPT_RT. |
use_softirq (a variable, not a symbol) | false | RCU core processing leaves RCU_SOFTIRQ and runs in per-CPU rcuc/N kthreads. |
CONFIG_RCU_NOCB_CPU_CB_BOOST | default y if PREEMPT_RT | Offloaded callback kthreads are switched to SCHED_FIFO wherever callbacks are offloaded. |
CONFIG_RCU_EXP_KTHREAD | default !PREEMPT_RT && NR_CPUS <= 32 | Off, so the expedited kthread workers are not promoted and stay SCHED_OTHER on an RT kernel. |
The second row is the one most often misread, so here it is exactly, from kernel/rcu/tree.c:
/* By default, use RCU_SOFTIRQ instead of rcuc kthreads. */
static bool use_softirq = !IS_ENABLED(CONFIG_PREEMPT_RT);
#ifndef CONFIG_PREEMPT_RT
module_param(use_softirq, bool, 0444);
#endifThe module parameter is declared inside the #ifndef, so on a PREEMPT_RT kernel rcutree.use_softirq does not exist. The effect runs deeper than a thread name: open_softirq(RCU_SOFTIRQ, rcu_core_si) appears exactly once in tree.c, guarded by if (use_softirq), and both sites that raise the softirq are guarded by the same variable, so on an RT kernel RCU’s softirq is never registered and never raised. The kernel reports this at boot from rcu_bootup_announce_oddness():
if (!use_softirq)
pr_info("\tRCU_SOFTIRQ processing moved to rcuc kthreads.\n");The work itself is unchanged — rcu_cpu_kthread() calls the same rcu_core() — but it is now a schedulable entity with a priority, and therefore something your own threads can outrank.
How RCU priority boosting manufactures a priority inheritance chain
Boosting is driven by one kthread per leaf rcu_node, created in rcu_spawn_one_boost_kthread() as "rcub/%d" and affined by rcu_thread_affine_rnp() to that node’s CPUs. It sleeps until rnp->boost_tasks or rnp->exp_tasks becomes non-NULL.
rcu_initiate_boost() decides when. An expedited grace period boosts immediately. A normal one boosts only when rnp->gp_tasks is set, rnp->boost_tasks is still NULL, rnp->qsmask is zero — every CPU in the node has already reported a quiescent state, so blocked readers are the only thing left holding the grace period — and either the node’s boost_time has passed or RCU’s callback-overload flag is set:
#define RCU_BOOST_DELAY_JIFFIES DIV_ROUND_UP(CONFIG_RCU_BOOST_DELAY * HZ, 1000)
static void rcu_preempt_boost_start_gp(struct rcu_node *rnp)
{
rnp->boost_time = jiffies + RCU_BOOST_DELAY_JIFFIES;
}CONFIG_RCU_BOOST_DELAY is in milliseconds, range 0 to 3000, default 500 — at HZ=250, 125 jiffies. A preempted reader therefore gets half a second before RCU priority boosting touches it: this is a recovery path, not a scheduling policy.
The boost does not raise the reader’s priority directly. rcu_boost() takes the first task from the appropriate list and does this:
t = container_of(tb, struct task_struct, rcu_node_entry);
rt_mutex_init_proxy_locked(&rnp->boost_mtx.rtmutex, t);
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
/* Lock only for side effect: boosts task t's priority. */
rt_mutex_lock(&rnp->boost_mtx);
rt_mutex_unlock(&rnp->boost_mtx); /* Then keep lockdep happy. */It fabricates an rt_mutex that appears to be held by the blocked reader, then acquires it. Because rt_mutex implements priority inheritance — the subject of Part 2 — a higher-priority task blocking on a mutex whose owner is the reader raises the reader to the blocker’s priority, and RCU needs no second priority-raising mechanism. Deboosting uses the same machinery: rcu_preempt_deferred_qs_irqrestore() snapshots rt_mutex_owner(&rnp->boost_mtx.rtmutex) == t under the node lock and later calls rt_mutex_futex_unlock(), so the reader loses the inherited priority when it leaves its outermost read-side critical section rather than at some later tick.
Why every RCU kthread lands on SCHED_FIFO priority 1
Now the number that decides whether any of this helps. In kernel/rcu/tree.c:
static int kthread_prio = IS_ENABLED(CONFIG_RCU_BOOST) ? 1 : 0;
module_param(kthread_prio, int, 0444);Because CONFIG_RCU_BOOST defaults to y on PREEMPT_RT, kthread_prio defaults to 1 there. sanitize_kthread_prio(), called early in rcu_init(), clamps whatever the command line supplied — with boosting enabled anything below 1 becomes 1, anything above 99 becomes 99 — and reports any change through pr_alert("%s: Limited prio to %d from %d\n", __func__, kthread_prio, kthread_prio_in)
That one value is applied at four places. rcu_spawn_gp_kthread() puts the grace-period kthread — visible as rcu_preempt — on SCHED_FIFO whenever it is non-zero, and rcu_spawn_one_boost_kthread() does the same for each rcub/N. rcu_cpu_kthread_setup(), inside an #ifdef CONFIG_RCU_BOOST block, calls sched_setscheduler_nocheck(current, SCHED_FIFO, &sp) on each rcuc/N. And rcu_spawn_cpu_nocb_kthread() in kernel/rcu/tree_nocb.h switches the offloaded callback kthread to SCHED_FIFO when CONFIG_RCU_NOCB_CPU_CB_BOOST is enabled. The boot log states the result:
#ifdef CONFIG_RCU_BOOST
pr_info("\tRCU priority boosting: priority %d delay %d ms.\n",
kthread_prio, CONFIG_RCU_BOOST_DELAY);
#endifOne asymmetry is easy to miss. The expedited grace-period kthread workers, created in rcu_start_exp_gp_kworker() and rcu_spawn_exp_par_gp_kworker(), are promoted only under if (IS_ENABLED(CONFIG_RCU_EXP_KTHREAD)), which defaults off on PREEMPT_RT. The work behind synchronize_rcu_expedited() therefore runs at SCHED_OTHER while the four kthreads above run at FIFO 1.
The limit of RCU priority boosting is then arithmetic. A boosted reader inherits the priority of the rcub/N kthread that blocks on the manufactured mutex, and that kthread is at SCHED_FIFO 1. An application thread at SCHED_FIFO 50 sits 49 levels above it.
How to tell which RCU model your kernel is running
A reader who has already checked the configuration can start at step three.
Step 1 — the preemption model. uname -v names it. An RT kernel carries PREEMPT_RT in that string; PREEMPT or PREEMPT_DYNAMIC means none of the four flipped defaults applies.
Step 2 — the configuration. The /proc/config.gz grep shown above. CONFIG_PREEMPT_RCU=y alone means only that readers are preemptible; CONFIG_RCU_BOOST=y is what tells you kthread_prio is at least 1.
Step 3 — the boot log. Three lines matter, and an absence is as informative as a presence. Preemptible hierarchical RCU implementation. confirms preemptible RCU. RCU_SOFTIRQ processing moved to rcuc kthreads. appears only when use_softirq is false, which means PREEMPT_RT unless rcutree.use_softirq=0 was passed to a non-RT kernel. RCU priority boosting: priority N delay M ms. reports the priority after clamping — the number to compare against your application’s.
Step 4 — the kthreads. The rcuc/N threads exist only when the softirq path is off:
raghu@techveda.org:~$ ps -eo class,rtprio,comm | grep -E "rcu_preempt|rcuc/|rcub/"
TS - rcu_preemptOn this non-RT kernel only the grace-period kthread exists, in class TS. On an RT kernel the same command returns rcu_preempt, one rcuc/N per CPU and one rcub/N per leaf node, all in class FF. Offloaded callback threads appear as rcuo plus the RCU flavour’s abbreviation, only for CPUs named by rcu_nocbs or implied by nohz_full.
Step 5 — the softirq counter. On a kernel still using the softirq path, the RCU row of /proc/softirqs advances between two reads:
raghu@techveda.org:~$ grep RCU /proc/softirqs
RCU: 840 1075
raghu@techveda.org:~$ grep RCU /proc/softirqs
RCU: 850 1089A row that never advances is consistent with an RT kernel, where the handler is never registered. A row that was advancing and has stopped, on a non-RT kernel, is the starved-softirq case stallwarn.rst describes. This column was not observed on an RT kernel; that claim rests on the two guarded raise sites, not on a measurement.
Three wrong turns when RCU stalls on an RT kernel
Raising the application’s real-time priority. The reasoning is that RCU is background maintenance and the control loop is the product, so the control loop should win. That is correct on a non-RT kernel, where RCU’s core work runs in softirq context and is not a schedulable competitor. On an RT kernel it inverts the problem: the higher the application thread sits, the less RCU priority boosting can do for a reader stuck at priority 1. The incomplete part of the model is the assumption that RCU’s work has no priority.
Setting rcutree.use_softirq=1 on the command line. This is attractive because the parameter is real, is documented, and looks like a way to undo the change without rebuilding. On an RT kernel the module_param() line is compiled out, so the parameter does not exist; an unknown rcutree. parameter is not a boot failure, so nothing visibly rejects it.
Offloading callbacks and assuming the work has left the CPU. rcu_nocbs is the right tool for an isolated CPU. The incomplete model is that offloading removes cost rather than relocating it: the rcuo threads have to run somewhere, and CONFIG_RCU_NOCB_CPU_CB_BOOST makes them SCHED_FIFO at kthread_prio on whichever CPU they land on. The rcub/N threads are a separate case, because rcu_thread_affine_rnp() expresses a preference for the CPUs of their own leaf rcu_node. Isolating a CPU is a placement exercise across all of them.
What RCU priority boosting cannot do
Four limits, each a case where the mechanism works as designed and still does not help. It cannot outrank your threads: nothing in the boost path consults the priority of whatever preempted the reader, and raising rcutree.kthread_prio is the documented response, at the context-switch cost stallwarn.rst names. It is not immediate: the 500 ms delay and the zero-qsmask requirement mean a normal grace period tolerates a preempted reader for a considerable time. It does not cover the expedited path’s own kthread workers, which stay at SCHED_OTHER on an RT kernel. And it does nothing about read-side sections you did not write: on PREEMPT_RT, __local_bh_disable_ip() calls rcu_read_lock() when a task first disables bottom halves in a preemptible context, as Part 5 established.
Verification checklist
dmesg | grep "RCU priority boosting"prints a line, and the priority it reports is the one you intended, not a valuesanitize_kthread_prio()clamped.ps -eo class,rtprio,comm | grep -E "rcuc/|rcub/|rcuo"lists onercucper CPU and onercubper leaf node, all in classFF.chrt -pon each of those PIDs reports a priority you chose deliberately relative to your application’s real-time threads, not the default 1 by accident.- The RCU row of
/proc/softirqsis not advancing. - No RCU CPU stall warning appears after the worst-case real-time load has run for longer than the stall timeout.
- For every CPU in
rcu_nocbs, the matchingrcuothread’s affinity has been checked and is not on a CPU you intended to isolate.
Reasoning about RCU, scheduling classes and kthread priorities together is the kind of work the Linux Kernel Infrastructure course covers in depth.
What was verified and what was not
Every identifier, Kconfig default and format string above was read from kernel source at tag v7.3, and the four flipped defaults and the kthread_prio initialiser were confirmed identical at v6.12. The command output was captured on a running 6.18.44 x86_64 kernel built with PREEMPT_DYNAMIC, which has no RCU priority boosting. No PREEMPT_RT kernel was built or booted for this part. Every statement about RT behaviour is derived from the source and from stallwarn.rst, and no RT console output is shown: where the kernel’s own message is quoted, it is the pr_info format string, not a captured line. Whether raising rcutree.kthread_prio resolves the stall on a particular board was not tested.
Key takeaways
- Preemptible readers are a
CONFIG_PREEMPT_RCUproperty, not a PREEMPT_RT one. kthread_priodefaults to 1 wheneverCONFIG_RCU_BOOSTis set, and that one value sets the priority of the grace-period kthread, thercucandrcubthreads and the offloaded callback threads.- RCU priority boosting raises a preempted reader to
kthread_prioand no further, by manufacturing anrt_mutexand letting priority inheritance do the work.
Related reading on this blog
- What PREEMPT_RT Changes: Priority Inheritance (Part 2) — the
rt_mutexinheritance machinery thatrcu_boost()reuses. - What PREEMPT_RT Changes: Preemptible Softirqs (Part 5) — why
local_bh_disable()takes an RCU read-side critical section on an RT kernel. - Real-Time Linux with PREEMPT_RT — Part 3: SCHED_FIFO Priorities and CPU Isolation — choosing application priorities, the decision
kthread_priois set against.
Frequently asked questions
Does PREEMPT_RT make rcu_read_lock() preemptible?
No. CONFIG_PREEMPT_RCU does that, and it is enabled by default on PREEMPT, PREEMPT_DYNAMIC and PREEMPT_RT kernels alike. What PREEMPT_RT adds is RCU priority boosting, the rcuc kthreads, and real-time priorities on RCU’s own threads.
Can I set rcutree.use_softirq=1 to get the old behaviour back on an RT kernel?
No. The module_param declaration for use_softirq sits inside an #ifndef CONFIG_PREEMPT_RT block, so the parameter does not exist on an RT kernel and setting it has no effect.
Why does boosting not help when my control thread runs at SCHED_FIFO 50?
Boosting raises the preempted reader to the priority of the rcub kthread, which is kthread_prio, normally 1. A thread at priority 50 still runs first. Raising rcutree.kthread_prio is the remedy the kernel’s stall-warning documentation suggests, at the cost of more context switches.
Further reading
- Linux v7.3, kernel/rcu/tree_plugin.h —
__rcu_read_lock(),rcu_note_context_switch(),rcu_read_unlock_special(),rcu_boost(),rcu_initiate_boost(),rcu_cpu_kthread_setup() - Linux v7.3, kernel/rcu/tree.c —
use_softirq,kthread_prio,sanitize_kthread_prio(),invoke_rcu_core(),rcu_cpu_thread_spec,rcu_thread_affine_rnp() - Linux v7.3, kernel/rcu/Kconfig —
PREEMPT_RCU,RCU_BOOST,RCU_BOOST_DELAY,RCU_NOCB_CPU_CB_BOOST,RCU_EXP_KTHREAD - Linux v7.3, kernel/rcu/tree_nocb.h —
rcu_spawn_cpu_nocb_kthread() - Using RCU’s CPU Stall Detector — the
rcutree.kthread_prioremedy and the starved-softirq case on RT kernels




