linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: 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 16:18:01 +0100	[thread overview]
Message-ID: <7c5cc18e-71e0-4ebb-bb0d-5765a9467753@redhat.com> (raw)
In-Reply-To: <78ebaad9-c7ba-423a-a824-c2b1a499aea6@efficios.com>

On 28.02.25 16:01, Mathieu Desnoyers wrote:
> On 2025-02-28 08:59, David Hildenbrand wrote:
>> On 28.02.25 06:17, Linus Torvalds wrote:
>>> On Thu, 27 Feb 2025 at 19:03, Mathieu Desnoyers
>>> <mathieu.desnoyers@efficios.com> wrote:
>>>>
>>>> I'd be fine with SKSM replacing KSM entirely. However, I don't
>>>> think we should try to re-implement the existing KSM userspace ABIs
>>>> over SKSM.
>>>
>>> No, absolutely. The only point (for me) for your new synchronous one
>>> would be if it replaced the kernel thread async scanning, which would
>>> make the old user space interface basically pointless.
>>>
>>> But I don't actually know who uses KSM right now. My reaction really
>>> comes from a "it's not nice code in the kernel", not from any actual
>>> knowledge of the users.
>>>
>>> Maybe it works really well in some cloud VM environment, and we're
>>> stuck with it forever.
>>
>> Exactly that; and besides the VM use-case, lately people stated using it
>> in the context of interpreters (IIRC inside Meta) quite successfully as
>> well.
>>
> 
> I suspect that SKSM is a better fit for JIT and code patching than KSM,
> because user-space knows better when a set of pages is going to become
> invariant for a long time and thus benefit from merging. This removes
> the background scanning from the picture.
 > > Does the interpreter use-case require background scanning, or does
> it know when a set of pages are meant to become invariant for a long
> time ?

To make the JIT/interpreter use case happy, people wanted ways to 
*force* KSM on for *the whole process*, not just individual VMAs like 
the traditional VM use case would have done.

I recall one of the reasons being that you don't really want to modify 
your JIT/interpreter to just make KSM work.

See [1] "KSM at Meta" for some details, and in general, optimization 
work to adapt KSM to new use cases.

Regarding some concerns you raised, Stefan did a lot of optimization 
work like "smart scanning" (slide "Optimization - Smart Scan (6.7)") to 
reduce the scanning overhead and make it much more efficient.

So people started optimizing for that already and got pretty good results.

[1] 
https://lpc.events/event/17/contributions/1625/attachments/1320/2649/KSM.pdf

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2025-02-28 15:18 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
2025-02-28 21:49                 ` Mathieu Desnoyers
2025-02-28 15:01         ` Mathieu Desnoyers
2025-02-28 15:18           ` David Hildenbrand [this message]
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=7c5cc18e-71e0-4ebb-bb0d-5765a9467753@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=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