From: "David Hildenbrand (Arm)" <david@kernel.org>
To: "Xu Xin (vivo)" <xu.xin@linux.dev>
Cc: g@dgvxl46587.localhost.localdomain,
Andrew Morton <akpm@linux-foundation.org>,
Jonathan Corbet <corbet@lwn.net>,
Chengming Zhou <chengming.zhou@linux.dev>,
Lorenzo Stoakes <lstoakes@gmail.com>,
"Liam R . Howlett" <liam.howlett@oracle.com>,
linux-mm@kvack.org, linux-doc@vger.kernel.org,
Huan Yang <link@vivo.com>, Wang Xiao <xiao.wang@vivo.com>
Subject: Re: [PATCH resend] ksm: add merge_only_zero_pages to merge only empty anonymous pages
Date: Tue, 10 Nov 2026 12:54:19 +0100 [thread overview]
Message-ID: <c092dbef-515b-4575-8669-efef8ebb6e29@kernel.org> (raw)
In-Reply-To: <avJ0p8ZfjZc9EewW@dgvxl46587.localhost.localdomain>
On 11/10/26 02:34, Xu Xin (vivo) wrote:
> On Mon, Nov 09, 2026 at 06:41:39PM +0100, David Hildenbrand (Arm) wrote:
>> On 11/9/26 02:39, Xu Xin (vivo) wrote:
>>>
>>> Ha, fair question :) This came from our own investigation. We were looking
>>> into whether KSM can actually provide benefits on Android phones, and this
>>> observation came from real-world application workloads. To be fully honest:
>>> I did use an LLM to help polish the English wording of the commit description,
>>> but I carefully rechecked and verified every sentence myself..
>>
>> The reason why I ask is that this effectively disables most deduplication where
>> KSM was originally invented for: VMs running the same kernels, libaries,
>> executables etc.
>
> Yes, it closes the original scenarios like KVM, so I wrote a Note to say that in
> commit description and Documentations. But it opens up some new application scenarios
> — scenarios with high security and low cpu-consuming requirements, where merging
> zero pages alone can already bring benefits.
>
>>
>> So yeah, disabling most deduplication shrinks side-channels ... by disabling the
>> core functionality of KSM, to dedupicate pages with the same content :)
>>
>>>
>>>
>>> We still keep the stable/unstable tree data structures, but zero-page merging
>>> does not participate in the stable/unstable tree search path. One more reason
>>> for keeping them is that merge_only_zero_page is designed as a dynamic knob
>>> that can be toggled at runtime, so when it is disabled KSM can fall back to
>>> the traditional full KSM behavior.
>>
>>
>> What's the memory overhead from keeping these datastructures in the
>> merge_only_zero_page-only path?
>
> In the merge_only_zero_page-only path of current implementation, the main memory
> overhead comes from the ksm_rmap_items for non-zero pages, RB trees of stable and
> unstable, and mm_slots.
>
> If the allocation of rmap_item can be avoided (following Tu Jinjiang’s idea), then
> only the stable_tree and unstable_tree remain, which are basically empty, and these
> overheads become so low that they are negligible. The mm_slots are essential so can't
> be avoid, but won't take up much memory.
Okay, so that's the right approach then.
--
Cheers,
David
prev parent reply other threads:[~2026-11-10 11:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 3:48 [PATCH resend] ksm: add merge_only_zero_pages to merge only empty anonymous pages xu.xin
2026-11-07 3:49 ` sashiko-bot
2026-11-07 8:13 ` Jinjiang Tu
2026-11-09 2:02 ` Xu Xin (vivo)
2026-11-09 3:17 ` Jinjiang Tu
2026-11-09 17:56 ` David Hildenbrand (Arm)
2026-11-09 7:58 ` Xu Xin (vivo)
2026-11-10 2:02 ` Jinjiang Tu
2026-11-07 18:28 ` David Hildenbrand (Arm)
2026-11-09 1:39 ` Xu Xin (vivo)
2026-11-09 17:41 ` David Hildenbrand (Arm)
2026-11-10 1:34 ` Xu Xin (vivo)
2026-11-10 11:54 ` David Hildenbrand (Arm) [this message]
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=c092dbef-515b-4575-8669-efef8ebb6e29@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=corbet@lwn.net \
--cc=g@dgvxl46587.localhost.localdomain \
--cc=liam.howlett@oracle.com \
--cc=link@vivo.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lstoakes@gmail.com \
--cc=xiao.wang@vivo.com \
--cc=xu.xin@linux.dev \
/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.