Pcornel
Browse topics
Options
Recent
Favorites
Virtualization · Technical reference

Huge Pages · Memory Virtualization

Direct answer

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.

When to use this

Use this when large or latency-sensitive VMs need huge pages for memory performance.

First 30 seconds

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.

Operational verification

reserved pages → VM backing

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
virtualization-hardware
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformvirtualization-hardware
Scope / prerequisiteUse this when large or latency-sensitive VMs need huge pages for memory performance.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Key points
  • Huge pages are reserved and not swappable.
  • Allocate at boot to avoid fragmentation.
  • Wrong count wastes RAM.
Key checks
  • grep -i hugepages /proc/meminfo — reserved/free huge pages
  • cat /sys/kernel/mm/transparent_hugepage/enabled — THP mode
  • virsh 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

PlatformConfiguration
Proxmox VEqm 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

BenefitCost
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 — predictableNo 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.*

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docvirtualization-hardware current

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%
Confirmation

Confirm action

Continue?