Breakdown of changes to Kernel Samepage Merging (KSM) by Kernel Version

This article describes how Linux Kernel Samepage Merging (KSM) has changed.

Kernel Samepage Merging has changed over the last couple of versions. This document provides an overview of the changes by version. The document will be updated as new kernel versions become available.

Add new metric pages scanned in /sys/kernel/mm/ksm/pages_scanned.

Add “smart scan” mode to skip pages that have not been de-duplicated in previous scans.

Add KSM information to /proc/<pid>/smaps and /proc/<pid>/smaps_rollup

  • d256d1cd8da1 mm: memory-failure: use rcu lock instead of tasklist_lock when collect_procs()
  • 5994eabf3bbb merge mm-hotfixes-stable into mm-stable to pick up depended-upon changes
  • b348b5fe2b5f mm/ksm: add pages scanned metric

Expose pages scanned metric in /sys/kernel/mm/ksm/pages_scanned

  • 1a8e84305783 ksm: consider KSM-placed zeropages when calculating KSM profit

Include zero pages when calculating /sys/kernel/mm/ksm/general_profit

  • 2c281f54f556 mm/ksm: move disabling KSM from s390/gmap code to KSM code
  • 24139c07f413 mm/ksm: unmerge and clear VM_MERGEABLE when setting PR_SET_MEMORY_MERGE=0
  • d21077fbc2fc mm: add new KSM process and sysfs knobs
  • expose new general_profit metric /sys/kernel/mm/ksm/general_profit
  • expose process_profit metric in /proc//ksm_stat
  • expose ksm_merging_pages metric in /proc//ksm_stat

new prctl api to enable KSM per process

KSM tracepoints for scan start and stop

  • 6db504ce55bd mm/ksm: fix race with VMA iteration and mm_struct teardown
  • f67d6b266493 Merge branch ‘mm-hotfixes-stable’ into mm-stable
  • 7d4a8be0c4b2 mm/mmu_notifier: remove unused mmu_notifier_range_update_to_read_only export
  • b970599e807 mm: hwpoison: support recovery from ksm_might_need_to_copy()
  • d7c0e68dab98 mm/ksm: convert break_ksm() to use walk_page_range_vma()
  • 6cce3314b928 mm/ksm: fix KSM COW breaking with userfaultfd-wp via FAULT_FLAG_UNSHARE
  • 58f595c66591 mm/ksm: simplify break_ksm() to not rely on VM_FAULT_WRITE
  • 6a56ccbcf6c6 mm/autonuma: use can_change_(pte|pmd)_writable() to replace savedwrite
  • 1eeaa4fd39b0 memory: move hotplug memory notifier priority to same file for easy sorting
  • b4e6f66e45b4 ksm: use a folio in replace_page()
  • 58730ab6c7ca ksm: convert to use common struct mm_slot
  • 79b099415637 ksm: convert to ksm_mm_slot.hash
  • 23f746e412b4 ksm: convert ksm_mm_slot.mm_list to ksm_mm_slot.mm_node
  • 21fbd59136e0 ksm: add the ksm prefix to the names of the ksm private structures
  • cb4df4cae4f2 ksm: count allocated ksm rmap_items for each process

Added /proc/<pid>/ksm_stat to report ksm_rmap_items.

  • f7091ed64ec8 mm: fix the handling Non-LRU pages returned by follow_page
  • a5f18ba07276 mm/ksm: use vma iterators instead of vma linked list
  • 088b8aa537c2 mm: fix PageAnonExclusive clearing racing with concurrent RCU GUP-fast
  • 507228044236 mm/khugepaged: record SCAN_PMD_MAPPED when scan_pmd() finds hugepage
  • 3218f8712d6b mm: handling Non-LRU pages returned by vm_normal_pages
  • 9800562f2ab4 mm/folio-compat: Remove migration compatibility functions