AlgoViz

How the Linux kernel works

medium 40 min

The kernel is the one program that runs with full privilege.

Where it shows up

The same pattern appears across everyday software.

  • A slow command on a busy host

    A deploy script hangs on `ls` of a network mount. `ps` shows the shell in D state and `/proc/PID/wchan` names a network file system function. The fix is the mount, not the script.

  • Containers on one kernel

    On our Docker Desktop machine, `ls -l /proc/self/ns` inside a container lists ten namespace links, including pid, net, mnt and time. Every container shares the same kernel and gets its own view.

  • A web server under a packet flood

    One CPU sits at 100% in softirq while the others idle. `/proc/interrupts` shows one hot queue. Spreading receive queues over CPUs with RSS or RPS evens it out.

  • A database and the page cache

    After a restart the first queries are slow and `vmstat` shows high bi: file pages are coming back into the page cache. Once warm, reads are memory copies.

  • A batch job that hurts latency

    A nightly job makes the API slow. `pidstat -w` shows the API with many involuntary switches. Moving the job into a cgroup with a cpu.max quota gives the API its CPU back.

  • A service killed in silence

    A Python service disappears every few hours with nothing in its log. The oom_kill counter in its cgroup's memory.events grows each time, and dmesg names the process the OOM killer chose.