Re: [PATCH v3 0/4] mm/ksm: keep smart scan from losing duplicate pages

From: David Hildenbrand (Arm)

Date: Sat Nov 07 2026 - 14:55:18 EST


On 11/7/26 17:56, Qiliang Yuan wrote:
> With smart scan, which is on by default, two identical pages that become
> mergeable some scans apart can stay unmerged for as long as they live:
> each page times its skipped scans on its own, and once both are old they
> may never be looked at in the same scan, which merging through the
> unstable tree requires. This was first noticed as intermittent failures
> of ksm_tests "KSM NUMA merging" in run_vmtests.sh.
>
> Patch 1 picks the skipped scans by the global scan number, so all old
> pages are looked at together every eighth scan. Over 420 pairs made
> mergeable 0 to 20 scans apart, 361 and 334 merged before on two boots
> and all of them after, at the cost of about 10% more ksmd time on memory
> that never merges.
>
> Patch 2 documents how smart scan picks the scans to skip.
>
> Patch 3 moves waiting for KSM full scans into a vm_util helper, and
> patch 4 adds a ksm_functional_tests case that fails 20/20 without patch
> 1 and 0/20 with it, on both boots.
>
> Signed-off-by: Qiliang Yuan <odys.yuan@xxxxxxxxx>
> ---

I'll wait a bit for more review before I queue this, thanks.

--
Cheers,

David