24059
Hardware

A Step-by-Step Guide to Intel's Cache Aware Scheduling on Linux

Posted by u/Yogawife · 2026-05-15 02:41:56

Introduction

Intel's Cache Aware Scheduling (CAS) is a kernel optimization that improves CPU task distribution by considering how each core shares its cache with others. For over a year, Intel engineers have been developing and testing these patches, showing significant performance gains on both Intel and AMD processors. While the patches are not yet merged into the mainline Linux kernel, they are getting closer. This guide walks you through understanding, enabling, and testing CAS on your Linux system—whether you are a kernel developer, a performance enthusiast, or just curious about what's coming next.

A Step-by-Step Guide to Intel's Cache Aware Scheduling on Linux

What You Need

  • A Linux system with root access (physical or virtual machine).
  • Basic familiarity with compiling a custom kernel.
  • The latest CAS patch series from the Linux kernel mailing list (LKML). As of this writing, the patches are posted by Intel engineers; search for "Cache Aware Scheduling" or the sched/core branch.
  • Kernel source tree (e.g., git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git).
  • Essential build tools: build-essential, ncurses-dev, libssl-dev, etc.
  • Atom processor or multi-core CPU (AMD or Intel) to see benefits.

Step-by-Step Guide

Step 1: Understand Cache Topology

Before applying patches, familiarize yourself with your system's cache hierarchy. Run lscpu and lstopo (from hwloc package) to see which cores share L2 and L3 caches. CAS uses this information to place tasks on cores that minimize cache contention. For example, on an AMD Zen 2 processor, each CCX has its own L3; CAS avoids spreading a workload across CCXs if it fits in one.

Step 2: Check Kernel Version

Current CAS patches target the latest mainline kernel (e.g., 6.x). Verify your kernel version with uname -r. If you are on an older LTS kernel, you may need to backport the patches or use a development branch. The patchset often includes changes to kernel/sched/ and include/linux/sched/.

Step 3: Obtain the CAS Patches

Go to the LKML archives (lore.kernel.org) and search for the most recent CAS patch series. Alternatively, find the repository maintained by Intel's scheduler team. Download the patches as a mbox file or apply them via git am. Make sure you have the correct base commit—usually the tip of Linus's tree.

Step 4: Apply and Build the Kernel

  1. Change to your kernel source directory: cd linux
  2. Apply the patches: git am /path/to/patches/*.patch (or patch -p1 < patch_file)
  3. Configure the kernel: make menuconfig. Ensure CONFIG_SCHED_CACHE_AWARE is enabled (under Processor Type and Features). Save and exit.
  4. Build the kernel: make -j $(nproc). Install modules: sudo make modules_install. Install the kernel: sudo make install.
  5. Update bootloader (e.g., sudo update-grub) and reboot into the new kernel.

Step 5: Verify CAS is Active

After boot, check dmesg | grep -i cache for messages about "Cache Aware Scheduling". Also examine /sys/kernel/debug/sched_features (if debugfs is mounted) for the CACHE_AWARE flag. You can also run cat /proc/schedstat to see whether migration counts change.

Step 6: Run Performance Tests

Use benchmarks that benefit from cache locality, such as Phoronix Test Suite tests like CacheBench or memcached. Compare results between a kernel with and without CAS. Intel's internal tests show up to 15% improvement on memory-bound workloads. For AMD CPUs, similar gains appear in workloads that span multiple CCX domains.

Step 7: Tune Parameters (Optional)

CAS introduces new sysctl knobs (kernel.sched_cache_aware_*). Adjust them via sysctl -w to fine-tune aggressiveness. For instance:

sudo sysctl kernel.sched_cache_aware_migration_delay=5

Refer to the documentation (usually in Documentation/scheduler/) for details.

Tips

  • Start with a test environment. Compile a custom kernel on a non-production machine or virtual machine to avoid downtime.
  • Monitor cache misses. Use perf stat -e cache-misses,cache-references to see if CAS reduces cache contention.
  • Be patient with mainline integration. The patches are near completion, but Intel engineers continue to refine them. Watch LWN.net or LKML for updates.
  • Consider alternative implementations. Some distributions (e.g., Clear Linux) already ship with early CAS patches. You may test there first.
  • Share your results. Post your benchmarks on the kernel mailing list to help the community validate the work.

Intel's Cache Aware Scheduling is a promising addition that will soon land in the upstream kernel. By following this guide, you can be among the first to experience its benefits on your hardware today.