The core idea. An operating system turns one machine into many private ones: every program gets its own memory, a share of the CPUs and handles on files and devices, all owned by one kernel that the program can reach only through a system call. A training job runs at full speed between those crossings and pays at each one: a system call, a page fault, a context switch, a CPU-quota stall, an fsync, a VM exit.
python train.py (PID 13, 5 threads) and its two worker processes (PIDs 19 and 21, 4 threads each), on the glass plate of user space. Below it the kernel, which alone touches the hardware: the CPUs, RAM, the drive and the GPU. A program runs on the CPU directly, in user mode, and the kernel regains control only at a system call, a fault or an interrupt (OSTEP's limited direct execution). Owner: Processes and the system-call API, whose Fig. 1 draws these processes over their kernel records.svc #0, syscall) and comes back as a number: 281 ns for getppid here, against 1.3 ns for a function call. CPython, libtorch and glibc all end in the same few hundred calls (the Syscall tracer records them). Section 1 prices every crossing; Fig. 2 on Processes follows one os.read() down and back.del (section 5). Owner: Memory allocators, Fig. 1.torch.save's write() returns once the bytes are in the page cache (1.4 µs for 4 KiB); only fsync waits for the drive (1,305 µs), and only fsync and rename decide what a crash leaves (section 7). Owner: Storage and file systems, Fig. 1; the safe save is its Fig. 5.--cpus 2 --memory 3g), on the one shared kernel (section 8). Owner: Containers and isolation, Fig. 1.nvidia.ko is entered by ioctl only for setup, allocation and errors. In a cloud VM a hypervisor sits under the kernel, and this lab runs in one too (section 9). Owner: Virtualization and the GPU driver stack, whose Fig. 10 takes one CUDA call down.A map, not a mechanism: each step lights the part one child page owns. PIDs, threads, RSS, PSS, the CPU count, the system-call cost and the futex count are this page's own runs (src/read/code/out/); the write and fsync costs are the ladder's, from Storage and file systems.
You need nothing beyond Python: this root starts from zero. Caches and the machine under the OS, from the programmer's side, are C++: the machine underneath.
| Page | What the kernel shares out | The mechanism, in one line | Where it bites a training job | Check first | Measured here |
|---|---|---|---|---|---|
| Processes and the system-call API | the right to run a program; handles on files, pipes and sockets | a process is a kernel record changed only by system calls: fork copies it, exec replaces the program, wait collects its end, a signal interrupts it | DataLoader start methods; SIGTERM that never reaches a shell-wrapped PID 1; zombie workers | ps -eo pid,ppid,stat,cmd, /proc/PID/status | first batch 0.021 s with fork, 0.836 s with spawn |
| Scheduling and CPU time | CPU time | a run queue per CPU; the fair class runs the thread with the least virtual runtime; a cgroup quota stops the whole group once spent | low GPU utilisation from throttled or oversubscribed DataLoader workers; thread pools sized from the host's CPU count | cpu.stat (nr_throttled), top -H | a nice-5 loop gets about a third of a CPU against nice 0 (its virtual runtime grows 3.06 times faster) |
| Virtual memory | physical memory | every address translated page by page through a tree of tables and the TLB; pages filled at first touch; fork shares pages copy-on-write | worker memory climbing as reference counts copy shared pages; exit 137 from the cgroup OOM killer | smaps_rollup (PSS, Private_Dirty), memory.events | fork + exit + wait grows about 19 microseconds per resident MiB |
| Memory allocators | memory inside one process | allocators buy big regions rarely and hand out small pieces often; freed memory stays with the allocator | RSS that never drops after del; "CUDA out of memory" with gigabytes reserved | memory_allocated against memory_reserved, tracemalloc | 1,562 KiB of live data held as 110,524 KiB of RSS |
| Concurrency | shared memory, and waiting | an atomic instruction for every shared update; a futex sleeps a thread only when a lock is contended; epoll or io_uring for I/O | a hang after fork with threads; the GIL capping Python threads | py-spy dump, strace -c -f | an uncontended lock is one atomic instruction (about 10 ns) |
| Storage and file systems | durable bytes on devices | writes land in the page cache and reach the device later; fsync and rename decide what a crash leaves | an empty or torn checkpoint after a crash; a slow first epoch | strace the save (fsync, rename, directory fsync); vmstat 1 | write() 1.4 us against fsync 1,305 us for one 4 KiB record |
| Containers and isolation | a private view and a budget on the one shared kernel | namespaces, cgroups, capabilities and seccomp, and an overlayfs image; no second kernel | exit 137; a full /dev/shm; the host's CPU count; untrusted code | /sys/fs/cgroup/memory.max, cpu.max | docker run --rm took about 0.4 s, of which the namespaces were about 4 ms |
| Virtualization and the GPU driver stack | the whole machine to guests; the GPU to processes | guest code runs on the CPU directly and exits only at boundaries; a CUDA launch is stores into mapped memory plus a doorbell | "CUDA driver version is insufficient"; sharing one GPU (MIG, MPS, time slicing) | nvidia-smi against torch.version.cuda | one VM exit costs about 0.92 µs |
Every number was measured on this topic's lab machine (below) by the page in the first column. OSTEP's three pieces map onto the rows: virtualization (processes, scheduling, virtual memory, allocators), concurrency, persistence (storage); containers, virtual machines and the GPU driver are beyond the book, and are where an ML job actually runs.
Every output on these pages was produced for real, on 2026-10-05, inside the Docker image kb-os-lab:1 (Debian 12, Python 3.11.2, PyTorch 2.14.1 CPU build), on Linux 5.10.104 running in Docker Desktop's virtual machine on an Apple M1 laptop with 5 CPUs and about 10 GB of memory: measured here. A virtual machine on a laptop is not a training server, so absolute numbers are this machine's, and ratios are the lesson. What needs a GPU, a newer kernel (6.6 and later) or several memory nodes is taught from man pages, kernel documentation, kernel source at a pinned version, or vendor documentation and labelled not run here. Scripts and raw outputs: src/read/code/.
A computer has a few CPUs, one physical memory and some devices; dozens of programs want them at once, none trusts the others, and none wants to know how an NVMe drive is programmed. The kernel owns five things on their behalf: CPU time, memory, devices (each run by a driver), files and the network (sockets and TCP: Networking foundations). A program never touches any of them directly. It runs on the CPU at full speed in user mode, and the kernel regains control only at a system call, a fault or a timer interrupt; OSTEP calls this limited direct execution. Every subsystem in the table above is a kind of crossing, and the children measure what each one costs. The ladder beside this text puts sixteen of those costs, all measured on this topic's lab machine, on one log scale.
Python, C++, Rust and Node do not talk to the kernel in their own ways: they all end in the same few hundred system calls, usually through the C library (glibc here). The Syscall tracer records every call of the running job and traces one small file read in five languages.
os.read() down and back is its Fig. 2); the hypervisor's crossing is section 2 of Virtualization and the GPU driver stack (one VM exit, measured, is its Fig. 3).clock_gettime through the vDSO: no crossing at all Processesgetppid Processespread of 4 KiB already in the page cache Virtual memorywrite() of 4 KiB into the page cache Storagefdatasync of a 4 KiB overwrite Storagefsync of the same record (a journal commit) Storageunshare) Containersdocker run --rm of the lab image ContainersLog scale, one machine (the lab VM, 2026-10-05), each number from the page named beside it or from this page's own runs (src/read/code/, src/sim/real/, src/trace/raw/). Grey: stays in user space; blue: enters the kernel or the hypervisor; green: waits for the device. The ratio between a function call and the cheapest system call, in the hundreds, explains buffered I/O, large reads, and the vDSO (kernel code mapped into every process so that asking the time never enters the kernel).
A process is a program in execution: an address space (its private memory), registers, a table of open file descriptors (small integers naming files, pipes and sockets; 0, 1 and 2 are stdin, stdout and stderr), credentials and a PID. Unix builds every process from four calls: fork() copies the caller, exec() replaces the program inside the process, wait() collects a child's exit status, exit() ends it; a shell running python train.py is fork, exec in the child, wait in the parent. A signal interrupts a process with a small numbered message: SIGTERM asks it to stop (what Kubernetes, Slurm and spot preemption send first), SIGKILL stops it and cannot be caught. The kernel publishes each process's state as text under /proc/<pid>/; ps and top only read it.
The distinction that runs through every child: process or thread. On Linux both are made by clone(), whose flags say what to share. Threads share memory, so they are cheap and need locks (Concurrency); processes are isolated, so a crash or a leak in one does not take the others down and, in CPython, each has its own GIL. A training node is a small tree of both: torchrun, one trainer process per GPU, each trainer's operator threads, and its DataLoader worker processes. How the workers start changes their cost: on the running job, time from iter(DataLoader) to the first batch was 0.021 s with fork against 0.836 s with spawn and 0.763 s with forkserver (medians of 7 runs each with 2 CPUs, 2026-10-05, in src/trace/raw/timing_first_batch.txt); spawn and forkserver pay for a fresh interpreter that re-imports torch. Linux's default is fork through Python 3.13 and forkserver from 3.14; fork is cheap because it copies page tables, not pages (Virtual memory, section 7), and unsafe once the parent has threads or has initialised CUDA.
Python's multiprocessing, which the PyTorch DataLoader uses for its workers, can start a child in three ways:
| Method | What happens | Good | Bad |
|---|---|---|---|
| fork | fork() only: the child is a copy of the parent at that moment | Instant; the dataset object and everything built so far are already there | Unsafe if the parent has threads (only the calling thread is copied, so a lock another thread held stays locked forever in the child) or has initialised CUDA |
| spawn | a fresh Python interpreter (fork then exec, or posix_spawn), which re-imports your main module and receives the pickled dataset | Clean child, safe with threads and CUDA | Slow (every worker re-imports torch); needs if __name__ == "__main__":; everything passed must pickle |
| forkserver | a single clean "server" process is started once (like spawn); each new worker is forked from it | Safe, and faster than spawn after the first | Still pickles arguments; the server costs one interpreter start |
Which one you get by default depends on the Python version and the platform: on Linux, fork through Python 3.13 and forkserver from 3.14 ("On POSIX platforms the default start method was changed from fork to forkserver to retain the performance but avoid common multithreaded process incompatibilities", Python 3.14 docs); on macOS, spawn since 3.8, because "macOS system libraries may start threads" (Python 3.11 docs). Since 3.12, os.fork() raises a DeprecationWarning when Python detects that the process has several threads. PyTorch's DataLoader follows the same defaults (torch.utils.data docs, 2.14). The running job uses Python 3.11 on Linux, so fork. Code that relies on fork-only behaviour, such as a global built at import and read by workers, changes behaviour on upgrading to 3.14: name the start method explicitly (multiprocessing_context=).
The running job alone has a main thread, PyTorch's operator threads, two worker processes and some helpers, on 5 CPUs shared with other containers. The scheduler decides which thread runs on which CPU and for how long. It gets control because the kernel programs a timer interrupt at boot; a switch saves one thread's registers into its kernel record and loads another's (a context switch, section 1). OSTEP builds policies up from FIFO (run in arrival order: a long job delays everyone behind it), through SJF and STCF (excellent turnaround, but they need to know job lengths) and round robin (good response, poor turnaround), to the multi-level feedback queue, which learns from behaviour; the OS simulators run all of them on the same jobs. Linux shares CPUs in proportion to weight instead: CFS from 2.6.23, EEVDF since 6.6, with nice from -20 to 19 picking the weight.
The distinction that matters for a training job: a CPU limit is a stop, not fewer CPUs. A container's limit is a cgroup quota per period: with --cpus 2 the file cpu.max reads 200 ms per 100 ms period, spendable on any of the 5 CPUs. Five busy threads spend it in the first 40 ms and are then throttled, not scheduled at all, for the remaining 60 ms; cpu.stat's nr_throttled counts the periods. Python and PyTorch's default thread pool still see 5 CPUs, so size torch.set_num_threads and num_workers from the quota, not from os.cpu_count(). A starving GPU is often this: workers that cannot produce batches as fast as the GPU consumes them. Kubernetes CPU limits become exactly this quota (requests become a relative weight, cpu.weight), which is why some clusters set CPU requests but no CPU limit on training pods.
Every address a program uses is a virtual address. On every load and store the MMU translates it, page by page (4 KiB here), through a per-process page table: a tree of four levels of 512 entries on ARM64 and x86-64 with 48-bit addresses. The TLB caches recent translations, so a hit costs nothing and a miss costs a walk. The kernel fills the tree lazily: allocating memory or mapping a file only records a promise, and the first touch of each page traps as a page fault. File pages live in the page cache, which mmap maps straight into the process (how np.memmap and safetensors read without copying). After fork, parent and child share every page read-only until one writes (copy-on-write), and Python's reference counts turn reads into writes. When memory runs out the kernel reclaims cache, may swap, and finally the OOM killer sends SIGKILL: inside a container the job vanishes with exit code 137 (128 + 9), no traceback.
The distinction across the children: memory promised, resident, shared and private are four different numbers. VSZ counts what was promised (the job reserves 1 GiB it never touches; this lab's VM overcommits), RSS what is resident, counting shared pages once per process, PSS divides each shared page among its sharers, USS is what only this process holds. For the running job's three processes, 815 MiB of RSS were 345 MiB of PSS, so summing workers' RSS overstates memory; and RSS also counts what allocators hold but no longer use (section 5).
measured here (src/read/code/tlb.c, median of 5 runs): a pointer chase visits N cache lines in random order. Packed, the N lines sit side by side and fit in few pages; spread, each line sits in its own 4 KiB page, so every access needs a different translation; a third run spreads the lines the same way inside memory advised to use 2 MiB transparent huge pages. Same number of cache lines, so the gap between the runs is mostly translation. Nanoseconds per access, packed, spread and spread on huge pages: 1.01, 3.08 and 1.00 at 256 lines; 1.01, 8.03 and 6.90 at 1,024; 5.70, 33.64 and 8.37 at 4,096; 7.22, 76.09 and 46.67 at 32,768. Huge pages remove most of the miss cost until they too run out of TLB reach. In this VM a miss is also a two-stage walk (the guest's tables, then the hypervisor's), dearer than on bare metal. The OS simulators time the same effect per page and replay OSTEP's TLB homework; Virtual memory, section 3, explains reach.
/dev/shm).The kernel hands out memory in whole pages and only through system calls; programs ask for millions of small, short-lived pieces. A user-space allocator sits in between: it gets large regions rarely (brk or mmap), cuts them into pieces often, and keeps freed pieces for reuse. One training job runs several: pymalloc for small Python objects, glibc's malloc (with an arena per thread, roughly) for NumPy and C extensions, mimalloc inside PyTorch's Linux arm64 wheels for CPU tensors, and on a GPU PyTorch's caching allocator, which keeps freed GPU blocks instead of returning them to the driver.
The distinction: freed is not returned. Freed memory stays with the allocator until a whole page, arena or segment is empty, so RSS measures what allocators hold, and free memory in the wrong-shaped pieces is fragmentation. The same shape appears one level up on the GPU: "CUDA out of memory" with gigabytes reserved by PyTorch but no single free block large enough, which PyTorch's own message answers with expandable_segments:True. torch.cuda.memory_allocated() counts live tensors, memory_reserved() everything the cache holds.
Threads share one address space, which is what makes them useful and what makes them dangerous: the scheduler can stop a thread between any two instructions, and on several CPUs two threads really do run at once. count = count + 1 is three instructions (load, add, store); two threads that each add 1 ten million times on two CPUs ended at 10,747,160 instead of 20,000,000 here. Code on shared data that must not run in two threads at once is a critical section; a lock or an atomic instruction (one indivisible read-modify-write) protects it. Two locks taken in opposite orders can wait for each other forever: a deadlock, cured by one global lock order. CPython's GIL lets one thread run bytecode at a time, which is why the DataLoader uses processes for Python-heavy work.
The distinction: every wait on Linux ends in one of two kernel queues. A thread waiting for another thread sleeps on a futex: the lock word lives in user memory, is taken with an atomic instruction, and only a thread that must wait asks the kernel to put it to sleep (20 million lock and unlock pairs under contention made 8,382 futex calls here). A thread waiting for I/O sleeps in epoll (asyncio, Node's libuv and tokio are loops around it) or collects completions from io_uring's rings. Choosing threads, processes or an event loop is choosing which queue your work waits in.
A storage device sits behind a driver and the block layer; a file system (ext4, XFS) turns its blocks into files, directories and names, keeping an inode per file (size, owner, block locations); the page cache (section 4) sits on top. write() and torch.save return once the bytes are in the page cache; the kernel's flusher threads write dirty pages out later, on their own schedule. A journal keeps the file system's own structures consistent across a crash; it does not protect your file's contents.
The distinction: returned is not durable. What a crash can leave is decided only by fsync (of the file, and of its directory, since fsync does not cover the file's name) and rename, which replaces a name atomically. The safe checkpoint is: write to a temporary file, fsync it, rename it over the old one, fsync the directory; a restart then sees the whole old checkpoint or the whole new one. Measured here, a 4 KiB write() took 1.4 us and an fsync of it 1,305 us; the protocol costs milliseconds against a training step and saves days. On a cluster the same rule applies to the whole set of shards, and object stores have no rename at all.
2009, ext4's zero-length files. With delayed allocation, ext4 wrote file data much later than its rename; after crashes, users found "pretty much any file written to by any application (during the previous boot) was 0 bytes". Ted Ts'o's answer: applications had come to depend on ext3's behaviour "even though POSIX never really made any such guarantee"; ext4 then added a heuristic that forces the data out when a file is renamed over another (LWN, 2009-03-11). Do not rely on that heuristic: call fsync.
2018, fsyncgate. PostgreSQL assumed that a successful fsync meant everything written since the last one was safe. After a device error, Linux could report the error once and mark the pages clean, so a retried fsync succeeded with the data lost (LWN, 2018-04-18). Lesson for checkpoints: if fsync fails, treat that checkpoint as lost and write it again from memory; never just retry the fsync.
A container is ordinary processes on the host's kernel, started with four kinds of restriction: namespaces (what it can see: its own PIDs, mounts, network, hostname, IPC, users), cgroups (how much it may use: CPU quota, memory limit, PIDs, I/O), capabilities and seccomp (what it may do: root's powers split up and mostly dropped, every system call checked against an allowlist at kernel entry), and an image (what files it has: read-only layers plus one writable layer, merged by overlayfs as its root).
The distinction: a container is not a VM. There is no second kernel, so a container keeps well-behaved jobs apart but a kernel bug reachable through an allowed system call is a way out; untrusted code goes in gVisor (a user-space kernel) or a microVM such as Firecracker. Read from inside one of this topic's containers (docker run --cpus 2 --memory 3g --pids-limit 256): ps sees two processes with the shell as PID 1, 14 capabilities remain, Seccomp: 2 means a filter is active, the root file system is overlay, and the limits are plain files under /sys/fs/cgroup. Reaching memory.max runs the OOM killer inside the cgroup (exit 137, OOMKilled, counted in memory.events); a GPU image brings the CUDA runtime and PyTorch, the host brings the driver.
measured here (src/read/code/container_view.sh, output in src/read/code/out/container_view.txt), inside docker run --cpus 2 --memory 3g --pids-limit 256: each namespace is a separate kernel object (its own number in /proc/self/ns), except time (4026531834) and user (4026531837), which are the kernel's initial namespaces, 0xEFFFFFFA and 0xEFFFFFFD in include/linux/proc_ns.h lines 45 and 48 (v6.12): shared with the host; the process sees itself at the root of its own cgroup (0::/); the limits are plain files; ps sees only two processes, with the shell as PID 1; 14 capabilities remain of root's full set (no cap_sys_admin, no cap_sys_ptrace, which is why this topic's strace runs needed --cap-add SYS_PTRACE); Seccomp: 2 means a filter is active (Docker's default profile "is an allowlist which specifies the calls that are allowed", Docker docs); and the root file system is overlay.
/dev/shm, CPU throttling, the pids limit).A hypervisor (KVM, Xen, the cloud providers' own, Apple's Hypervisor.framework under Docker Desktop) runs whole guest operating systems, each believing it owns a machine; the CPU helps with an extra privilege level and a second layer of page tables from guest-physical to host-physical addresses. A cloud GPU instance is almost always such a guest, and this lab is one too: its cross-CPU wake-ups and TLB misses are dearer than on bare metal. The IOMMU translates and checks every DMA address a device issues, which is what lets a whole GPU be passed to one VM; MIG, MPS and time slicing share one GPU among jobs.
The distinction: the hot path never asks permission. Guest code runs directly on the CPU and exits to the hypervisor only at boundaries; a CUDA kernel launch goes from PyTorch through the runtime (libcudart, in your wheel) to the user-mode driver (libcuda, installed with the host's driver), which writes commands into memory the GPU reads and rings a doorbell, while the kernel driver (nvidia.ko) is entered by ioctl only for setup, allocation and errors. The Python call returns long before the GPU finishes, because launches are asynchronous until something waits (.item(), .cpu(), torch.cuda.synchronize()); an strace -f of a CUDA PyTorch program shows a burst of openat("/dev/nvidia..."), mmap and ioctl calls at start-up and very few during steady training. So the two version numbers come from two places: the driver from the host (nvidia-smi), the runtime from the image (torch.version.cuda); "CUDA driver version is insufficient for CUDA runtime version" means a new image on an old host.
A failure in a training job shows up in one place and lives in another: a vanished job is memory, a starving GPU is often CPU, a corrupt checkpoint is persistence. This table spans every child; the last column is the page that owns the mechanism.
| What you see | Likely subsystem | Check first | Owner |
|---|---|---|---|
Job vanishes, exit code 137, no traceback; pod OOMKilled | Memory: cgroup OOM kill | cat /sys/fs/cgroup/memory.events (oom_kill), dmesg on the host | Virtual memory, Containers |
| "DataLoader worker (pid N) is killed by signal: Killed" | Memory: a worker OOM-killed | PSS per worker (smaps_rollup), memory.events | Processes, Virtual memory |
| "bus error", "unable to write to file </torch_...>" | Shared memory: /dev/shm too small | df -h /dev/shm; --shm-size or --ipc=host | Containers |
| Worker memory grows all epoch | Copy-on-write through refcounts | Private_Dirty per worker over time | Virtual memory |
| GPU utilisation low, steps uneven | CPU: too few workers, throttling, oversubscription | cpu.stat nr_throttled; top -H; py-spy dump of the main process | Scheduling |
| Each step slower in a container than on a laptop | CPU quota against thread count | cpu.max vs torch.get_num_threads() | Scheduling |
Job hangs at start with workers, fine with num_workers=0 | Fork after threads or CUDA | py-spy dump --pid of a worker (stuck in a lock); try spawn | Processes, Concurrency |
| "CUDA out of memory" with memory reserved | Allocator fragmentation | torch.cuda.memory_summary(); expandable_segments | Memory allocators |
| Preempted job lost its progress | Signals: SIGTERM not handled or not delivered | Is your script PID 1? Is there a handler and a checkpoint path? | Processes |
| Checkpoint empty or corrupt after a crash | Persistence: no fsync or no rename | strace the save: is there fsync, rename, directory fsync? | Storage |
| First epoch slow, later ones fast | Page cache cold against warm | vmstat 1 (bi), iostat -x 1, major faults | Virtual memory, Storage |
High sys time in top | Too many system calls (small reads, polling) | strace -c -f -p PID | Processes |
Process in state D, cannot be killed | Stuck in device or network file system I/O | cat /proc/PID/stack (root), cat /proc/PID/wchan | Processes, Storage |
| "Too many open files" | File descriptor limit | ulimit -n, ls /proc/PID/fd | wc -l | Processes |
| "CUDA driver version is insufficient for CUDA runtime version" | Driver against runtime versions | nvidia-smi against torch.version.cuda | Virtualization |
Each row with a failure that can happen without a GPU is reproduced, with real output, in the Debug lab tab, which also has a "what would you check first?" drill.
One line per subsystem; each child page gives the files and commands for its own part.
ps -eo pid,ppid,stat,rss,cmd, pstree -p, /proc/PID/status, py-spy dump (Python stacks of a live process)top -H (threads), vmstat 1 (r, cs, us, sy), pidstat -t 1, perf top, cgroup cpu.statfree -m, /proc/meminfo, smaps_rollup (PSS), memory.current and memory.eventsiostat -x 1, lsof -p PID, df -h, vmstat bi/bobpftrace, the bcc tools like execsnoop, opensnoop, biolatency) and perf, where the kernel and permissions allow; Brendan Gregg's books and site (Further reading)python train.py?| Section here, and its child page | OSTEP chapters (v1.10) | When to read |
|---|---|---|
| 1 What an OS does | 2 Introduction; 6 Direct Execution | First: the vocabulary for everything else |
| 2 Processes | 4 Processes; 5 Process API | Do ch. 5's fork and exec homework |
| 3 Scheduling | 7 CPU Scheduling; 8 Multi-level Feedback; 9 Lottery Scheduling; 10 Multi-CPU Scheduling | Ch. 7 and 8 now; 10 when you tune thread counts |
| 4 Virtual memory | 13 Address Spaces; 15 Address Translation; 18 Introduction to Paging; 19 TLBs; 20 Advanced Page Tables; 21 and 22 Swapping; 23 Complete VM Systems | The core of the book for ML engineers; 18 to 20 especially |
| 5 Allocators | 14 Memory API; 17 Free Space Management | Before reading about the CUDA caching allocator |
| 6 Concurrency | 26 Concurrency and Threads; 27 Thread API; 28 Locks; 30 Condition Variables; 31 Semaphores; 32 Concurrency Bugs; 33 Event-based Concurrency | 28, 32 and 33 first |
| 7 Persistence | 36 I/O Devices; 39 Files and Directories; 40 File System Implementation; 42 FSCK and Journaling; 44 Flash-based SSDs; 49 NFS | 39 and 42 before writing any checkpoint code |
| 8 Containers, 9 VMs | 53 to 57 Security; appendix Virtual Machines | Last; OSTEP has no container chapter |
Chapter numbers and titles from the table of contents at pages.cs.wisc.edu/~remzi/OSTEP, version 1.10 (November 2023), checked 2026-10-05.
Times are each page's own header, as of 2026-11-07: core reading, plus optional closed details. Every page uses the same lab machine and the same running job, so numbers carry from one to the next.
This page's other tabs span the children: the OS simulators (OSTEP's homework simulators for scheduling, the TLB and page replacement, races and locks, crash consistency, checked against OSTEP), the Syscall tracer (every system call of the running job, by phase and process) and the Debug lab (training-job failures reproduced in containers, each with its fix).
OSTEP's homework simulators for all three of its pieces, running in the page, next to the same thing measured on a real Linux kernel. Each one takes a mechanism that a child page owns and lets you drive it: you choose the jobs, the addresses, the interleaving or the moment of the crash, predict the result, then watch it happen step by step. Where a real run can show the same effect, its output sits beside the simulation. Translating one address and copy-on-write after fork, once simulated here, are now drawn page by page where they are taught: Virtual memory, section 2 (the walk, with its Address translator tab) and section 7 (copy-on-write, with this tab's fork measurement).
Every simulator is written twice (the address-translation and copy-on-write cores that Virtual memory now draws are still checked, so their lines stay in the list): once in Python (the reference, in the page's src/sim/ folder) and once in the JavaScript that runs here. A script runs the page's JavaScript on every case the Python produces and requires identical output, tick by tick and access by access. Where OSTEP ships a homework simulator for the same mechanism, the Python reference is run against it on the same inputs (OSTEP's simulators: github.com/remzi-arpacidusseau/ostep-homework):
Not checked against OSTEP because it ships no simulator for them: STCF, the simplified CFS (checked against the formulas in the Linux source instead), CLOCK (OSTEP's paging-policy.py inspects random pages rather than sweeping a hand) and the crash-consistency cases (checked against the six cases OSTEP chapter 42 lists).
The real runs used the shared lab image of this page (Debian 12, gcc 12.2, Python 3.11.2, numpy 2.4.6) in Docker Desktop's Linux VM on an Apple M1 laptop: Linux 5.10.104-linuxkit, arm64, 5 virtual CPUs, 4 KiB pages. It is a virtual machine on a laptop, shared with other experiments, so absolute numbers are this machine's on this day, not a property of Linux. Hardware performance counters are not available inside this VM (perf stat -e dTLB-load-misses reports <not supported>), so TLB effects below are shown by timing, with huge pages as the control.
The problem. A CPU core runs one thread at a time, but a training node has many runnable threads: the training loop, DataLoader workers, a logging thread, your shell. The scheduler is the kernel code that decides which one runs on the core for the next slice of time. Each policy below is a different answer, and each is good at one thing and bad at another. Two numbers judge them (OSTEP chapter 7): turnaround time = finish time minus arrival time (how long a batch job takes), and response time = first time it runs minus arrival time (how long an interactive program waits before anything happens).
The model: time in ticks; one CPU; a job with "I/O every k" runs k ticks then blocks for the I/O time (as in OSTEP's mlfq.py). At each tick, newly arrived jobs join the queue first, then jobs whose I/O finished, then the job whose slice just ended; ties go to whoever queued first. The CFS here keeps the kernel's slice formula, weights and placement rules (sources below) and leaves out wake-up preemption and multi-CPU load balancing.
MLFQ settings: quanta per queue from the top; "quanta 2, 4, 8" uses allotments 1, 1, 2 (a job may use 2 slices at the bottom before requeueing); the boost moves every job back to the top every 40 ticks.
Shorter is better for both. The pattern to notice: the policies that are best for turnaround (SJF, STCF) need to know how long each job will run, which a real OS does not; round robin is best for response and worst for turnaround; MLFQ and CFS do not need to know run lengths.
Two busy loops pinned to the same CPU for 10 seconds, one at nice 0 and one at nice 0, 5 or 10 (src/sim/real/nice_share.c). Linux turns nice into a weight with a fixed table: nice 0 is 1024, nice 5 is 335, nice 10 is 110 (Sourcekernel/sched/core.c line 8457, v5.10), and CFS gives each runnable thread a share of the CPU equal to its weight divided by the sum of weights. The formula predicts the share before the run; the bars are what the kernel did.
The same two jobs in the simulator above (choose CFS, edit the table to two long jobs with nice 0 and 5) give the same split. One thing a simulator hides: switching costs time. Two processes pinned to one CPU, handing a byte back and forth through pipes 200,000 times (src/sim/real/ctxsw.c, the lmbench method), cost per switch after subtracting the pipe system calls themselves. On two different CPUs the same hand-off took about per round trip: there is no switch, but waking an idle virtual CPU in this VM is slow (we did not measure where that time goes).
limits.cpu) is a different mechanism that stops the whole group when its quota runs out. Both, with real measurements of a throttled job, are in the Debug lab. OSTEP: ch. 7 Scheduling, ch. 8 MLFQ, ch. 9 Proportional share (9.7 is CFS); homework simulators cpu-sched and cpu-sched-mlfq.All from SourceLinux v5.10 kernel/sched/fair.c (the kernel running the real measurements):
calc_delta_fair, line 671): a nice 5 thread's vruntime grows about 3 times as fast as a nice 0 thread's, so it is picked about a third as often.sched_slice, line 701), where the period is sched_latency, or (number of threads × min_granularity) when more threads than sched_nr_latency = latency / granularity are runnable (__sched_period, line 687). The kernel defaults are 6 ms and 0.75 ms, scaled by 1 + log2(CPUs) (lines 38 and 59); the simulator uses OSTEP's example values, 48 and 6 ticks.check_preempt_tick, line 4355): when the thread has run its slice, or, after min_granularity, when its vruntime is ahead of the smallest by more than a slice.place_entity, line 4108): a new thread starts one virtual slice after the queue's minimum vruntime (the START_DEBIT feature), so it cannot jump the queue; a thread waking from I/O is placed at most half a latency behind the minimum, so sleeping does not bank unlimited credit.The problem. Every process believes it owns one large, private range of addresses (its virtual address space), but all processes share one physical memory. On every load and store, the CPU's memory management unit (MMU) translates the virtual address the program used into a physical one. Memory is cut into fixed-size pages (4 KiB on this machine); the page table, kept by the kernel in memory, maps each virtual page number (VPN) to a physical frame number (PFN). A page-table entry (PTE) also holds a valid bit: an access to an invalid page traps into the kernel as a page fault. Reading the page table on every access would double the cost of memory, so the CPU caches recent translations in the TLB (translation lookaside buffer): a hit costs nothing extra, a miss costs a walk of the table. OSTEP chapters 18 to 22. One address walked through the tables, step by step, is on Virtual memory (section 2 and its Address translator tab).
A 2-D array of 4-byte integers is stored row after row. Walking it along rows touches consecutive addresses, so one TLB entry serves a whole page of accesses; walking it down columns jumps a whole row each time and may need a different page on every access. Same data, same sum, different order. (OSTEP Fig. 19.2 is the 1-D version: ten integers on 16-byte pages, 70% hits; choose "OSTEP Fig. 19.2" to reproduce it.)
Pages are tiny here so that a few fit on the screen; on the real machine a page is 4,096 bytes and the TLB has hundreds to thousands of entries. The proportions are what carry over.
OSTEP's chapter 19 homework, done for real (src/sim/real/tlb.c): touch one integer on each of N pages, over and over, and time each access. While the N translations fit in the TLB, an access costs about a nanosecond; past it, each access pays for a page-table walk. The catch is that the cache footprint grows with N too, so the same loop is run a second time on 2 MiB huge pages (one TLB entry covers 512 of the 4 KiB pages): same addresses, same cache lines, only the translation differs. Where the two lines part, it is the TLB.
From 2,048 to 4,096 pages the 4 KiB line jumps from about 1.1 to 7.6 ns per access and keeps rising, while the huge-page line stays near 1.1 ns until 16,384 pages: a second-level TLB of a few thousand entries is consistent with that, but the hardware's exact size is not measured here. In this VM a TLB miss is also a two-stage walk (the guest's page table, then the hypervisor's), which makes misses dearer than on bare metal. The 16,384-page jump on huge pages is not explained by this experiment. The first rows (1 to 8 pages) are slower only because the loop's own overhead is spread over few accesses. The 2-D walk of a 4,096 × 4,096 array (64 MiB): ; that ratio mixes cache lines and TLB misses.
When a process touches more pages than fit in memory, each access to a page that is not resident is a major page fault: the kernel reads the page from disk (swap, or the file it maps) and must first evict another page. The policy decides which. OPT evicts the page used furthest in the future (perfect, impossible in practice, the yardstick); FIFO the oldest; LRU the least recently used; CLOCK approximates LRU cheaply: a hand sweeps the frames, clearing each page's use bit, and evicts the first page whose bit is already clear (OSTEP chapter 22; Linux's real policy keeps active and inactive lists, a refinement of the same idea).
np.memmap or a safetensors file is mapped, not read: its pages come in by page fault on first touch, from the page cache if another process (or an earlier epoch) already read them, and are evicted under memory pressure by the policy above. The Syscall tracer shows the job's real mmap of its dataset, and the Debug lab measures a cold and a warm page cache. OSTEP: ch. 18 Paging, ch. 19 TLBs, ch. 20 Advanced page tables, ch. 22 Swapping policies; homework simulators vm-paging, vm-smalltables, vm-beyondphys-policy.The problem. Threads of one process share memory. count = count + 1 looks like one step, but the CPU does it in three instructions: load count into a register, add 1, store it back. The real compiler output for it on this machine (gcc 12, -O2, arm64; src/sim/real/inc.c) is ldr, add, str:
If the scheduler switches threads (or a second core runs the other thread) between the load and the store, both threads load the same old value and one increment is lost: a race condition. The three instructions form a critical section that needs mutual exclusion. A lock provides it, built on a hardware instruction that reads and writes memory indivisibly (here xchg, test-and-set); an atomic add does the whole read-modify-write as one indivisible operation (on this machine gcc calls a helper, __aarch64_ldadd8_acq_rel, in the listing above). OSTEP chapters 26 and 28.
OSTEP's x86.py assembly, run here instruction by instruction. Two threads run the same code; each loops %bx times. The scheduler switches thread every k instructions (an interrupt), as x86.py -i k does; or you are the scheduler.
The red bar marks the critical section. The atomic add is our one addition to OSTEP's instruction set (fetchadd, one indivisible read-modify-write); everything else is OSTEP's looping-race-nolock.s and test-and-set.s verbatim, and the final counts match x86.py on every setting checked (see the top of this tab).
src/sim/real/race.c, two POSIX threads. On 2 CPUs the threads truly run at the same time and nearly half the increments vanish; on 1 CPU they only interleave when the scheduler preempts one, every few milliseconds, so a switch almost never lands inside the 3-instruction window: zero lost in these runs, which is exactly why such bugs pass tests and fail in production. The mutex and the atomic are correct, and slower.
Thread 1 takes lock A, then lock B. Thread 2 takes B, then A. If each gets its first lock before the other asks for its second, each waits forever for the lock the other holds: a deadlock (OSTEP chapter 32). The standard fix is a lock order: everyone takes A before B, so the cycle cannot form. You are the scheduler: step either thread.
/procsrc/sim/real/deadlock.c: the same two threads with pthread mutexes and a 100 ms pause between the two locks. After 2 seconds the program reads each thread's state from /proc/self/task/<tid>/stat (S = sleeping) and the system call it is blocked in from /proc/self/task/<tid>/syscall: 98 is futex on arm64, the kernel call a contended mutex sleeps in. The ordered version finishes.
count += 1, which is several bytecodes (Python FAQ); PyTorch's own data structures are guarded by C++ mutexes, which is where a hang in a DataLoader or NCCL thread sits (futex in py-spy dump or /proc). Memory ordering and false sharing, measured on the M1: C++: the machine underneath, section 8; the GIL and free-threading: Python: concurrency, asyncio and the GIL. The Debug lab reproduces a fork-after-threads deadlock. OSTEP: ch. 26 Concurrency, ch. 28 Locks, ch. 32 Concurrency bugs; homework threads-intro, threads-locks.The problem. Appending one block to a file changes three places on disk: the file's inode (I, its metadata: size and a pointer to the new block), the data bitmap (B, which blocks are in use) and the data block itself (Db, written to block 5). The disk writes them one at a time, and in whatever order it likes; a crash or power cut can leave any subset on disk. OSTEP chapter 42 lists what each subset means; a journal (write-ahead log: first describe the whole update in a separate log area, mark it complete with a commit block TxE, then write it in place) turns "any subset" into "all or nothing". Linux ext4's default data=ordered mode is the "ordered" protocol below, and its data=writeback mode allows the "data written last" one (ext4 documentation).
How to read it: blocks in a dashed box are issued together and may reach the disk in any order or not at all; a new box starts only after the previous one is completely on disk (a write barrier, a cache FLUSH on a real drive). Each step of the animation is one possible crash: green blocks reached the disk, faded ones did not. Then recovery runs: fsck without a journal, or journal replay (copy every transaction whose TxE is on disk to its final place).
"Old file": the append is lost but everything is consistent (acceptable: the application never got confirmation). "New file": the append survived. "Garbage": the metadata is consistent but the file now contains whatever was in block 5 before, which no checker can detect. Counts are of distinct crash states, not probabilities.
journal_checksum, puts a checksum of the transaction in the commit block so a torn transaction is detected. The "TxE sent with the rest" protocol above shows the 8 crash points that end this way.Reproducing these orderings needs control of the disk's write cache: cutting power to a drive, or a block device that drops unflushed writes. Inside this VM the "disk" is a file on the Mac, and a killed container or VM does not lose the host's cache in the same way, so a real run could show only the happy path. The application-level version of the same problem, a checkpoint file half written when the process dies, is real and measured: the Debug lab kills a job mid-torch.save, and the Syscall tracer shows the job's write, fsync and rename calls. Write to a temporary file, fsync it, rename it over the old one, then fsync the directory: the rename is the application's commit block.
fsync (and the rename pattern) tells you the data is durable; see Storage and file systems (sections 5 and 6), and the databases topic for the same idea in a write-ahead log. OSTEP: ch. 42 FSCK and Journaling; homework file-journaling (an fsck puzzle rather than a crash simulator).One training job, and every request it made to the kernel. This tab is the evidence behind the Reading. The running example (a tiny CPU-only PyTorch training job: a memory-mapped dataset, a DataLoader with 2 worker processes, a few steps, a safe checkpoint, a SIGTERM) was run under strace inside a Linux container on . Every call, count and timing below comes from those recordings; nothing is illustrative.
The job marks each phase with a deliberate, harmless system call, faccessat("/phase/<name>"), which fails because the path does not exist; that is how the trace below is cut into phases. Bars are system calls in each phase, all processes and threads together, coloured by kind. The scale is logarithmic, because two phases dwarf all the others.
Each row is a process or the threads of one process; each mark is one system call at the time strace saw it. Shaded blocks are import storms, collapsed to a summary (open one to see what is inside). Pick a phase to zoom, tick kinds to show, type a name or a path to filter, and click a mark or a row to see what that call asks the kernel.
import torch asks of the kernelImporting a Python package means finding files and reading them. For every name in an import, Python's import system (the path finder) checks each directory on sys.path for a matching package, module, compiled extension or bytecode file, which is why most of the calls below are newfstatat (a stat: "does this path exist, and what is it?"), many of them failing with ENOENT ("no such file"). Each compiled extension (.so) is opened and memory-mapped by the dynamic loader. The import system is described in the Python 3.11 reference, section 5.5.
import torch. It happens on the line torch.optim.SGD(model.parameters(), lr=0.1): building the first optimizer imports torch._dynamo (the torch.compile front end), which pulls in sympy and torch.distributed, about as many calls as import torch itself. Measured without strace, constructing that first optimizer took (median of 7 fresh interpreters), against for import torch. It is a one-off per process, but every spawned DataLoader worker or new process pays its own imports again (section 4).mmap of 1 GiB (MAP_NORESERVE: address space only, no memory committed) followed by madvise(MADV_HUGEPAGE). A gdb catchpoint on that madvise shows the caller: mi_reserve_os_memory_ex and _mi_prim_alloc in torch/lib/libc10.so, the mimalloc allocator built into this PyTorch wheel. See it in the explorer with the jump button "the 1 GiB reservation".A DataLoader with num_workers=2 starts two worker processes. How they start is Python's start method (multiprocessing docs). fork: the kernel copies the parent (copy-on-write: no memory is copied until someone writes), so the worker starts with torch already imported. spawn: a brand new Python is execve'd and must import everything again. forkserver: a small server process is spawned once, and each worker is forked from it. In CPython 3.11 the default is fork on Linux and spawn on macOS (context.py lines 322 to 327); Python 3.14 changed the Linux default to forkserver (docs, "Changed in version 3.14"). The animation replays the real traces, from iter(dl) to the first batch, drawn to scale in system calls.
Step by step
A system call is not free: the CPU has to switch into kernel mode and back. Python's file objects therefore keep a buffer in user memory and call write(2) only when it fills. Its size is "chosen using a heuristic trying to determine the underlying device's block size and falling back on io.DEFAULT_BUFFER_SIZE" (open() in the 3.11 docs); here the file system reports 4,096-byte blocks, and the trace shows exactly 4,096-byte writes. The experiment writes the same 1 MiB as 4,096 pieces of 256 bytes, once through a normal file object and once with buffering=0.
Step by step
Script: src/trace/scripts/writes.py; traces raw/writes_buffered.strace.txt and raw/writes_unbuffered.strace.txt; times in raw/writes_timing.txt (best of 21 untraced runs, on the container's overlay file system).
The same checkpoint (the job's model and optimizer state, about 270 KB) written three ways. naive: torch.save(obj, "ckpt.pt") over the old file. fsync: write through a file object, then os.fsync. safe: write ckpt.pt.tmp, fsync it, os.replace it over ckpt.pt, fsync the directory. A write only copies bytes into the kernel's page cache (memory); fsync waits until the storage device has them (fsync(2)); a rename replaces a name atomically, so a reader sees the old file or the new one, never a mixture (rename(2)). Step through the real calls and see what a crash at that moment would leave on disk.
Step by step
What "a crash here" leaves is reasoned from the man pages and the order of calls (what reaches the device before each point), not from a real power cut: a container cannot cut the power to its disk. The Debug lab tries what can be tried honestly.
Before a preempted node or a cancelled job is killed, the scheduler sends SIGTERM (Kubernetes waits a grace period, 30 seconds by default, then sends SIGKILL: pod termination). The job installs a handler that only sets a flag; the training loop sees the flag, saves a checkpoint and exits 0. Here is that path in the real trace, with one twist the trace exposed.
The same task, read /work/hello.txt (27 bytes) into memory, in C, C++, Rust, Python and Node, each traced. Every one of them ends in the same three system calls, openat, read, close; what differs is how many calls the runtime makes before your line runs, and how many extra questions it asks about the file. The call stacks were captured with gdb stopping at each of those system calls (symbols from Debian's debuginfod server), so the path from your line to the kernel is real, not drawn.
Each case below is a failure that ML training jobs really hit, reproduced on purpose in a container and recorded: the error exactly as it appears, the subsystem of the operating system behind it, the commands that pinpoint it with their real output, the cause, the fix, and where it bites in training. Three ways in: browse and filter the cases, follow the decision tree from a symptom, or drill: see a symptom and pick what you would check first.
Every output was recorded on 2026-10-05 in Docker containers on a laptop: Docker Desktop's Linux VM (kernel 5.10.104, arm64, 5 CPUs, about 10 GB of memory, cgroups v2, one NUMA node, no GPU), image kb-os-dbg:1 (the shared lab image kb-os-lab:1 with Python 3.11.2, torch 2.14.1 CPU build, numpy 2.4.6, plus pyarrow). No container was privileged; five added only CAP_SYS_PTRACE, for strace and py-spy. Each case's first grey line is the exact docker run that recorded it: the limits (--memory, --cpus, --shm-size, ...) are part of the experiment. Timings come from one run each on a shared VM and vary between runs; the shapes (which is slower, what dies, what the counters say) are what repeat. The CUDA case is quoted from PyTorch's source, not run. Scripts and raw recordings: src/debug/ (run_all.sh reruns everything); the page quotes them verbatim.
Start from what you see; each answer narrows the subsystem until the cases that match remain. Opening a case takes you to it in the list.
A symptom from one of the cases, as the user sees it. Which command would you run first? The answer explains why and links the full case.
| Subsystem | Cases |
|---|
Chapter numbers are those of Operating Systems: Three Easy Pieces (table of contents checked 2026-10-05). The Reading explains each mechanism, the OS simulators animate them, and the Syscall tracer shows the running job's system calls.
Every link was checked on 5 October 2026. Times are estimates of reading time for the part worth reading, not whole books. Suggested order if the subject is new: this page's Reading tab; OSTEP's virtualization chapters (4 to 23) with their homework; Julia Evans' zines as a quick map of the tools; then The Linux Programming Interface or the man pages for whichever call you are debugging, and Brendan Gregg when something is slow.
OSTEP-style simulators in the page: schedulers, the TLB and page replacement, races and locks, crash consistency, each with predict-then-reveal drills and a real run beside it.After sections 3, 4, 6 and 7, to step through the mechanisms yourself.
Every system call of the running job, by phase and process, explained one by one; start methods, buffered writes and the checkpoint compared; one file read in four languages.After section 1 and 2; whenever you want to see what a line of Python asks of the kernel.
Real failures of training jobs reproduced in containers, each with the symptom, the commands that pinpoint it and the fix; filterable, with a drill.When something breaks; pairs with section 10's table.
Remzi and Andrea Arpaci-Dusseau's textbook, one PDF per chapter, written to be read: dialogues, a "crux" per chapter, and homework simulators. The OSTEP map in section 10 says which chapters go with which section.Start with ch. 4 Processes, ch. 18 Paging, ch. 19 TLBs, ch. 28 Locks and ch. 42 FSCK and Journaling.
The Python simulators the book's homework uses (scheduler.py, mlfq.py, paging and TLB, x86.py threads, fsck and journaling); the OS simulators tab checks its own outputs against them.Run them as you read each chapter.
Maintained by Michael Kerrisk; the exact contract of every system call (section 2) and library function (section 3), with the edge cases. This page quotes fsync(2), rename(2), mmap(2), fork(2), futex(2), epoll(7), proc_pid_maps(5), mallopt(3) and more.Whenever you need the precise promise of one call.
The complete, careful book on the Linux and POSIX system-call API: processes, signals, threads, memory mappings, file I/O, sockets. Old but the interfaces it covers have barely changed.After OSTEP, for the real API behind each idea.
Admin guides for the knobs this page uses: cgroup v2, transparent huge pages, EEVDF, overcommit, vm sysctls.When you change or read one of those files.
The machine underneath the OS from a programmer's side: data representation, assembly, caches, linking, exceptions and processes, virtual memory, system-level I/O.If you want the hardware half that OSTEP assumes (chapters 6, 8 and 9 especially).
The method and the tools for finding why a Linux system is slow: the USE method, CPU, memory, file system, disk and network chapters, perf and eBPF.The first time a job is slow and you cannot see why.
Flame graphs, the Linux performance tools map, eBPF tools, and many short articles on specific measurements.Alongside the book, or instead of it for one tool.
Illustrated, short, accurate: Bite Size Linux!, Linux debugging tools you'll love, How Containers Work!, So you want to be a wizard.First, as a map of the tools; again before section 8.
A sampling profiler that reads a running Python process's stacks from outside, without restarting it: py-spy dump --pid answers "where is it stuck?" for a hung DataLoader.The first tool for a hung or slow Python job.
Every layer between write() and the platter, and which call flushes which: the long version of section 7.
The zero-length files story and why "write, then rename" needs fsync.
What happens to your data when fsync fails, and why retrying is not enough.
Why CFS was replaced and how virtual deadlines work.
io_uring's design when it was introduced; The rapid growth of io_uring (2020-01-24) follows it a year on.
How THP works and what it costs.
cgroups v2, the interface every container limit on this page uses.
Workers, start methods, the warning that workers copy the parent's Python objects, pin_memory.Before tuning a DataLoader.
Sharing tensors between processes, sharing strategies, CUDA and "poison fork".
The caching allocator, its counters, and every option of PYTORCH_ALLOC_CONF including expandable_segments.The next time you see "CUDA out of memory".
fork, spawn and forkserver, and which is the default on which platform and version.
Driver against runtime versions, minor-version and forward compatibility.
How GPUs get into containers.
Partitioning a GPU; storage straight into GPU memory.
The two common designs for sandboxing untrusted code: an application kernel, and a microVM.
Caches, layout, mmap, SIMD, atomics and false sharing, measured on an M1. 33 min, plus 21
llama.cpp's mmap of weights (section 5) and its thread pool (section 9). 37 min, plus 39
The GIL, free-threading, asyncio's event loop, multiprocessing. 19 min, plus 10
tokio and Node's event loop: section 6's epoll from the language side.
The write-ahead log and fsync in a database: section 7 applied.
Sockets and TCP: the network the kernel owns.
Processes per GPU, sharded checkpoints and cluster storage.
CPU, GPU and memory hardware; writing GPU kernels: what sections 4 and 9 lean on.
DataLoader and allocator APIs in depth; Kubernetes and Slurm; code-execution sandboxes. 26, 26 and 21 min
The process as a kernel record and every call that changes it: the system-call boundary and its cost, fork and threads, exec, wait and PID 1, signals, descriptors and pipes, the DataLoader and torchrun, preemption measured.
Run queues and the context switch measured, proportional share, CFS and EEVDF, the other classes, load balancing, affinity and NUMA, cpu.weight and cpu.max throttling, CPU accounting and profilers, a training job's CPU budget.
The address space and the page-table walk, the TLB, faults, mmap and the page cache, copy-on-write measured, huge pages, pinned memory, overcommit, swap, cgroup limits and the OOM killer, VSZ to USS.
Free lists, glibc's malloc and arenas, fragmentation measured, jemalloc, tcmalloc and mimalloc on the same job, pymalloc and the cycle collector, the CUDA caching allocator, diagnosing growth.
Threads and their cost, races as interleavings, atomics and memory order, locks measured, the futex, condition variables, deadlock, the GIL and free-threaded Python, epoll and io_uring, choosing threads, processes or async.
Devices and NVMe queues, the VFS, readahead, writeback, the fsync family and its failures, atomic replace and a crash lab, journaling, direct I/O, NFS, checkpoint writes, data loading.
A container built by hand, namespaces, PID 1, images and overlayfs, cgroups v2 and memory limits, capabilities, seccomp, LSMs, runtimes, gVisor and microVMs, GPU containers, Kubernetes requests and limits as cgroup files.
VMs against containers, VM exits measured, cloud instances, nested paging, virtio, the IOMMU and passthrough, sharing a GPU (MIG, MPS, time slicing), one CUDA call down to the driver and GSP, version compatibility.