Chapter 8: Resource Isolation Strategies
Chapter 8: Resource Isolation Strategies
The primary objective of running multiple kernels on a single physical host is to eliminate cross-workload interference (the “noisy neighbour” effect). On high-performance hardware, interference rarely arises from raw CPU cycle exhaustion; rather, it manifests in shared resource contention: CPU cache thrashing, interrupt routing disruptions, NUMA interconnect saturation, and storage queue locking. This chapter details kernel tuning and isolation primitives to achieve deterministic performance.
CPU Isolation: isolcpus, nohz_full, rcu_nocbs
Linux kernels provide specialized boot parameters to shield specific CPU cores from general operating system interference:
isolcpus=domain,managed_irq,<cpulist>:- Removes the specified cores from the kernel’s Completely Fair Scheduler (CFS/EEVDF) load-balancing domains.
- The kernel will never automatically place or migrate any process onto these cores. Only tasks explicitly bound via
taskset,sched_setaffinity(), or cpusets will execute here.
nohz_full=<cpulist>:- Puts specified cores into adaptive-ticks mode.
- When exactly one task is running on an isolated core, the periodic scheduling timer tick (\(1000\text{ Hz}\) or \(250\text{ Hz}\)) is completely turned off, eliminating timer interrupt jitter.
rcu_nocbs=<cpulist>:- Offloads Read-Copy-Update (RCU) callback invocations to housekeeping cores. RCU processing threads will never execute on isolated cores, preserving strict CPU execution budgets.
Example host kernel boot line:
isolcpus=domain,managed_irq,16-31 nohz_full=16-31 rcu_nocbs=16-31
Cpusets and Cgroup-Based CPU Management
Cgroups v2 cpuset controllers provide dynamic hierarchical partitioning of CPU cores and memory nodes:
# 1. Create a dedicated cpuset for the primary management stack
sudo mkdir -p /sys/fs/cgroup/management
echo "0-15" | sudo tee /sys/fs/cgroup/management/cpuset.cpus
echo "0" | sudo tee /sys/fs/cgroup/management/cpuset.mems
# 2. Create an isolated cpuset partition for secondary kernel worker instances
sudo mkdir -p /sys/fs/cgroup/isolated-workers
echo "root" | sudo tee /sys/fs/cgroup/isolated-workers/cpuset.cpus.partition
echo "16-31" | sudo tee /sys/fs/cgroup/isolated-workers/cpuset.cpus
echo "1" | sudo tee /sys/fs/cgroup/isolated-workers/cpuset.memsSetting cpuset.cpus.partition to root marks these cores as an isolated partition, preventing any child or parent groups from sharing those CPU resources.
Memory Isolation and NUMA Policies
Cross-socket memory accesses incur severe interconnect delays and bandwidth throttling:
- Strict NUMA Allocation: Bind memory strictly to Node 1 via
numactl --membind=1. If memory is exhausted on Node 1, allocations fail immediately rather than allocating slow remote memory from Node 0. - Hugepages Isolation: Pre-allocate 1GB hugepages at boot time. Hugepages bypass the kernel’s transparent hugepage (THP) daemon (
khugepaged), eliminating memory compaction and page migration overhead.
Interrupt Routing and IRQ Affinity
By default, the irqbalance daemon distributes hardware interrupts across all available CPU cores:
The Problem: A high-volume network interface or storage controller can fire 100,000+ interrupts per second, repeatedly interrupting tasks executing on isolated cores.
The Solution: Mask isolated cores out of the
irqbalancebanned list, and pin device interrupts explicitly via/proc/irq/<irq>/smp_affinity:# Exclude cores 16-31 from irqbalance in /etc/default/irqbalance IRQBALANCE_BANNED_CPUS="00000000,ffff0000" # Manually route host management NIC interrupts to Core 0 echo 1 | sudo tee /proc/irq/42/smp_affinity
I/O Scheduling and Storage Contention
When storage devices are shared (rather than passed through via dedicated NVMe controllers):
- I/O Scheduler Selection: Use
none(passthrough) for high-speed NVMe drives to eliminate kernel I/O scheduling latency. Usebfqormq-deadlineon slower SATA SSDs to enforce fair queuing. - I/O Weight and Throttling: Use cgroup v2
io.weightandio.maxto prevent batch background processes in one kernel environment from starving low-latency transactions in another.