linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC v2 0/4] mm/ksm: add option to automerge VMAs
@ 2019-05-14 13:16 Oleksandr Natalenko
  2019-05-14 13:16 ` [PATCH RFC v2 1/4] mm/ksm: introduce ksm_enter() helper Oleksandr Natalenko
                   ` (4 more replies)
  0 siblings, 5 replies; 21+ messages in thread
From: Oleksandr Natalenko @ 2019-05-14 13:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Kirill Tkhai, Vlastimil Babka, Michal Hocko, Matthew Wilcox,
	Pavel Tatashin, Timofey Titovets, Aaron Tomlin, Grzegorz Halat,
	linux-mm

By default, KSM works only on memory that is marked by madvise(). And the
only way to get around that is to either:

  * use LD_PRELOAD; or
  * patch the kernel with something like UKSM or PKSM.

Instead, lets implement a sysfs knob, which allows marking VMAs as
mergeable. This can be used manually on some task in question or by some
small userspace helper daemon.

The knob is named "force_madvise", and it is write-only. It accepts a PID
to act on. To mark the VMAs as mergeable, use:

   # echo PID > /sys/kernel/mm/ksm/force_madvise

To unmerge all the VMAs, use the same approach, prepending the PID with
the "minus" sign:

   # echo -PID > /sys/kernel/mm/ksm/force_madvise

This patchset is based on earlier Timofey's submission [1], but it doesn't
use dedicated kthread to walk through the list of tasks/VMAs. Instead,
it is up to userspace to traverse all the tasks in /proc if needed.

The previous suggestion [2] was based on amending do_anonymous_page()
handler to implement fully automatic mode, but this approach was
incorrect due to improper locking and not desired due to excessive
complexity.

The current approach just implements minimal interface and leaves the
decision on how and when to act to userspace.

Thanks.

[1] https://lore.kernel.org/patchwork/patch/1012142/
[2] http://lkml.iu.edu/hypermail/linux/kernel/1905.1/02417.html

Oleksandr Natalenko (4):
  mm/ksm: introduce ksm_enter() helper
  mm/ksm: introduce ksm_leave() helper
  mm/ksm: introduce force_madvise knob
  mm/ksm: add force merging/unmerging documentation

 Documentation/admin-guide/mm/ksm.rst |  11 ++
 mm/ksm.c                             | 160 +++++++++++++++++++++------
 2 files changed, 137 insertions(+), 34 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2019-05-16  7:53 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-14 13:16 [PATCH RFC v2 0/4] mm/ksm: add option to automerge VMAs Oleksandr Natalenko
2019-05-14 13:16 ` [PATCH RFC v2 1/4] mm/ksm: introduce ksm_enter() helper Oleksandr Natalenko
2019-05-14 13:16 ` [PATCH RFC v2 2/4] mm/ksm: introduce ksm_leave() helper Oleksandr Natalenko
2019-05-14 13:16 ` [PATCH RFC v2 3/4] mm/ksm: introduce force_madvise knob Oleksandr Natalenko
2019-05-14 13:22   ` Aaron Tomlin
2019-05-15  0:48     ` Timofey Titovets
2019-05-14 13:16 ` [PATCH RFC v2 4/4] mm/ksm: add force merging/unmerging documentation Oleksandr Natalenko
2019-05-15  0:53   ` Timofey Titovets
2019-05-15  6:26     ` Oleksandr Natalenko
2019-05-14 14:41 ` [PATCH RFC v2 0/4] mm/ksm: add option to automerge VMAs Michal Hocko
2019-05-14 14:51   ` Michal Hocko
2019-05-15  6:25     ` Oleksandr Natalenko
2019-05-15  6:53       ` Michal Hocko
2019-05-15  7:37         ` Oleksandr Natalenko
2019-05-15  8:33           ` Michal Hocko
2019-05-15  8:51             ` Oleksandr Natalenko
2019-05-15 14:24               ` Michal Hocko
2019-05-15 14:51         ` Michal Hocko
2019-05-15 15:15           ` Greg KH
2019-05-16  7:47             ` Michal Hocko
2019-05-16  7:53               ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).