From: David Hildenbrand <david@redhat.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Sean Christopherson <seanjc@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Matthew Wilcox <willy@infradead.org>,
Olivier Dion <odion@efficios.com>,
linux-mm@kvack.org
Subject: Re: [RFC PATCH 0/2] SKSM: Synchronous Kernel Samepage Merging
Date: Fri, 28 Feb 2025 22:45:57 +0100 [thread overview]
Message-ID: <adc90638-79a7-4015-accc-0932611cc697@redhat.com> (raw)
In-Reply-To: <331ed532-eb98-4665-9d1b-b6b8bf46e396@efficios.com>
On 28.02.25 22:38, Mathieu Desnoyers wrote:
> On 2025-02-28 10:10, David Hildenbrand wrote:
> [...]
>> For example, QEMU will mark all guest memory is mergeable using MADV, to
>> limit the deduplicaton to guest RAM only.
>>
>
> On a related note, I think the madvise(2) documentation is inaccurate.
>
> It states:
>
> MADV_MERGEABLE (since Linux 2.6.32)
> Enable Kernel Samepage Merging (KSM) for the pages in the range
> specified by addr and length. [...]
>
> AFAIU, based on code review of ksm_madvise(), this is not strictly true.
>
> The KSM implementation enables KSM for pages in the entire vma containing the range.
> So if it so happens that two mmap areas with identical protection flags are merged,
> both will be considered mergeable by KSM as soon as at least one page from any of
> those areas is made mergeable.
I *think* it does what is documented. In madvise_vma_behavior(),
ksm_madvise() will update "new_flags".
Then we call madvise_update_vma() to split the VMA if required and set
new_flags only on the split VMA. The handling is similar to other MADV
operations that end up modifying vm_flags.
If I am missing something and this is indeed broken, we should
definitely write a selftest for it and fix it.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-02-28 21:46 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-28 2:30 Mathieu Desnoyers
2025-02-28 2:30 ` [RFC PATCH 1/2] mm: Introduce " Mathieu Desnoyers
2025-02-28 2:30 ` [RFC PATCH 2/2] selftests/kskm: Introduce SKSM basic test Mathieu Desnoyers
2025-02-28 2:51 ` [RFC PATCH 0/2] SKSM: Synchronous Kernel Samepage Merging Linus Torvalds
2025-02-28 3:03 ` Mathieu Desnoyers
2025-02-28 5:17 ` Linus Torvalds
2025-02-28 13:59 ` David Hildenbrand
2025-02-28 14:59 ` Sean Christopherson
2025-02-28 15:10 ` David Hildenbrand
2025-02-28 15:19 ` David Hildenbrand
2025-02-28 21:38 ` Mathieu Desnoyers
2025-02-28 21:45 ` David Hildenbrand [this message]
2025-02-28 21:49 ` Mathieu Desnoyers
2025-02-28 15:01 ` Mathieu Desnoyers
2025-02-28 15:18 ` David Hildenbrand
2025-02-28 14:59 ` Mathieu Desnoyers
2025-02-28 16:32 ` Peter Xu
2025-02-28 17:53 ` Mathieu Desnoyers
2025-02-28 22:32 ` Peter Xu
2025-03-01 15:44 ` Mathieu Desnoyers
2025-03-03 15:01 ` Peter Xu
2025-03-03 16:36 ` David Hildenbrand
2025-03-03 20:01 ` Mathieu Desnoyers
2025-03-03 20:45 ` Peter Xu
2025-03-03 20:49 ` David Hildenbrand
2025-03-05 14:06 ` Mathieu Desnoyers
2025-03-05 19:22 ` David Hildenbrand
2025-02-28 15:34 ` David Hildenbrand
2025-02-28 15:38 ` 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=adc90638-79a7-4015-accc-0932611cc697@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=odion@efficios.com \
--cc=seanjc@google.com \
--cc=torvalds@linux-foundation.org \
--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