Buconos

Mastering Cache Aware Scheduling in Linux Kernel 7.2: A Step-by-Step Guide

Published: 2026-05-21 07:32:40 | Category: Linux & DevOps

Overview

Modern CPUs are no longer simple single-core designs. They often feature multiple last-level caches (LLCs) shared among different core clusters. This architectural shift poses a challenge for the Linux scheduler: it must decide not only which core to run a task on, but also which cache domain to place it in. The upcoming Linux kernel 7.2 brings a long-awaited solution: Cache Aware Scheduling (CAS). By enabling the CONFIG_SCHED_CACHE kernel configuration option, the scheduler gains awareness of cache hierarchies, reducing cache misses and improving overall system performance, especially on multi-socket and hybrid processor architectures.

Mastering Cache Aware Scheduling in Linux Kernel 7.2: A Step-by-Step Guide

This tutorial guides you through the entire process—from understanding the fundamentals to enabling Cache Aware Scheduling on your system. Whether you're a kernel developer, a system administrator, or an enthusiast eager to squeeze more performance out of your hardware, you'll find clear, actionable instructions.

Prerequisites

Before jumping into the kernel configuration, ensure your environment meets the following requirements:

  • Linux kernel source tree – You need the kernel source code from the tip branch (where CAS code has been merged). Clone the official repository: git clone git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
  • Build tools – Install essential packages: build-essential (Debian/Ubuntu), base-devel (Arch), or equivalent. Also install libncurses-dev for menuconfig, flex, bison, and openssl-dev for module signing.
  • Bootloader configuration skills – Familiarity with GRUB (or your bootloader) to add the new kernel to the boot menu.
  • Backup – Always back up your current kernel and boot configuration before attempting a custom build.

Step-by-Step Instructions

1. Clone the TIP Branch and Check Out the CAS Code

The Cache Aware Scheduling patches are part of the sched/core branch of the TIP tree. Start by cloning:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
cd tip
git checkout sched/core

This branch includes the CONFIG_SCHED_CACHE option alongside other scheduler improvements. Verify by checking the kernel version string—it should be 6.2-rc1 or later (the 7.2 merge window begins in about one month from the original announcement).

2. Configure the Kernel with Cache Aware Scheduling

Run the configuration interface of your choice. We recommend make menuconfig for a text-based yet user-friendly approach:

make menuconfig

Navigate to General setupKernel FeaturesScheduler features. Look for the option "Cache Aware Scheduling" (CONFIG_SCHED_CACHE). Enable it by pressing Y. If you prefer to build your kernel using a .config file, you can add the line manually:

CONFIG_SCHED_CACHE=y

For most systems, leaving other scheduler options at their defaults is fine. However, you may also want to enable CONFIG_SCHED_MC (multi-core scheduler domain) and CONFIG_SCHED_SMT (simultaneous multithreading) for full cache topology awareness.

3. Build the Kernel and Modules

With the configuration ready, compile the kernel and its modules:

make -j$(nproc)
make modules_install

The -j flag speeds up compilation by using all available CPU cores. This step can take anywhere from 10 minutes to an hour depending on your hardware.

4. Install the New Kernel

Copy the kernel image and System.map to the /boot directory:

cp arch/x86/boot/bzImage /boot/vmlinuz-7.2-cas
cp System.map /boot/System.map-7.2-cas

Generate the initramfs (initial RAM filesystem) using your distribution's tool. For example, on Debian/Ubuntu:

mkinitramfs -o /boot/initrd.img-7.2-cas 7.2-cas

Update your bootloader. For GRUB, run:

update-grub

5. Reboot and Verify

Select the new kernel entry from the GRUB menu during boot. Once logged in, confirm that Cache Aware Scheduling is active:

cat /proc/schedstat | head -10

Look for a line containing cache_domain or llc_domain. Alternatively, check through ls /sys/kernel/debug/sched/ (requires debugfs mounted). You can also inspect the kernel config at runtime:

zgrep CONFIG_SCHED_CACHE /proc/config.gz

You should see CONFIG_SCHED_CACHE=y.

6. Benchmark Performance

To appreciate the improvement, run a cache-intensive workload with and without CAS. Tools like perf stat can measure cache-miss ratios. For example:

perf stat -e cache-misses,cache-references your_workload

Compare the numbers between a kernel built with CONFIG_SCHED_CACHE and one without. On CPUs with multiple last-level caches (e.g., Intel Raptor Lake or AMD EPYC), you can expect a noticeable reduction in misses.

Common Mistakes

Mistake 1: Using the Wrong Kernel Source

The CAS code is not yet in mainline. Do not use the stable kernel from kernel.org. Always use the tip repository's sched/core branch. A common error is cloning torvalds/linux.git and expecting CONFIG_SCHED_CACHE to appear—it won't.

Mistake 2: Forgetting to Enable Cache Topology Discovery

The CAS feature relies on accurate cache topology information from ACPI or device tree. Make sure your kernel has CONFIG_ACPI and CONFIG_SCHED_MC enabled. Without them, the scheduler may not see the multiple LLCs.

Mistake 3: Not Updating the Bootloader

After copying the kernel and initramfs, failing to run update-grub (or the equivalent) means you won't see the new kernel entry. You'll end up booting the old kernel and wondering why CAS isn't active.

Mistake 4: Ignoring Module Dependencies

If your hardware requires proprietary or out‑of‑tree modules (e.g., NVIDIA drivers), they must be rebuilt against the new kernel. Otherwise, you may experience boot failures or missing functionality.

Summary

Cache Aware Scheduling for Linux 7.2 is a groundbreaking enhancement that optimizes task placement on modern CPUs with multiple last-level caches. By following the steps outlined—cloning the TIP branch, enabling CONFIG_SCHED_CACHE, compiling and installing the kernel, and verifying success—you can unlock significant performance gains. Avoid the common pitfalls of wrong source trees, incomplete topology configuration, and missing bootloader updates. With this guide, you're well on your way to a faster, more cache‑efficient Linux system.