From: Sourav Panda <souravpanda@google.com>
To: mathieu.desnoyers@efficios.com, willy@infradead.org,
david@redhat.com, pasha.tatashin@soleen.com,
rientjes@google.com, akpm@linux-foundation.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
weixugc@google.com, gthelen@google.com, souravpanda@google.com,
surenb@google.com
Subject: [RFC PATCH 0/6] Selective KSM: Synchronous and Partitioned Merging
Date: Fri, 21 Mar 2025 17:37:23 +0000 [thread overview]
Message-ID: <20250321173729.3175898-1-souravpanda@google.com> (raw)
The purpose of this RFC is to supplement our discussion in LSF/MM-25.
This is sent as a proof of concept. It applies on top of v6.14-rc7.
With the goal of increasing security and improving CPU efficiency,
we would like to propose making KSM synchronous and partitioned.
The synchronous aspect eliminates the need of ksmd running in the
background. Instead, userspace can trigger merging on the specified
memory region synchronously. Contrary to SKSM [1], which uses
MADV_MERGE, we also propose sysfs and syscall based alternatives.
The partitioned aspect divides the merge space into security domains.
Merging of pages only takes place within a partition, improving security.
Furthermore, trees in each partitioning becomes smaller, improving CPU
efficiency.
Proposal 1: SYSFS Interface
KSM_SYSFS=/sys/kernel/mm/ksm
echo "part_1" > ${KSM_SYSFS}/ksm/control/add_partition
ls ${KSM_SYSFS}/part_1/
pages_scanned pages_to_scan sleep_millisecs ...
echo "pid start_addr end_addr" > ${KSM_SYSFS}/part_1/trigger_merge
Proposal 2: SYSCALL Interface
Partition can be created or opened using:
int ksm_fd = ksm_open(ksm_name, flag);
name specifies the ksm partition to be created or opened.
flags:
O_CREAT
Create the ksm partition object if it does not exist.
O_EXCL
If O_CREAT was also specified, and a shared memory object
with the given name already exists, return an error.
Trigger the merge using:
ksm_merge(ksm_fd, pid, start_addr, size);
[1] https://lore.kernel.org/linux-mm/20250228023043.83726-1-mathieu.desnoyers@efficios.com/
Sourav Panda (6):
mm: introduce SELECTIVE_KSM KConfig
mm: make Selective KSM synchronous
mm: make Selective KSM partitioned
mm: create dedicated trees for SELECTIVE KSM partitions
mm: trigger unmerge and remove SELECTIVE KSM partition
mm: syscall alternative for SELECTIVE_KSM
arch/x86/entry/syscalls/syscall_64.tbl | 3 +-
include/linux/ksm.h | 4 +
mm/Kconfig | 11 +
mm/ksm.c | 823 ++++++++++++++++++++++---
4 files changed, 751 insertions(+), 90 deletions(-)
--
2.49.0.395.g12beb8f557-goog
next reply other threads:[~2025-03-21 17:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 17:37 Sourav Panda [this message]
2025-03-21 17:37 ` [RFC PATCH 1/6] mm: introduce SELECTIVE_KSM KConfig Sourav Panda
2025-03-21 17:37 ` [RFC PATCH 2/6] mm: make Selective KSM synchronous Sourav Panda
2025-03-21 17:37 ` [RFC PATCH 3/6] mm: make Selective KSM partitioned Sourav Panda
2025-03-21 17:37 ` [RFC PATCH 4/6] mm: create dedicated trees for SELECTIVE KSM partitions Sourav Panda
2025-03-21 17:37 ` [RFC PATCH 5/6] mm: trigger unmerge and remove SELECTIVE KSM partition Sourav Panda
2025-03-21 17:37 ` [RFC PATCH 6/6] mm: syscall alternative for SELECTIVE_KSM Sourav Panda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250321173729.3175898-1-souravpanda@google.com \
--to=souravpanda@google.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=gthelen@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=pasha.tatashin@soleen.com \
--cc=rientjes@google.com \
--cc=surenb@google.com \
--cc=weixugc@google.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox