// the find
torvalds/test-tlb
Stupid memory latency and TLB tester
A single-file C program from Linus Torvalds for measuring memory latency and TLB behavior across different buffer sizes and page configurations. It tests sequential stride access versus random pointer-chasing to expose cache hierarchy and TLB characteristics. Aimed at kernel developers and hardware people who need to profile memory subsystems, not general application developers.
The random pointer-chasing approach (vs. stride loops) is the right way to measure true memory latency rather than prefetcher-inflated bandwidth numbers. The hugepage flag (-H via MADV_HUGEPAGE) lets you isolate TLB miss cost from cache associativity effects — the README actually explains why these conflate, which is more educational than most benchmarks bother to be. Makefile drives a sweep from 4kB to 256MB automatically, giving you a full latency curve in one run. GPLv2 with an explicit note that Linus will relicense on request is a pragmatic touch for a tool this niche.
The CPU frequency is hardcoded as a #define you must edit before the cycle counts mean anything — on modern CPUs with frequency scaling, those numbers will be wrong anyway without pinning frequency first. No noise reduction: one second per test, no iteration averaging, results vary noticeably between runs depending on virtual-to-physical mapping. The hardcoded constants (page size, hugepage size, stride, max buffer) in both the C file and the Makefile mean every new machine requires manual editing rather than runtime detection. Linux-only due to MADV_HUGEPAGE and the madvise() calls, with no portability shim or compile guard.