From: Peng Liang <liangpeng10@huawei.com>
To: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Cc: <akpm@linux-foundation.org>, <hughd@google.com>,
<xiexiangyou@huawei.com>, <zhengchuan@huawei.com>,
<wanghao232@huawei.com>, <liangpeng10@huawei.com>
Subject: [RFC 0/1] memfd: Support mapping to zero page on reading
Date: Wed, 22 Dec 2021 20:33:59 +0800 [thread overview]
Message-ID: <20211222123400.1659635-1-liangpeng10@huawei.com> (raw)
Hi all,
Recently we are working on implementing CRIU [1] for QEMU based on
Steven's work [2]. It will use memfd to allocate guest memory in order
to restore (inherit) it in the new QEMU process. However, memfd will
allocate a new page for reading while anonymous memory will map to zero
page for reading. For QEMU, memfd may cause that all memory are
allocated during the migration because QEMU will read all pages in
migration. It may lead to OOM if over-committed memory is enabled,
which is usually enabled in public cloud.
In this patch I try to add support mapping to zero pages on reading
memfd. On reading, memfd will map to zero page instead of allocating a
new page. Then COW it when a write occurs.
For now it's just a demo for discussion. There are lots of work to do,
e.g.:
1. don't support THP;
2. don't support shared reading and writing, only for inherit. For
example:
task1 | task2
1) read from addr |
| 2) write to addr
3) read from addr again |
then 3) will read 0 instead of the data task2 writed in 2).
Would something similar be welcome in the Linux?
Thanks,
Peng
[1] https://criu.org/Checkpoint/Restore
[2] https://patchwork.kernel.org/project/qemu-devel/cover/1628286241-217457-1-git-send-email-steven.sistare@oracle.com/
Peng Liang (1):
memfd: Support mapping to zero page on reading memfd
include/linux/fs.h | 2 ++
include/uapi/linux/memfd.h | 1 +
mm/memfd.c | 8 ++++++--
mm/memory.c | 37 ++++++++++++++++++++++++++++++++++---
mm/shmem.c | 10 ++++++++--
5 files changed, 51 insertions(+), 7 deletions(-)
--
2.33.1
next reply other threads:[~2021-12-22 12:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-22 12:33 Peng Liang [this message]
2021-12-22 12:34 ` [RFC 1/1] " Peng Liang
2022-01-12 2:30 ` [RFC 0/1] " Hugh Dickins
2022-01-12 3:33 ` Yang Shi
2022-01-12 5:02 ` Hugh Dickins
2022-01-12 4:32 ` Matthew Wilcox
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=20211222123400.1659635-1-liangpeng10@huawei.com \
--to=liangpeng10@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=wanghao232@huawei.com \
--cc=xiexiangyou@huawei.com \
--cc=zhengchuan@huawei.com \
/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