# Real-time (RT) kernel overview
A real-time system is a deterministic system, where response to an event
is expected in a fixed and pre-determined time.
A system is classified as compatible with RT if:
- It’s devoid of unbounded latency.
- The maximum response time is calculated with precision.
- It meets the set criteria for scheduling of tasks (latency and
deadline).
Linux can be configured as a real-time operating system (RTOS) in which
real-time tasks have well-defined periodic execution cycles (cycle
time) and meet execution criteria within specified limits (jitter).
When considering Linux as RTOS, apply `PREEMPT_RT` patches and enable
configurations for a fully preemptible kernel.
The RT kernel maintainers maintain out-of-tree `PREEMPT_RT` patches
for every kernel version released.
To install the patches, see [Versions of PREEMPT_RT
patches](https://wiki.linuxfoundation.org/realtime/start).
Note
The real-time support is for kernel space process and not for user space.
**Figure : Build sequence**
## Set up workspace
The Qualcomm^®^ Linux^®^ kernel supports the LTS RT kernel (6.6.x), which is maintained
through the Yocto recipes in the `meta-qcom-realtime` layer.
For more information about cloning the workspace and getting all Qualcomm Linux meta layers to
use Qualcomm RT Linux, see [Sync and build with real-time Linux](https://docs.qualcomm.com/bundle/publicresource/topics/80-70033-254/how_to.html#sync-and-build-with-real-time-linux).
The Qualcomm Linux `meta-qcom-realtime` layer supports recipe for base and custom BSP that fetches and builds the Qualcomm Linux kernel for the supported machines by default.
The `meta-qcom-realtime` layer applies the changes on top of the
existing layer. During the kernel build, `meta-qcom-realtime` layer
appends the upstream `PREEMPT_RT` patches based on the kernel version,
and allows real-time configurations.
Note
- Use [linux-qcom-custom-rt_6.6.bb](https://github.com/quic-yocto/meta-qcom-realtime/blob/kirkstone/recipes-kernel/linux/linux-qcom-custom-rt_6.6.bb) for custom BSP.
- Use [linux-qcom-base-rt_6.6.bb](https://github.com/quic-yocto/meta-qcom-realtime/blob/kirkstone/recipes-kernel/linux/linux-qcom-base-rt_6.6.bb) for base BSP.
The following is the sample code for the RT base reference file:
require recipes-kernel/linux/linux-qcom-base_6.6.bb
SECTION = "RT kernel"
SUMMARY = "Linux Real time kernel for QCOM devices"
DESCRIPTION = "Recipe to build real time Linux kernel"
LICENSE = "GPLv2.0-with-linux-syscall-note"
S = "${WORKDIR}/git"
KERNEL_CONFIG_FRAGMENTS:append = " ${WORKDIR}/qcom_rt.cfg"
# Apply qcom patches
require ${BPN}/configs.inc
require ${BPN}/rt-patch.inc
Copy to clipboard
For more information about supported machines, see [Identify supported Qualcomm machines](https://docs.qualcomm.com/doc/80-70033-3/topic/getting_started_chapter2.html#supported-machines).
The base and custom recipes in `meta-qcom-realtimes` perform the following actions to set up the RT workspace:
- Fetch and apply RT patches hosted in Linux foundation repositories.
- Update the kernel `defconfig` to enable preempt RT-related configurations.
- Customize the kernel command-line.
- Include the RT test suite package.
- Run the presetting service to apply kernel tuning for RT performance.
## Kernel configuration for RT kernel
Optional and mandatory kernel configurations are used in the RT kernel.
To enable full preemption in the RT kernel, use `CONFIG_PREEMPT_RT`.
The `CONFIG_PREEMPT_RT` flag is enabled by default as part of the
`linux-qcom-base-rt_6.6.bb` recipe.
The following example shows the kernel configuration:
# CONFIG_PREEMPT_RT
zcat proc/config.gz | grep CONFIG_PREEMPT
# CONFIG_PREEMPT_NONE is not set
# CONFIG_PREEMPT_VOLUNTARY is not set
# CONFIG_PREEMPT is not set
CONFIG_PREEMPT_RT=y
Copy to clipboard
To optimize the RT kernel response, use the following configurations:
# CONFIG_NO_HZ
zcat proc/config.gz | grep NO_HZ
CONFIG_NO_HZ_COMMON=y
# CONFIG_NO_HZ_IDLE is not set
CONFIG_NO_HZ_FULL=y
# CONFIG_NO_HZ is not set
#CONFIG_CPUSETS
zcat proc/config.gz | grep CPUSETS
CONFIG_CPUSETS=y
Copy to clipboard
Set the following kernel configuration options when affining the RT
task:
- `CONFIG_NO_HZ_COMMON` - When enabled, it configures the kernel infrastructure for tickless operation.
- `CONFIG_NO_HZ_FULL` - When enabled, it configures the kernel to avoid sending scheduling-clock interrupts to CPUs with a single runnable task.
- `CONFIG_CPUSETS` - Use the `CONFIG_CPUSETS` configuration option
to enable `cpuset`, where the CPU is grouped to form a set.
Note
The `meta-qcom-realtime` layer enables `CONFIG_NO_HZ_IDLE` by default and keeps `NO_HZ_FULL` disabled.
When affining the RT task to a set of CPUs, use the `CONFIG_CPUSETS` configuration option:
**Figure: RT kernel verification**
## Build a RT kernel
To build the RT kernel, run the following commands:
MACHINE=-- DISTRO=qcom-wayland QCOM_SELECTED_BSP=base source setup-environment
#verify realtime layer is present
bitbake-layers show-layers | grep realtime
meta-qcom-realtime /layers/meta-qcom-realtime 12
# compile
bitbake qcom-console-image
Copy to clipboard
## Test RT kernel
A suite of tests is available in the Linux foundation RT test suite.
The cyclic test determines the best- and worst-case latencies for an RT
application.
1. Access the RT test suite source code at [rt-tests/rt-tests.git](https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git/).
2. To include the RT test suites as a part of the image, change the `layer.conf` file in the standard Yocto build:
IMAGE_INSTALL:append = "rt-tests numactl"
Copy to clipboard
3. Run the cyclic test as follows, where core 7 is the highest performing core in the SoC.
cyclictest -a 7 -t 1 -m -l 100000000 -i 1000 -p 95 -h 100
Copy to clipboard
Note
During standard evaluation, run the cyclic test on a single core.
For more information, see [RT-Tests](https://wiki.linuxfoundation.org/realtime/documentation/howto/tools/rt-tests).
The following table lists the cyclic test performance use cases:
| **Device** | **Cyclic test use cases (Time in 24 hours)** | **Minimum latency (µs)** | **Avg latency (µs)** | **Max latency (µs)** |
| --- | --- | --- | --- | --- |
| QCS6490 | No load | 1 | 2 | 11 |
| QCS6490 | Stress-NG | 1 | 2 | 15 |
| IQ-8275 | No load | 1 | 2 | 16 |
| IQ-8275 | Stress-NG | 2 | 3 | 19 |
| IQ-9075 | No load | 1 | 2 | 7 |
| IQ-9075 | Stress-NG | 1 | 2 | 7 |
| | | | | |
## Tune RT kernel
Tune the RT kernel to achieve deterministic latency for RT tasks on the device.
The RT kernel tuning process customizes the kernel command-line and adjusts the parameters through the `sysfs` interface. Some tuning targets on the RT cores, while other adjustments apply to the entire system. The following points describe RT‑specific tuning that enhances real‑time behavior:
- Identify the highest performing core in the system and determine the highest frequency at which the core can run continuously for at least 24 hours without triggering thermal throttling.
- Set the frequency for the selected core or cluster to the identified value, disable DCVS on that core or cluster, and configure it to run with the *performance* governor.
CPU in performance for policy in /sys/devices/system/cpu/cpufreq/policy*;
do
if [ -w "$policy/scaling_governor" ];
then
echo performance > "$policy/scaling_governor"
fi
done
Copy to clipboard
- Specify the `cpumask` for all kernel work queues to prevent them from running on the identified and designated RT core.
>
>
> Affine kernel worqueue to housekeeping cpus
> for wq in /sys/devices/virtual/workqueue/*; do
> if [ -w "$wq/cpumask" ]; then
> echo 7F > "$wq/cpumask"
> fi
> done
> Copy to clipboard
- Ensure that all IRQs are directed to the non‑RT cores and set the `irq_affinity` mask in the kernel command-line. For example, `irqaffinity=0-2,4-7` indicates kernel not to dispatch any IRQs on CPU 3. The following example shows how to migrate the IRQs after boot using `sysfs` interface:
# CPUs to ALLOW handling IRQs (i.e. system CPUs/non-RT CPUs)
ALLOW_CPUS="0,1,2,4,5,6,7"
# Convert list to hex bitmask
cpu_list_to_mask() {
CPUs="$1"
MASK=0
for cpu in $(echo $CPUs | tr ',' ' '); do
MASK=$((MASK | (1 << cpu)))
done
printf "%x\n" "$MASK"
}
MASK=$(cpu_list_to_mask "$ALLOW_CPUS")
echo "Setting IRQ affinity to CPUs: $ALLOW_CPUS (mask=0x$MASK)"
# Loop through all IRQs and update their affinity
for irq in /proc/irq/[0-9]*; do
irq_num=$(basename "$irq")
smp_file="$irq/smp_affinity"
if [ -w "$smp_file" ]; then
echo "$MASK" > "$smp_file" 2>/dev/null || echo "️ masking Failed for $irq_num"
else
echo "Skipping IRQ $irq_num (permission denied or not movable)"
fi
done
Copy to clipboard
- Disable LPM modes to eliminate LPM wake-up latencies on the RT core using `cpuidle.off=1` in the kernel command-line. Use the following example to disable the LPM modes through `sysfs` interface:
disable cpu-idle
for cpu in /sys/devices/system/cpu/cpu[0-7]*; do
for state in 0 1 2; do
file="$cpu/cpuidle/state${state}/disable"
if [ -w "$file" ]; then
echo 1 > $file
fi
done
done
Copy to clipboard
- Isolate the RT core to exclude it from scheduling decisions using `isolcpus=3` in the kernel command-line. For example, `isolcpus=3` indicates that the logical core 3 is isolated, and is excluded from scheduling decisions.
- Tune RT earmarked CPUs to prevent RCU callbacks from running on the RT core using `rcu_nocbs=3` in the kernel command-line. For example, `rcu_nocbs=3` indicates kernel to exclude logical core 3 from running RCU callbacks.
- The following are the additional system level tuning for improved RT performance:
>
>
> disable tracing
> echo 0 > /sys/kernel/tracing/tracing_on
>
> disable timer migration
> echo 0 > /proc/sys/kernel/timer_migration
>
> disable RT Throttling
> echo -1 > /proc/sys/kernel/sched_rt_runtime_us
> Copy to clipboard
Last Published: Sep 29, 2026
[Previous Topic
Configure the pinctrl driver](https://docs.qualcomm.com/bundle/publicresource/80-70033-3/topics/pinctrl-configuration.md) [Next Topic
Enable virtualization](https://docs.qualcomm.com/bundle/publicresource/80-70033-3/topics/virtualization.md)
Source: [https://docs.qualcomm.com/doc/80-70033-3/topic/real_time_kernel_overview.html](https://docs.qualcomm.com/doc/80-70033-3/topic/real_time_kernel_overview.html)