[PATCH RFC 0/4] mm/ksm: add option to automerge VMAs

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

 



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 so-called "always" mode, which allows marking
VMAs as mergeable on do_anonymous_page() call automatically.

The submission introduces a new sysctl knob as well as kernel cmdline option
to control which mode to use. The default mode is to maintain old
(madvise-based) behaviour.

Due to security concerns, this submission also introduces VM_UNMERGEABLE
vmaflag for apps to explicitly opt out of automerging. Because of adding
a new vmaflag, the whole work is available for 64-bit architectures only.

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.

For my laptop it saves up to 300 MiB of RAM for usual workflow (browser,
terminal, player, chats etc). Timofey's submission also mentions
containerised workload that benefits from automerging too.

Open questions:

  * once "always" mode is activated, should re-scan of all VMAs be
    triggered to find eligible ones for automerging?

Thanks.

[1] https://lore.kernel.org/patchwork/patch/1012142/

Oleksandr Natalenko (4):
  mm/ksm: introduce ksm_enter() helper
  mm/ksm: introduce VM_UNMERGEABLE
  mm/ksm: allow anonymous memory automerging
  mm/ksm: add automerging documentation

 .../admin-guide/kernel-parameters.txt         |   7 +
 Documentation/admin-guide/mm/ksm.rst          |   7 +
 fs/proc/task_mmu.c                            |   3 +
 include/linux/ksm.h                           |   5 +
 include/linux/mm.h                            |   6 +
 include/trace/events/mmflags.h                |   7 +
 mm/ksm.c                                      | 142 ++++++++++++++----
 mm/memory.c                                   |   6 +
 8 files changed, 157 insertions(+), 26 deletions(-)

-- 
2.21.0




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux