Documentation: real-time: Add boot parameters and task isolation section
Subsystems (2)
PATCH v5 1/1 Documentation: real-time: Add boot parameters and task isolation section
Document the boot parameters and runtime tunables that affect the worst-case latency of a real-time system, alongside the existing kernel configuration guidance.
Cover CPU isolation, nohz_full, RCU callback offloading, interrupt affinity, and C-state limits, with references to the relevant documentation. Keep the C-state parameters next to CONFIG_CPU_IDLE and the tickless trade-off next to CONFIG_NO_HZ, so each option stays with its configuration guidance.
---
Thanks Sebastian for the review.
v4 -> v5:
- Drop the fixed 1-9 range for intel_idle.max_cstate; the maximum C-state depth is platform dependent.
- Move the residual 1 Hz tick and workqueue details to the isolcpus=nohz description, matching kernel-parameters.rst, and document that the global workqueue runs on all CPUs by default and needs manual affinity or the domain flag.
- Shorten the nohz_full= entry accordingly.
- Clarify the rcu_nocbs= and CONFIG_RCU_NOCB_CPU_DEFAULT_ALL interaction.
Testing:
make SPHINXDIRS="core-api" htmldocs and checkpatch.pl pass.
The host boot, latency, and QEMU C-state observations from v4 are unchanged.
--- .../real-time/kernel-configuration.rst | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+)
Documentation/core-api/real-time/kernel-configuration.rst +132 -0
@@ -98,6 +98,11 @@ can be achieved by using the boot parameter [1]_:: processor.max_cstate=1 +On x86 systems using ``intel_idle``, the ``intel_idle.max_cstate=`` boot +parameter sets the maximum C-state depth. A value of 0 disables +``intel_idle`` and falls back to ``acpi_idle``; it does not disable +C-states. + Higher C-states can be acceptable depending on the user workload's latency requirements. For ACPI-based platforms, use the ``cpupower idle-info`` command to inspect the available idle states.
@@ -179,6 +184,9 @@ the extra accounting and state book-keeping. ``NO_HZ_FULL`` may be beneficial. In such cases, users should offload the kernel housekeeping to dedicated CPUs and isolate compute cores. +``nohz_full=`` enables tickless operation for a set of CPUs; see +:ref:`real_time_boot_parameters` for its interaction with ``isolcpus=``. + See also Documentation/timers/no_hz.rst ``CONFIG_PREEMPT_RT``
@@ -190,6 +198,39 @@ See also Documentation/timers/no_hz.rst This option must be enabled, or the resulting kernel will not be fully preemptible and real-time capable. +``CONFIG_RCU_NOCB_CPU`` +------------------------- + +:Expectation: allowed +:Severity: *info* + +Enable support for offloading RCU callback invocation from selected CPUs +to per-CPU ``rcuo`` kthreads. The offload is selected with ``rcu_nocbs=``, +implied by ``nohz_full=``, or enabled for all CPUs by +``CONFIG_RCU_NOCB_CPU_DEFAULT_ALL`` when neither parameter is given. +Enabling this option alone does not change callback placement. Use it +when RCU callback processing causes jitter on CPUs dedicated to +latency-sensitive tasks. See Documentation/admin-guide/cpu-isolation.rst. + +``rcu_nocbs[=cpu-list]`` + Offload RCU callback invocation from the listed CPUs to the + corresponding ``rcuo`` kthread, which can run on a housekeeping CPU. + This reduces callback-processing jitter on the CPU that enqueued them. + On a non-real-time kernel this also moves invocation out of softirq + context; with PREEMPT_RT, callbacks already run in kthread context + because ``rcutree.use_softirq`` is false, and the offload only changes + where they run. If the parameter is given without a CPU list, no CPU + is offloaded at boot; the mode can still be toggled at runtime through + cpusets. The parameter takes precedence over + ``CONFIG_RCU_NOCB_CPU_DEFAULT_ALL``. + +``rcu_nocb_poll`` + Make the ``rcuo`` kthreads poll for callbacks instead of requiring the + offloaded CPUs to wake them. This improves the real-time response at + the cost of higher power consumption, because the kthreads wake up + periodically to do the polling. Consider this option only when wakeup + latency matters more than power. + ``CONFIG_TRACING`` (and tracing options) ----------------------------------------
@@ -216,6 +257,97 @@ just by being enabled. These tracers do incur measurable latency overhead even when tracing is not currently active. +.. _real_time_boot_parameters: + +Boot parameters and task isolation +================================== + +Kernel configuration options alone do not determine a real-time system's +worst-case latency. Integrators commonly rely on boot parameters and +runtime tunables as well, to keep kernel housekeeping work away from +latency-sensitive tasks. The parameters below complement the options +described above. Some of them correspond to a configuration option and +are referenced from that option's section, so the configuration and +runtime guidance stay together. Each one is documented in detail in +Documentation/admin-guide/kernel-parameters.rst; the notes here focus on +the aspects that matter for real-time latency. Consider these options +only when the workload suffers from the corresponding interference; +leave them disabled otherwise, as each of them trades flexibility or +power for a lower worst-case latency. The notes below follow the +decisions an integrator has to make: whether to keep tasks off a CPU, +whether to stop its tick, and where interrupts should run. Idle state +limits are discussed with ``CONFIG_CPU_IDLE`` above, and RCU callback +offloading with ``CONFIG_RCU_NOCB_CPU`` above. +For the full CPU isolation model and its limitations, see +Documentation/admin-guide/cpu-isolation.rst. + +.. caution:: + + CPU isolation is best effort. Work that is explicitly bound to an + isolated CPU, such as per-CPU kernel threads, bound workqueues, and + interrupts, may still run there unless it is steered away. Measure + the resulting latency with tools such as ``osnoise``, ``timerlat``, + and ``rtla`` rather than assuming that an isolated CPU is free of + kernel noise. See Documentation/timers/no_hz.rst and + Documentation/tools/rtla/index.rst. + +CPU isolation +------------- + +``isolcpus=`` + Format: ``[flag-list,]<cpu-list>``. Isolates the listed CPUs from the + disturbances selected by the flag list (default: ``domain``): + + ``domain`` + Remove the CPUs from the scheduler domains. This is the default + when no flag is given. Domain isolation cannot be undone at + runtime; use cpusets when the isolated CPU set must change + dynamically. Isolated CPUs remain usable through CPU affinity or + cpusets. Unbound workqueues and unbound kernel threads are + confined to the housekeeping CPUs as a side effect. Consider it + for CPUs dedicated to a latency-sensitive workload. + + ``nohz`` + Equivalent to ``nohz_full=``; see below. The residual 1 Hz tick is + offloaded to workqueues, which must be affine to the housekeeping + CPUs through the global workqueue ``cpumask`` + (/sys/devices/virtual/workqueue/cpumask). By default the global + workqueue runs on all CPUs; configure this cpumask manually after + boot, or use the ``domain`` flag to confine unbound workqueues. + + A practical configuration therefore combines ``isolcpus=`` with + ``nohz_full=``, ``rcu_nocbs=``, an interrupt affinity mask, and, on + x86 systems, a C-state limit. + + Timer placement follows the same choice. By default a migratable + timer expires on the CPU that armed it; with ``nohz`` (or + ``nohz_full=``), timers and hrtimers armed on the isolated CPUs are + migrated to housekeeping CPUs. + +``nohz_full=`` + Format: ``<cpu-list>``. Requires ``CONFIG_NO_HZ_FULL=y``. Stops the + scheduler tick on the listed CPUs whenever possible. The boot CPU is + forced outside the range to maintain timekeeping, and the RCU + callbacks of the listed CPUs are offloaded as if they had been + passed to ``rcu_nocbs=``; see the ``CONFIG_RCU_NOCB_CPU`` section + above. This parameter takes precedence over + ``CONFIG_RCU_NOCB_CPU_DEFAULT_ALL``. + + The trade-off between tickless operation and the kernel-to-userspace + transition latency is described in the ``CONFIG_NO_HZ`` / + ``CONFIG_NO_HZ_FULL`` section above. + +Interrupt affinity +------------------ + +``irqaffinity=`` + Format: ``<cpu-list>``. Sets the default affinity mask for + interrupts that do not have an explicit affinity, steering them to + the housekeeping CPUs. Managed interrupts are not affected by this + setting and cannot be redirected through ``/proc/irq/*``. Verify + the resulting placement in ``/proc/interrupts``. See + Documentation/core-api/irq/managed_irq.rst. + Kernel Debug Options ====================
Signature · 1 line
2.54.0
Hi Zixin,
Quoted 20 lines · Zixin Wang
Documentation/core-api/real-time/kernel-configuration.rst +20
-0+ +``rcu_nocbs[=cpu-list]`` + Offload RCU callback invocation from the listed CPUs to the + corresponding ``rcuo`` kthread, which can run on a housekeeping CPU. + This reduces callback-processing jitter on the CPU that enqueued them. + On a non-real-time kernel this also moves invocation out of softirq + context; with PREEMPT_RT, callbacks already run in kthread context + because ``rcutree.use_softirq`` is false, and the offload only changes + where they run. If the parameter is given without a CPU list, no CPU + is offloaded at boot; the mode can still be toggled at runtime through + cpusets. The parameter takes precedence over + ``CONFIG_RCU_NOCB_CPU_DEFAULT_ALL``. + +``rcu_nocb_poll`` + Make the ``rcuo`` kthreads poll for callbacks instead of requiring the + offloaded CPUs to wake them. This improves the real-time response at + the cost of higher power consumption, because the kthreads wake up + periodically to do the polling. Consider this option only when wakeup + latency matters more than power. +
...
Quoted 82 lines
+..
_real_time_boot_parameters:Documentation/core-api/real-time/kernel-configuration.rst +80
-0+ +Boot parameters and task isolation +================================== + +Kernel configuration options alone do not determine a real-time system's +worst-case latency. Integrators commonly rely on boot parameters and +runtime tunables as well, to keep kernel housekeeping work away from +latency-sensitive tasks. The parameters below complement the options +described above. Some of them correspond to a configuration option and +are referenced from that option's section, so the configuration and +runtime guidance stay together. Each one is documented in detail in +Documentation/admin-guide/kernel-parameters.rst; the notes here focus on +the aspects that matter for real-time latency. Consider these options +only when the workload suffers from the corresponding interference; +leave them disabled otherwise, as each of them trades flexibility or +power for a lower worst-case latency. The notes below follow the +decisions an integrator has to make: whether to keep tasks off a CPU, +whether to stop its tick, and where interrupts should run. Idle state +limits are discussed with ``CONFIG_CPU_IDLE`` above, and RCU callback +offloading with ``CONFIG_RCU_NOCB_CPU`` above. +For the full CPU isolation model and its limitations, see +Documentation/admin-guide/cpu-isolation.rst. + +.. caution:: + + CPU isolation is best effort. Work that is explicitly bound to an + isolated CPU, such as per-CPU kernel threads, bound workqueues, and + interrupts, may still run there unless it is steered away. Measure + the resulting latency with tools such as ``osnoise``, ``timerlat``, + and ``rtla`` rather than assuming that an isolated CPU is free of + kernel noise. See Documentation/timers/no_hz.rst and + Documentation/tools/rtla/index.rst. + +CPU isolation +------------- + +``isolcpus=`` + Format: ``[flag-list,]<cpu-list>``. Isolates the listed CPUs from the + disturbances selected by the flag list (default: ``domain``): + + ``domain`` + Remove the CPUs from the scheduler domains. This is the default + when no flag is given. Domain isolation cannot be undone at + runtime; use cpusets when the isolated CPU set must change + dynamically. Isolated CPUs remain usable through CPU affinity or + cpusets. Unbound workqueues and unbound kernel threads are + confined to the housekeeping CPUs as a side effect. Consider it + for CPUs dedicated to a latency-sensitive workload. + + ``nohz`` + Equivalent to ``nohz_full=``; see below. The residual 1 Hz tick is + offloaded to workqueues, which must be affine to the housekeeping + CPUs through the global workqueue ``cpumask`` + (/sys/devices/virtual/workqueue/cpumask). By default the global + workqueue runs on all CPUs; configure this cpumask manually after + boot, or use the ``domain`` flag to confine unbound workqueues. + + A practical configuration therefore combines ``isolcpus=`` with + ``nohz_full=``, ``rcu_nocbs=``, an interrupt affinity mask, and, on + x86 systems, a C-state limit. + + Timer placement follows the same choice. By default a migratable + timer expires on the CPU that armed it; with ``nohz`` (or + ``nohz_full=``), timers and hrtimers armed on the isolated CPUs are + migrated to housekeeping CPUs. + +``nohz_full=`` + Format: ``<cpu-list>``. Requires ``CONFIG_NO_HZ_FULL=y``. Stops the + scheduler tick on the listed CPUs whenever possible. The boot CPU is + forced outside the range to maintain timekeeping, and the RCU + callbacks of the listed CPUs are offloaded as if they had been + passed to ``rcu_nocbs=``; see the ``CONFIG_RCU_NOCB_CPU`` section + above. This parameter takes precedence over + ``CONFIG_RCU_NOCB_CPU_DEFAULT_ALL``. + + The trade-off between tickless operation and the kernel-to-userspace + transition latency is described in the ``CONFIG_NO_HZ`` / + ``CONFIG_NO_HZ_FULL`` section above. + +Interrupt affinity
Documentation/core-api/real-time/kernel-configuration.rst just by being enabled. · line 350
Quoted 10 lines
Documentation/core-api/real-time/kernel-configuration.rst +10
-0+------------------ + +``irqaffinity=`` + Format: ``<cpu-list>``. Sets the default affinity mask for + interrupts that do not have an explicit affinity, steering them to + the housekeeping CPUs. Managed interrupts are not affected by this + setting and cannot be redirected through ``/proc/irq/*``. Verify + the resulting placement in ``/proc/interrupts``. See + Documentation/core-api/irq/managed_irq.rst. +
Thanks for the write-up above.
I wrote the RT configuration guide some time ago, where "configuration" here implied kconfig build-time .config generation.
It is true, of course, that "kernel configuration options alone do not determine a real-time system's worst-case latency". But this does not mean that all the RT optimization tricks above must be squeezed together into the kernel RT /configuration/ guide.
There's also a kernel configuration checker that produces lots of links to this guide:
https://msgid.link/[email protected]
So I don't think that expanding the scope of this document into overall RT optimizations tricks will help.
Since the whole of Documentation/real-time/ is dedicated to PREEMPT_RT, why not integrate these RT-optimization information into a proper guide there?
Then, let this configuration guide link to the relevant sections only when necessary. This way, scope creep is avoided.
Thanks!
--
Ahmed S. Darwish
Linutronix GmbH
Hi Ahmed,
Thanks for the review and for pointing out the scope issue. I have sent v6, which moves the runtime tuning material out of kernel-configuration.rst into a new Documentation/core-api/real-time/runtime-tuning.rst, and keeps the configuration guide focused on Kconfig options.
The existing CONFIG_* section headings and anchors in kernel-configuration.rst are unchanged, so the documentation links generated by kconfig-checker remain valid. I ran the preempt_rt rules from your v1 checker (reconstructed in the 7.3.5 tree, since the tool is not merged there): all 12 generated documentation URLs resolve to anchors in the built HTML.
The C-state, EFI runtime, CPU isolation, RCU offload, and interrupt affinity content from v5 is now in the runtime tuning guide, and the configuration guide links to the relevant sections.
Thanks,
Zixin