All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <ljs@kernel.org>
To: xu.xin16@zte.com.cn
Cc: npache@redhat.com, david@kernel.org, lance.yang@linux.dev,
	 linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	usamaarif642@gmail.com, yuzhao@google.com,  aarcange@redhat.com,
	akpm@linux-foundation.org, chengming.zhou@linux.dev,
	 ziy@nvidia.com, baolin.wang@linux.alibaba.com,
	liam@infradead.org,  ryan.roberts@arm.com, dev.jain@arm.com,
	baohua@kernel.org, matthew.brost@intel.com,
	 joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com,
	gourry@gourry.net,  ying.huang@linux.alibaba.com,
	apopple@nvidia.com, wang.yaxin@zte.com.cn
Subject: Re: [PATCH mm-unstable v1 2/3] mm/migrate.c: Prevent folio splitting from interacting with KSM
Date: Tue, 9 Jun 2026 15:14:41 +0100	[thread overview]
Message-ID: <aigfvl-pfW2nWawb@lucifer> (raw)
In-Reply-To: <20260609214947060zpq8Z6jdYop1TceXXcLoQ@zte.com.cn>

On Tue, Jun 09, 2026 at 09:49:47PM +0800, xu.xin16@zte.com.cn wrote:
> > > >AFAIU, KSM and THP do often conflict with each other. THP tries hard to collapse
> > > >a huge page (which may contain many zero pages). If KSM is enabled and part of
> > > >that huge page is mergeable, it can easily be split by KSM, rendering THP's
> > > >efforts futile.
> > > >
> > > >Therefore, in our actual production environment, we typically avoid making the
> > > >same region both KSM mergeable and THP always.
> > >
> > > Right, some setups may choose to avoid using KSM and THP always on the
> > > same region. But that is not something the kernel can assume :)
> > >
> > > David noted in the RFC that QEMU may use both MADV_HUGEPAGE and
> > > MADV_MERGEABLE, while KSM can be enabled later system-wide.
> > >
> > > And I think Nico means something different from KSM spliting THPs in
> > > general.
> > >
> > > KSM has been able to split THP before. the new part from b1f202060afe is
> > > that a KSM-triggered split can also remap zero-filled subpages to the
> > > shared zeropage, outside KSM's own use_zero_pages/pages_to_scan controls.
> > >
> > > Maybe the changelog could spell that out :)
> >
> > Yeah maybe I didnt properly explain that :p
> >
> > After some thought I still think the alternative approach i mentioned
> > in the RFC may be better.
> >
> > ie) prevent the zero-page merging that results from KSM splitting a
> > folio. The check we add here is more general and will skip this
> > zero-page merging with all MERGEABLE mappings, not just those causing
> > the issue (the KSM splitting). The result is that even migrations, etc
> > that are also MERGEABLE will be skipped needlessly.
> >
> > If we use this approach we also don't need the first patch of the series.
>
> Yeah, That's also what I want to suggest.

I guess I'll hold off on review until the new version is posted then.

This feels like something we should have worked out in the RFC though?

Thanks, Lorenzo

  reply	other threads:[~2026-06-09 14:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09 11:46 [PATCH mm-unstable v1 0/3] MM: Tighten control over zero-page remapping Nico Pache
2026-06-09 11:46 ` [PATCH mm-unstable v1 1/3] mm/ksm: export ksm_is_running() to check KSM merge state Nico Pache
2026-06-09 14:13   ` Lorenzo Stoakes
2026-06-09 11:46 ` [PATCH mm-unstable v1 2/3] mm/migrate.c: Prevent folio splitting from interacting with KSM Nico Pache
2026-06-09 12:12   ` xu.xin16
2026-06-09 12:57     ` Nico Pache
2026-06-09 12:59       ` David Hildenbrand (Arm)
2026-06-09 13:47       ` xu.xin16
2026-06-09 14:07         ` Zi Yan
2026-06-09 17:27           ` Usama Arif
2026-06-09 13:06     ` Lance Yang
2026-06-09 13:42       ` Nico Pache
2026-06-09 13:49         ` xu.xin16
2026-06-09 14:14           ` Lorenzo Stoakes [this message]
2026-06-09 14:26   ` Lorenzo Stoakes
2026-06-09 11:46 ` [PATCH mm-unstable v1 3/3] mm/huge_memory.c: Skip zero-page remapping when underused THP shrinker is disabled Nico Pache

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=aigfvl-pfW2nWawb@lucifer \
    --to=ljs@kernel.org \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=byungchul@sk.com \
    --cc=chengming.zhou@linux.dev \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=gourry@gourry.net \
    --cc=joshua.hahnjy@gmail.com \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew.brost@intel.com \
    --cc=npache@redhat.com \
    --cc=rakie.kim@sk.com \
    --cc=ryan.roberts@arm.com \
    --cc=usamaarif642@gmail.com \
    --cc=wang.yaxin@zte.com.cn \
    --cc=xu.xin16@zte.com.cn \
    --cc=ying.huang@linux.alibaba.com \
    --cc=yuzhao@google.com \
    --cc=ziy@nvidia.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.