Skip to main content

116 docs tagged with "kernel"

View all tags

`switch_root` and PID 1

Mounting the real root, the three constantly-confused ways to change it, and what makes PID 1 special.

A Minimal Root Filesystem

A static BusyBox, a directory skeleton, and an /init packed into an initramfs — early user space made concrete instead of magical.

ABI Stability and Compat

"We do not break user space" is usually quoted as a slogan. Treated as an engineering constraint it is

Atomic Operations

atomict, the operation families, the ordering each does and does not carry, and why refcountt exists separately.

Building a Kernel

From defconfig to a bootable image, including the debug options that make the rest of this section's labs possible.

CFS and Virtual Runtime

The pinned kernel for this section, v6.18, does not run CFS as its fair-class scheduler — it runs

cgroup CPU Control

Everything earlier in this folder schedules tasks. A container, a service, or a user session is a

Choosing a Lock

The decision table, six worked selections, and the cost hierarchy from an uncontended atomic to cross-NUMA ping-pong.

Credentials and Identity

A task's identity is not one number. There are four user IDs, four group IDs, a supplementary group

Debugging the Kernel with GDB

Attaching a debugger to the virtual CPU, loading vmlinux symbols, and walking live kernel structures — the highest-leverage skill in this section.

Early Boot: Getting to C

x86-64 from 16-bit entry through protected mode and early page tables into long mode, and the far simpler arm64 equivalent.

Error Handling

C has no exceptions, no try/catch, and no automatic unwinding. The kernel has instead settled on one

Finding Locking Bugs

lockdep and what it proves, KCSAN for data races, and a real splat read line by line.

From Power-On to Login Prompt

Every handoff between pressing the power button and a login prompt, with the artefact each stage passes to the next.

Getting the Source

Cloning or downloading the pinned kernel, what the repository costs in disk and time, and a first orientation pass through the tree.

Glossary

Every term below links to the one page that owns and genuinely defines it, so "where did this come from" always has an answer. The list covers folders 00–10 so far and grows as later folders land — a term you expect but can't find here probably belongs to a page that hasn't been written yet.

Hard IRQ Context and Its Rules

What a handler may not do, why each rule follows from the context, and the pressure that creates the rest of the folder.

Huge Pages and THP

A TLB holds a fixed number of entries, and its reach — the amount of address space it can translate

Index of Misconceptions

Every widely-held wrong belief this section corrects, gathered in one place and linked to the

Inside `bzImage`

The layout of a compressed kernel image, and why vmlinux, vmlinuz, and bzImage are three different things.

Interrupt Affinity

/proc/interrupts read column by column, MSI-X vectors per queue, and why pinning an interrupt near its consumer matters.

Kconfig and Kbuild

How a configuration symbol becomes a compiled object, and how to read past the CONFIG_ ifdefs that are everywhere.

Kernel Data Structures

Intrusive lists, hlists, red-black trees, xarrays, and IDRs — why intrusive containers, and what they cost.

Kernel Modules

Loading, unloading, parameters, dependency resolution, taint, and building a module out of tree.

Lab: Add a System Call

End to end in the QEMU lab: define it, wire the table, rebuild, boot, call it, and watch it in

libc Is Not the Kernel

There is a layer most C programmers forget is there. Almost nobody calls the kernel directly — they

Linux & Kernel

How Linux actually works, from the boundary between a command you type and the kernel that

Lock-Free Patterns

Where the kernel genuinely goes lock-free, and an honest account of why most kernel code should not.

Memory Ordering and Barriers

Why a plain access is not safe, what each barrier actually orders, and why this is the page arm64 changes the most.

Monolithic, With Modules

Where Linux sits in the architecture taxonomy, why, and the honest cost: a driver bug is a kernel bug.

NUMA and Memory Policy

Node-local allocation by default, the policies that override it, and when NUMA effects are a red herring.

Page Tables and the Walk

Translation is a size problem before it's anything else. A flat table mapping every 4 KiB page of a

Per-CPU Data

Eliminating sharing rather than protecting it, and what that costs in preemption discipline.

Preemption Models

When the kernel is executing on behalf of a task — running a system call, handling a fault, walking a

RCU in Practice

The API, the ordering it encodes, and the rules that make RCU misuse silently fatal rather than loudly wrong.

RCU: The Idea

Readers that take no locks and pay nothing, writers that publish a new version and defer reclamation until every reader has left.

Reader-Writer Locks

Why a reader-writer lock is often slower than a plain one, and where rw_semaphore is genuinely the right answer.

Real-Time Scheduling

The word misleads, so the definition has to come first: real-time does not mean fast. It means

Roadmap

Every page in this section declares its prerequisites in front matter, and the build fails on a

Seqlocks

Lockless readers with a retry loop, the constraints that puts on a reader, and the canonical use in timekeeping.

Signals

Signals are the oldest asynchronous notification mechanism in UNIX — older than threads, older than

SMP and Load Balancing

The load balancer lives in a permanent tension. Moving a runnable task onto an idle CPU puts otherwise

Softirqs

The fixed set, why it is fixed, the budget that stops it starving everything else, and the si column in top.

Spinlocks

Busy-waiting and when it is right, the queued implementation, and the absolute rule against sleeping while holding one.

Swap, zswap, and zram

Swap has an undeserved reputation. It is not "what happens when a machine runs out of memory" — it is

The Context Switch

A context switch is both smaller and larger than people think. The part with a name — saving one

The Entry Path

Some of what happens between the SYSCALL instruction and dosyscall64 is done by the CPU, because

The Kernel Is Not C You Know

Freestanding C with no libc, no floating point, a tiny stack, GCC extensions in daily use, and the annotations sparse checks.

The Lab Machine

Why QEMU is the spine of every lab here, what to install on the host, and what each lab host badge means.

The Life of a `write()`

Where your data actually is at each moment between write() returning and the bytes reaching the device, and what fsync changes.

The Life of a Container

docker run de-mystified: a container is a process started with unusual arguments, and here is every one of them.

The Life of a Packet

Wire to socket and back again, through the DMA ring, NAPI, GRO, netfilter, routing, and TCP.

The Life of a Page Fault

An ordinary first touch of freshly allocated memory, traced from the CPU exception to the instruction re-executing — the normal case, not an error.

The OOM Killer

By the time this code runs, every allocation path has already failed, reclaim has already been asked and

The Page Allocator

Every other allocator in the kernel — slab, vmalloc, the page cache, the stack allocator — ultimately

The Page Cache

This is the single most consequential piece of Linux memory management, and the one most misread by

The Source Tree, Mapped

Every top-level directory in a line, the four that matter expanded, and a lookup table from question to location.

The vDSO

Some "system calls" are not system calls. clock_gettime is called millions of times a second by

The Virtual Address Space

A pointer on x86-64 is a 64-bit value, but the address space it names is not a 64-bit space. Implementing

Threaded IRQs

A quick primary handler plus a schedulable thread, and why PREEMPT_RT makes nearly every handler threaded.

Threads Are Tasks

Linux has no separate thread object: a thread is a task that shares its address space, files, and signal

Timekeeping and Clocksources

How a clocksource is chosen, what each CLOCK* actually measures, and the lockless read path behind clockgettime.

What Goes Wrong in Kernel C

This is the catalogue page. Kernel bugs — the ones that end in an oops, a silent corruption, or a security

What Linux Actually Is

Kernel, GNU, and distribution pulled apart, plus the two design commitments that still constrain everything: a stable user-space ABI and no stable module ABI.

What This Section Covers

The scope of this section, what it deliberately leaves out, and what "understanding Linux" means in practice.

Workqueues

Deferred work in process context, so it may sleep — plus the cancel-versus-free lifetime bug everyone writes once.

Your First Kernel

Every CUDA program, no matter how large, is built from the same five moves: allocate device memory, copy input in, launch a kernel, copy output back, free what was allocated. SAXPY — y = a*x + y, scalar-times-vector-plus-vector — is small enough to show all five in one file without anything else getting in the way. The rest of this page walks the same file section by section.