Re: [PATCH v6] mm/ksm: introduce ksm_force for each process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 10, 2022 at 03:30:36PM +0200, Oleksandr Natalenko wrote:
> Hello.
> 
> On úterý 10. května 2022 14:22:42 CEST cgel.zte@xxxxxxxxx wrote:
> > From: xu xin <xu.xin16@xxxxxxxxxx>
> > 
> > To use KSM, 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 inconvenient.
> > 
> > In order to change this situation, We add a new proc file ksm_force
> > under /proc/<pid>/ to support turning on/off KSM scanning of a
> > process's mm dynamically.
> > 
> > If ksm_force is set to 1, force all anonymous and 'qualified' VMAs
> > of this mm to be involved in KSM scanning without explicitly calling
> > madvise to mark VMA as MADV_MERGEABLE. But It is effective only when
> > the klob of /sys/kernel/mm/ksm/run is set as 1.
> > 
> > If ksm_force is set to 0, cancel the feature of ksm_force of this
> > process (fallback to the default state) and unmerge those merged pages
> > belonging to VMAs which is not madvised as MADV_MERGEABLE of this process,
> > but still leave MADV_MERGEABLE areas merged.
> 
> To my best knowledge, last time a forcible KSM was discussed (see threads [1], [2], [3] and probably others) it was concluded that a) procfs was a horrible interface for things like this one; and b) process_madvise() syscall was among the best suggested places to implement this (which would require a more tricky handling from userspace, but still).
> 
> So, what changed since that discussion?
>

Thanks a lot for your information. 
However, the patch here is slightly different from your previous discussion: 

your patch focuses on using procfs to change the madvise behaviour of another process,
but this patch will not modify the flag of all VMAs of the process. It introduces
a new bool ksm_force to represent this forcible feature of KSM based on process,
which is independent of madvise. the same way, process_madvise is a kind of
madvise in essence.

> P.S. For now I do it via dedicated syscall, but I'm not trying to upstream this approach.
> 
> [1] https://lore.kernel.org/lkml/2a66abd8-4103-f11b-06d1-07762667eee6@xxxxxxx/
> [2] https://lore.kernel.org/all/20190515145151.GG16651@xxxxxxxxxxxxxx/T/#u
> [3] https://lore.kernel.org/lkml/20190516172452.GA2106@avx2/
> [4] https://gitlab.com/post-factum/pf-kernel/-/commits/ksm-5.17/
> 
> Oleksandr Natalenko (post-factum)
> 



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux