Use this when large or latency-sensitive VMs need huge pages for memory performance.
Huge Pages · Memory Virtualization
Huge pages back VM memory with 2 MB or 1 GB pages instead of 4 KB, reducing TLB misses and page-table overhead for large or latency-sensitive VMs. They cannot be swapped or shared, so they reduce overcommit flexibility.
1. Huge pages improve TLB efficiency.
2. Static huge pages must be reserved.
3. THP is automatic but can cause latency.
4. Huge-page memory isn't shared or swapped.
5. Plan capacity.
reserved pages → VM backing
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Checks Verify boundary
grep -i huge /proc/meminfo
cat /sys/kernel/mm/transparent_hugepage/enabled
Check HugePages_Free drops when the VM starts.
Step 2 Common mistakes Narrow the fault
- Reserving more huge pages than VMs use, wasting RAM.
- Expecting memory overcommit with huge-page-backed VMs.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Huge pages are reserved and not swappable.
- Allocate at boot to avoid fragmentation.
- Wrong count wastes RAM.
grep -i hugepages /proc/meminfo— reserved/free huge pagescat /sys/kernel/mm/transparent_hugepage/enabled— THP modevirsh dumpxml <vm> | grep hugepages— VM uses huge pages
ReferenceWhy it matters1 section · depth on demand
How it works
Huge pages use 2 MB or 1 GB memory pages instead of 4 KB, reducing TLB misses and page-table overhead for large VMs and databases. The host must reserve them in advance, and memory backed by huge pages cannot be swapped.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Reserve huge pages on the host
The kernel documentation describes the HugePages_* fields in /proc/meminfo, the nr_hugepages sysctl and the hugepages= boot parameter, which it calls the most reliable way to preallocate because memory is not yet fragmented at boot.
# 1 GiB pages reserved at boot (kernel command line)
default_hugepagesz=1G hugepagesz=1G hugepages=64
# or 2 MiB pages at runtime (may fail on a fragmented host)
echo 8192 > /proc/sys/vm/nr_hugepages
$ grep -i huge /proc/meminfo
HugePages_Total: 64
HugePages_Free: 48
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 1048576 kB
Use them for a VM
| Platform | Configuration |
|---|---|
| Proxmox VE | qm set 101 --hugepages 1024 (1 GiB pages; 2 for 2 MiB, any) |
| libvirt | <memoryBacking><hugepages><page size='1' unit='G'/></hugepages></memoryBacking> |
The VM's memory must be a multiple of the page size, and enough free pages must exist on the right NUMA node when the VM starts — otherwise the start fails.
Trade-offs
| Benefit | Cost |
|---|---|
| Fewer TLB misses; lower latency for memory-heavy guests (databases, NFV, DPDK) | Memory is reserved, cannot be used by anything else |
| Memory cannot be swapped or merged by KSM — predictable | No overcommit; ballooning does not return memory to the host |
| Required by some workloads (DPDK, real-time) | Live migration needs free huge pages on the target |
When it is worth it
Large guests (tens of GB) with random memory access benefit most; small general-purpose VMs see little difference because Transparent Huge Pages already back much guest memory with 2 MiB pages. Measure before and after (application latency, perf stat -e dTLB-load-misses on the QEMU process).
Plan the reservation
Reserved huge pages disappear from MemAvailable. Size them per NUMA node (/sys/devices/system/node/node*/hugepages/) and leave enough normal memory for the host, ZFS ARC and non-hugepage VMs.
*The huge-page reservation and memory counters above are illustrative examples, not captured from a lab or production host.*
Configuration
# KVM host: reserve 1024 × 2 MB pages
echo 1024 > /proc/sys/vm/nr_hugepages
grep Huge /proc/meminfo
# Proxmox VM
qm set 101 --hugepages 2
Documented example, not captured output. Huge pages cannot be swapped or shared (KSM), so size them carefully.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Memory Virtualization → Huge Pages. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://libvirt.org/docs.html · confidence 94%