Re: [PATCH v2 2/2] mm/ksm: prevent zero-page remapping during ksmd-triggered THP splits

From: Nico Pache

Date: Thu Nov 19 2026 - 01:18:54 EST




On 11/18/26 2:27 PM, Usama Arif wrote:


Hey Nico,

Hey Usama!


I think I have had this conversation either on the previous revision
or the mailing list somewhere else before, so sorry for restarting this
again.

Isnt above a good thing? KSM is a memory saving feature, and this
is resulting in 1G being freed instantly?

Not necessarily, for two reason (a), we are ignoring the users defined pages_to_scan, and (b), this leads to KSM using way more CPU time than the user expected, and in our customers cases, a overall system regression (outside of KSM also losing some effectiveness).>

As an alternate to having this patch, should we just have patch 1
and users should turn off split_underused_thp when using KSM.

Me and David have been discussing the opposite. I was going to drop patch 1 as patch 2 solves the underlying issue in a fairly clean manner.


If you have a large number of THPs on your machine, using KSM is a very
bad idea IMO due to all the splits that happen.
IMO, there are 2 optimum host conditions:
- A large number of THPs, and KSM disabled, hence shrinker can stay on.
- Very low number of THPs, KSM can be enabled or disabled, but as there
are a low number of THPs, the shrinker can be turned off.

This requires the user to be aware of these limitations and properly configure this system. With this patch we remove the weird interaction without needing any config changes. I think in our previous discussion David pushed back saying that it is not uncommon to see MADV_MERGEABLE and MADV_HUGEPAGE.

I think the approach in patch #2 is the most sound approach.

Let me know if that clears everything up!
Cheers,
-- Nico