October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

What Is Kernel Samepage Merging (KSM)?

Kernel Samepage Merging (KSM) lets Linux share identical pages in application-designated anonymous memory ranges, trading potential memory savings for scanning and metadata costs.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Kernel Samepage Merging (KSM) is a Linux feature that reduces physical memory use by sharing identical memory pages between opted-in applications. The kernel’s ksmd daemon scans eligible ranges; when it finds matching pages, it can replace them with one shared, write-protected page. If a process later changes that data, the kernel gives it a private copy.

What KSM merges—and what it leaves alone

KSM operates only on anonymous private pages: memory that is not backed by a file. It does not merge file page-cache pages, and it does not automatically scan all RAM. An application must mark a memory range as eligible using madvise(MADV_MERGEABLE). It can withdraw that advice with madvise(MADV_UNMERGEABLE). The Linux kernel documentation describes this scope in its Kernel Samepage Merging guide.

The feature was originally developed for KVM virtual machines, where separate guests may hold identical memory contents. It can also benefit other applications that generate repeated data, provided those applications designate suitable ranges.

How sharing works

  1. An application opts in. It marks a range as mergeable with madvise(MADV_MERGEABLE).
  2. ksmd scans eligible memory. The kernel daemon looks for identical pages among the designated ranges.
  3. Matching pages may be consolidated. Instead of keeping separate physical copies, the kernel can map the processes to one shared, write-protected page.
  4. A write creates a private copy. If a process attempts to change the shared contents, the kernel uses copy-on-write to give it its own page.

The kernel must be built with CONFIG_KSM=y for the feature to be available. An application’s mergeable-range registration can succeed even if ksmd is not running at that moment; the registered pages may be scanned if the daemon starts later.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
CORSAIR Vengeance LPX DDR4 RAM 32GB (2x16GB) Up to 3200MHz CL16-20-20-38 1.35V Intel XMP AMD EXPO Computer Memory – Black (CMK32GX4M2E3200C16)
  • Disclaimer: Maximum Speed requires overclocking/PC BIOS adjustments. Maximum speed and performance depend on system components, including motherboard and CPU
  • Hand-sorted memory chips ensure high performance with generous overclocking headroom
  • VENGEANCE LPX is optimized for wide compatibility with the latest Intel and AMD DDR4 motherboards
  • A low-profile height of just 34mm ensures that VENGEANCE LPX even fits in most small-form-factor builds
  • A solid aluminum heatspreader efficiently dissipates heat from each module so that they consistently run at high clock speeds

When KSM can help—and what it costs

KSM is useful only when opted-in ranges contain identical pages that can be shared. The amount of memory saved therefore depends on the application and workload; there is no general saving percentage that applies to every system.

Sharing also has costs. Scanning consumes CPU, and KSM uses reverse-mapping metadata to track scanned pages, which itself takes memory. The kernel’s KSM profitability guide describes an estimate for weighing potential savings against these costs. Treat it as a way to assess a particular system, not as a promise of a fixed benefit. Applications should limit MADV_MERGEABLE to ranges likely to benefit.

Rank #2
Crucial 32GB DDR5 RAM Kit (2x16GB), 5600MHz (or 5200MHz or 4800MHz) Laptop Memory 262-Pin SODIMM, Compatible with Intel Core and AMD Ryzen 7000, Black - CT2K16G56C46S5
  • Boosts System Performance: 32GB DDR5 RAM laptop memory kit (2x16GB) that operates at 5600MHz, 5200MHz, or 4800MHz to improve multitasking and system responsiveness for smoother performance
  • Accelerated gaming performance: Every millisecond gained in fast-paced gameplay counts—power through heavy workloads and benefit from versatile downclocking and higher frame rates
  • Optimized DDR5 compatibility: Best for 12th Gen Intel Core and AMD Ryzen 7000 Series processors — Intel XMP 3.0 and AMD EXPO also supported on the same RAM module
  • Trusted Micron Quality: Backed by 42 years of memory expertise, this DDR5 RAM is rigorously tested at both component and module levels, ensuring top performance and reliability
  • ECC Type = Non-ECC, Form Factor = SODIMM, Pin Count = 262-Pin, PC Speed = PC5-44800, Voltage = 1.1V, Rank And Configuration = 1Rx8
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

NUMA systems: sharing versus locality

On systems with non-uniform memory access (NUMA), allowing pages to be shared across nodes can increase deduplication, but may put a process’s memory farther from the CPU accessing it. Restricting merging to one node can preserve locality while reducing the pool of pages that can match. Which trade-off is preferable depends on the workload and machine; there is no universally best setting.

Rank #3
Corsair Vengeance RGB RS DDR5 16GB (2 x 8GB) Up to 6000MHz AMD Intel RAM
  • Disclaimer: Maximum Speed requires overclocking/PC BIOS adjustments. Maximum speed and performance depend on system components, including motherboard and CPU
  • AMD EXPO & Intel XMP 3.0 Compatible Only: Dual memory profiles allow you to easily select optimized settings for your platform, whether you’re running an AMD or Intel processor
  • Dynamic RGB Lighting: Individually addressable RGB lighting delivers vibrant effects through a sleek, understated panoramic diffuser
  • Onboard Voltage Regulation: Onboard voltage regulation for reliable power at high frequencies
  • Maximum Bandwidth and Tight Response Times: Optimized for peak performance on the latest AMD and Intel DDR5 motherboards

How to decide whether KSM fits

  • Check whether the application marks ranges as mergeable and whether those ranges are likely to contain duplicate data.
  • Use the running kernel’s KSM counters and profitability estimate to compare memory savings with scanner CPU use and metadata overhead.
  • On NUMA hardware, consider the effect of cross-node sharing on memory locality as well as the number of pages that can be merged.
  • Consult the documentation for the running kernel before changing sysfs controls: available settings and defaults can vary by kernel version.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.