How Linux Handles Symmetric Multiprocessing

This article explores how the Linux operating system manages symmetric multiprocessing (SMP), an architecture where multiple processor cores share a unified physical memory and system bus. Linux treats all available CPU cores symmetrically, leveraging advanced process scheduling, fine-grained concurrency controls, inter-processor communication, and memory topology awareness to distribute computational workloads efficiently while preventing resource conflicts.

The Evolution Away from the Giant Kernel Lock

In early versions of Linux SMP support, the kernel relied heavily on the Big Kernel Lock (BKL). This coarse-grained locking mechanism allowed only one processor core to execute kernel-space code at any given time. While simple, it caused significant bottlenecks as CPU core counts increased. Modern Linux kernels have entirely eliminated the BKL, replacing it with fine-grained synchronization primitives such as spinlocks, read-write locks, mutexes, and Read-Copy-Update (RCU). These primitives allow multiple cores to execute kernel routines simultaneously, provided they are not modifying the exact same kernel data structures.

Distributed Scheduling and Load Balancing

Linux handles workload distribution primarily through the scheduler—predominantly the Completely Fair Scheduler (CFS) and the newer Earliest Eligible Virtual Deadline First (EEVDF) scheduler. Under SMP:

Cache Affinity and NUMA Awareness

Migrating a process to a different CPU invalidates the task's cache data stored in L1 and L2 caches, resulting in memory latency penalties. To mitigate this, Linux enforces soft CPU affinity:

Inter-Processor Interrupts (IPIs)

Independent cores must communicate to maintain system-wide state coherence. Linux utilizes Inter-Processor Interrupts (IPIs) at the hardware level for several critical coordination tasks: