Messages in this thread | | | Date | Wed, 11 May 2022 03:12:03 +0000 | From | CGEL <> | Subject | Re: [PATCH v6] mm/ksm: introduce ksm_force for each process |
| |
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@gmail.com wrote: > > From: xu xin <xu.xin16@zte.com.cn> > > > > 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@suse.cz/ > [2] https://lore.kernel.org/all/20190515145151.GG16651@dhcp22.suse.cz/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) >
| |