How the TLB makes virtual memory fast on Linux
▲ 7 r/linux

How the TLB makes virtual memory fast on Linux

I made a visual explainer on how the TLB and address translation work on Linux/x86-64.

Every memory access uses a virtual address, which the CPU has to translate to physical memory. Doing a full page table walk every time would be extremely slow, so CPUs cache those translations in the TLB.

The video also covers things like TLB misses, huge pages, PCIDs, context switches, TLB shootdowns and what happens when a TLB invalidation goes wrong.

Link for anyone interested

Feedback welcome :)

u/Ok_Marionberry8922 — 2 days ago
▲ 14 r/linux

How shared memory actually works in Linux

Had some free time recently so I made a visual explainer on how shared memory actually works in Linux.

Normally, two processes have completely separate virtual address spaces. Process A shouldn't be able to touch Process B's memory at all.

But with shared memory, one process can write a value and another process can read it without copying the payload between them.

The video goes through virtual memory, page tables, physical frames, shm_open, ftruncate, mmap with MAP_SHARED, lazy allocation, and what actually happens when either process touches the mapping.

I also get into related mechanisms like memory-mapped files, shared libraries, copy-on-write after fork(), zero-copy IPC, and eventually Dirty COW and what can happen when these page-table tricks go wrong.

Link for anyone interested

Feedback welcome :)

u/Ok_Marionberry8922 — 11 days ago
▲ 154 r/linux

How Linux services talk to each other through D-Bus

Had some free time last week so I made a visual explainer on how D-Bus works in Linux.

A modern Linux desktop is made up of a bunch of separate processes. NetworkManager, systemd, BlueZ, logind, polkit, UPower and desktop applications all need some way to call each other and broadcast when something changes.

A lot of that communication happens through D-Bus.

The video covers the system bus and session bus, service names, object paths, interfaces, method calls, signals, introspection, service activation, dbus-daemon, dbus-broker, and how applications actually use all of this, etc

Link for anyone interested

Feedback welcome :)

u/Ok_Marionberry8922 — 25 days ago

Why two O(n²) loops can run 15× apart

Two nested loops can do the same work, have the same O(n²) complexity, and still run around 15× apart.

A visual explainer on why: the RAM model, the memory wall, cache lines, locality, L1/L2/L3, prefetching, data layout and false sharing.

It also covers how the timing difference between a cache hit and miss became the side channel behind Spectre and Meltdown.

youtu.be
u/Ok_Marionberry8922 — 29 days ago
▲ 22 r/linux+1 crossposts

How fork() duplicates a process without copying its memory

A visual explainer on how copy-on-write makes fork() cheap.

A 10 GB process can fork almost instantly because Linux copies the page tables, shares the physical pages, marks them read-only, and only copies a page when one of the processes writes to it.

It also covers fork() + exec(), how Redis snapshots work, Android Zygote, lazy zero pages, and some CVEs

youtube.com
u/Ok_Marionberry8922 — 1 month ago
▲ 79 r/virtualization+2 crossposts

How Linux runs a virtual machine as a process

A visual explainer on the programming model behind KVM.

A virtual CPU is just a host thread calling KVM_RUN, guest RAM is mapped into the process, and execution returns to userspace whenever the guest triggers a VM exit.

It also covers /dev/kvm, hardware virtualization, EPT/NPT, QEMU, virtio and vhost.

youtube.com
u/Ok_Marionberry8922 — 1 month ago
▲ 1 r/C_Programming+1 crossposts

How Processes Share Memory Without Copying

I made a visual walkthrough of POSIX shared memory in C: creating an object with shm_open, sizing it with ftruncate, and mapping it into two processes with mmap(MAP_SHARED).

The video follows the mappings down through virtual addresses, page tables, physical frames, lazy allocation, and copy-on-write, then briefly looks at Dirty COW.

Suggestions are welcome :)

youtu.be
u/Ok_Marionberry8922 — 1 month ago
▲ 23 r/C_Programming+2 crossposts

A Visual walkthrough of C code that runs inside the Linux kernel (eBPF)

I made a visual walkthrough of Linux eBPF from the C/kernel boundary: restricted C, clang, bpf(), verifier checks, maps, ring buffers, and attach points.

Thought it might fit here since eBPF is basically structs, pointers, syscalls, file descriptors, memory bounds, and kernel/userspace state sharing.

youtu.be
u/Ok_Marionberry8922 — 1 month ago
▲ 11 r/C_Programming+1 crossposts

io_uring Feels Illegal

A visual walkthrough of how io_uring works: shared rings, SQEs/CQEs, batching, SQPOLL, multishot operations, linked operations, fixed/provided buffers, and the tradeoffs that come with exposing such a powerful linux kernel interface.

youtu.be
u/Ok_Marionberry8922 — 2 months ago
▲ 27 r/Zig

Building a file indexer in Zig

Hello guys, I made a video about building a real time file indexer in zig using Linux inotify.

It’s the first piece of a file sync project I’m building from scratch. I tried to keep it practical and beginner friendly.

Any thoughts or feedback?

youtu.be
u/Ok_Marionberry8922 — 2 months ago