skills/computer-architecture/virtual-memory-paging-and-tlb/SKILL.md
Virtual memory skill for paging, page tables, and TLB. Use when explaining page faults, multi-level page tables, TLB behavior, or virtual vs physical addressing. Activates on queries about virtual memory, page table, TLB, page fault, mmap paging, or x86-64 paging.
npx skillsauth add mohitmishra786/low-level-dev-skills virtual-memory-paging-and-tlbInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Explain virtual memory: paging, multi-level page tables, TLB role, page faults, and address translation — bridging OS kernels, embedded MPU, and performance analysis.
mmap, brk, and demand pagingVirtual address (VA)
├── TLB lookup → physical on hit
└── TLB miss → page table walk → fill TLB
├── valid PTE → physical address
└── invalid → page fault (OS handles)
CR3 → PML4 → PDPT → PD → PT → physical frame
Linux on x86_64 uses 4 KiB pages (default) and optional 2 MiB / 1 GiB huge pages.
| Fault | Typical cause | |-------|----------------| | Major | Disk read — file-backed page not in RAM | | Minor | Zero-fill or COW break | | Protection | User access to kernel page, W^X violation |
# Linux page fault stats
grep pgfault /proc/vmstat
Large sparse address spaces + random pointer chasing → TLB misses dominate.
Mitigations:
mmap huge pages (MAP_HUGETLB, madvise(MADV_HUGEPAGE))numactl --membind for NUMAMany MCUs use MPU (region-based) not full paging — no TLB, fixed region count. Application processors use MMU + OS.
See skills/platform/riscv-privileged for Sv39/Sv48.
cat /proc/self/maps
pmap -x $$
/virtual-memory-paging-and-tlb Explain why 4 KiB random access hurts TLB and hugepage helps
| Symptom | Cause | Fix |
|---------|-------|-----|
| Segfault | Unmapped VA | Fix pointer; check maps |
| Slow mmap workload | TLB thrashing | Huge pages; reduce regions |
| COW spike after fork | Shared pages split on write | Expected; consider MAP_POPULATE |
| W^X fault | JIT without mprotect dance | Separate RW and RX mappings |
| Wrong phys on MCU | No MMU — linear map | Use linker script addresses |
skills/computer-architecture/memory-hierarchy-and-caches — cache after translationskills/kernel-dev/kernel-memory-management — kernel page allocatorskills/kernel/os-dev-scratch — build paging from scratchskills/platform/riscv-privileged — Sv39 page tablesskills/allocators/numa-programming — NUMA and migrationdevelopment
QEMU/KVM skill for virtualization and kernel development. Use when running qemu-system-x86_64 with KVM, configuring virtio devices, VFIO passthrough, QMP monitor, libvirt, or booting custom kernels. Activates on queries about QEMU, KVM, virtio, VFIO, virsh, virt-install, or -kernel -append.
development
Hardware virtualization internals skill for Intel VT-x and AMD-V. Use when studying VMCS/VMCB, EPT/NPT page tables, VMEXIT handling, APIC virtualization, or building minimal hypervisors. Activates on queries about VMX, SVM, VMCS, EPT, NPT, VMEXIT, or type-1 hypervisor.
testing
Linux containers internals skill for namespaces, cgroups, and OCI. Use when understanding clone/unshare namespaces, cgroups v2 limits, overlayfs, runc, seccomp profiles, capabilities, or escape mitigations. Activates on queries about namespaces, cgroups, overlayfs, runc, seccomp-bpf, OCI spec, or container escape.
tools
Reverse engineering skill for binary analysis. Use when decompiling with Ghidra, analyzing with radare2, scripting RE tools, triaging with strings/file/xxd, or diffing binaries. Activates on queries about Ghidra, radare2, r2, decompiler, Binary Ninja, Diaphora, or stripped binary analysis.