Use this when evaluating memory deduplication (TPS, KSM) and its security trade-offs.
Memory Sharing
Memory sharing (Transparent Page Sharing on ESXi, KSM on KVM) deduplicates identical memory pages across VMs. It saves RAM for similar guests but is limited by default today because of side-channel security concerns.
1. Memory sharing (KSM, TPS) merges identical pages.
2. Saves memory for similar guests.
3. Costs CPU; side-channel concerns (inter-VM sharing off by default on ESXi).
4. Monitor savings.
5. Disable if not useful.
identical pages → merged → copy on write
Context & applicabilityCommon mistakes · platform/version boundaries
- Enabling KSM on hosts with sensitive multi-tenant workloads.
- Expecting large savings with large pages enabled.
- Ignoring the CPU cost of scanning on busy hosts.
Operational reference
Fast context before you go deeper.
esxtop → m → SHRD, ZERO columnsVerification & 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
cat /sys/kernel/mm/ksm/run # 1 = KSM active
cat /sys/kernel/mm/ksm/pages_sharing
esxtop → m → SHRD, ZERO columns
High pages_sharing means real savings. On Proxmox, KSM (ksmtuned) starts sharing when host memory use passes a threshold (80 % by default).
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.
- Sharing saves RAM for similar guests.
- Inter-VM sharing is limited for security.
- Large pages reduce sharing.
cat /sys/kernel/mm/ksm/pages_sharing— KSM shared pagessystemctl status ksmtuned— KSM tuneresxtop— SHRD (TPS)
ReferenceWhy it matters1 section · depth on demand
Trade-offs
- Saves memory when many similar VMs run (same OS, VDI).
- Costs CPU for scanning pages.
- Side-channel risk: since 2014 ESXi shares pages only within a VM by default (salting); KSM on KVM is often disabled on multi-tenant hosts.
- Large pages (2 MB) reduce sharing until the host is under pressure and breaks them into small pages.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
Memory sharing deduplicates identical memory pages across VMs: KSM on KVM, Transparent Page Sharing (TPS) on VMware. Savings are largest with many similar VMs (VDI, identical Linux guests).
Security: page sharing can enable side-channel attacks between VMs, so VMware disables inter-VM TPS by default (salting) and large pages reduce sharing opportunities further. KSM costs CPU for scanning.
cat /sys/kernel/mm/ksm/pages_sharing # pages saved
systemctl status ksmtuned
ReferenceConfiguration & state1 section · depth on demand
Configuration
systemctl status ksmtuned # Proxmox/KVM
echo 1 > /sys/kernel/mm/ksm/run
ESXi: Mem.ShareForceSalting controls inter-VM sharing (2 = only within a VM, default).
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 → Memory Sharing. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://libvirt.org/docs.html · confidence 94%