On Wed, May 18, 2022 at 04:58:27PM +1000, Balbir Singh wrote: > On Tue, May 17, 2022 at 09:27:01AM +0000, cgel.zte@xxxxxxxxx wrote: > > From: xu xin <xu.xin16@xxxxxxxxxx> > > > > For now, if we want to use KSM to merge pages of some apps, we have to > > explicitly call madvise() in application code, which means installed > > apps on OS needs to be uninstall and source code needs to be modified. > > It is very inconvenient because sometimes users or app developers are not > > willing to modify their app source codes for any reasons. > > > > I thought we got process_madvise in 5.13, doesn't that help solve the > problem with extensions to advice and an appropriate wrapper? Granted > it might be a little racy with a running process potentially > participating in KSM already. The reasons why I don't use process_madvise to achieve this include: 1. see https://lore.kernel.org/lkml/1835064.A2aMcgg3dW@xxxxxxxxxxxxxx/ 2. process_madvise is still a kind of madvise. processs_madvise from another process overrides the intention of origin app code ifself that also calls madvise, which is unrecoverable. For example, if a process "A" which madvises just one part of VMAs (not all) as MERGEABLE run on the OS already, meanwhile, if another process which doesn't know the information of "A" 's MERGEABLE areas, then call process_madvise to advise all VMAs of "A" as MERGEABLE, the original MERGEABLE information of "A" calling madivse is erasured permanently. > If we are concerned about KSM, I would assume that we care about long running processes, is that true? > Yes, it is. > Balbir Singh