From: "Xu Xin (vivo)" <xu.xin@linux.dev>
To: david@kernel.org
Cc: akpm@linux-foundation.org, chengming.zhou@linux.dev,
link@vivo.com, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-mm@kvack.org, ljs@kernel.org, tujinjiang@huawei.com,
xiao.wang@vivo.com, xu.xin@linux.dev
Subject: Re: [PATCH 2/4] ksm: skip rmap_item allocation for non-zero pages under only_merge_zero_pages
Date: Wed, 11 Nov 2026 17:36:57 +0800 [thread overview]
Message-ID: <20261111093657.123292-1-xu.xin@linux.dev> (raw)
In-Reply-To: <5445434f-078f-47d8-9851-dcc3712d18f1@kernel.org>
> I think we should get rid of any rmap items when merging the shared zeropage
> only. That might require more changes to the ksm code, but it really doesn't
> make any sense to have rmap items.
>
> Maybe we just want a separate KSM infrastrcture that only focuses on
> deduplciating shared zeropages in KSM: get a page, see if it is zero-filled. If
> so, try deduplciating with the shared zeropage. Done.
>
> Mangling this into the existing infrastructure might look easier but it just
> adds things like additional zero-page comparisons and (as Lorenzo points out)
> makes the code harder to understand + maintain.
Makes sense, I agree.
I actually thought about doing it this way at first, but went with the
current approach since it looked simpler back then. Without needing any
rmap_item tracking for zero pages, we can avoid rewriting scan_get_next_rmap_item()
with more complexities.
Splitting them up has two obvious wins:
1. ksm_do_scan() becomes much easier to read:
if (only_merge_zero_pages) {
scan_get_empty_page();
try_to_merge_with_zero_pages();
} else {
/* existing logic */
}
2. We can even add better filtering in scan_get_empty_page() to speed up
empty page scanning, without making scan_get_next_rmap_item() even messier.
That's a very constructive suggestion. I'll rework v3 this way.
Thanks,
Xu
next prev parent reply other threads:[~2026-11-11 9:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 7:43 [PATCH v2 0/4] KSM: introduce only_merge_zero_pages Xu Xin (vivo)
2026-11-10 7:44 ` [PATCH 1/4] ksm: add only_merge_zero_pages to merge only empty anonymous pages Xu Xin (vivo)
2026-11-10 7:44 ` [PATCH 2/4] ksm: skip rmap_item allocation for non-zero pages under only_merge_zero_pages Xu Xin (vivo)
2026-11-10 10:05 ` Lorenzo Stoakes (ARM)
2026-11-10 11:22 ` Xu Xin (vivo)
2026-11-10 12:42 ` Lorenzo Stoakes (ARM)
2026-11-11 8:36 ` Xu Xin (vivo)
2026-11-11 8:48 ` Lorenzo Stoakes (ARM)
2026-11-11 9:04 ` David Hildenbrand (Arm)
2026-11-11 9:08 ` David Hildenbrand (Arm)
2026-11-11 9:36 ` Xu Xin (vivo) [this message]
2026-11-10 7:44 ` [PATCH 3/4] selftests/ksm: consolidate ksm_stat readers into ksm_get_self_stat() Xu Xin (vivo)
2026-11-10 7:44 ` [PATCH 4/4] selftests/ksm: add test for only_merge_zero_pages Xu Xin (vivo)
2026-11-11 9:10 ` [PATCH 1/4] ksm: add only_merge_zero_pages to merge only empty anonymous pages David Hildenbrand (Arm)
2026-11-10 10:08 ` [PATCH v2 0/4] KSM: introduce only_merge_zero_pages Lorenzo Stoakes (ARM)
2026-11-10 11:34 ` Xu Xin (vivo)
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=20261111093657.123292-1-xu.xin@linux.dev \
--to=xu.xin@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=david@kernel.org \
--cc=link@vivo.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=tujinjiang@huawei.com \
--cc=xiao.wang@vivo.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.