Estimate memory fragmentation percentage from free memory chunk size distribution.
Memory fragmentation occurs when free memory is scattered in small non-contiguous chunks rather than available in large blocks. The fragmentation index (1 - largest_chunk/total_free) ranges from 0% (all free memory is one chunk) to near 100% (free memory is highly scattered). High fragmentation can cause large contiguous allocations to fail even when total free memory appears sufficient — a common issue affecting HugePages, DMA buffers, and large kernel allocations.
Fragmentation index
fragmentation% = (1 - largest_free_chunk / total_free_memory) × 100
Read /proc/buddyinfo to see the buddy allocator's free page counts at each order (4KB, 8KB, ..., 4MB). Low counts at higher orders indicate fragmentation. Also check /proc/pagetypeinfo for more detail.
Linux uses memory compaction (moving pages to create contiguous free space) and reclaim (freeing cached pages) to satisfy large allocations. You can trigger compaction manually via 'echo 1 > /proc/sys/vm/compact_memory'.