All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kiryl Shutsemau <kas@kernel.org>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: sashiko-reviews@lists.linux.dev, akpm@linux-foundation.org,
	 david@kernel.org, ljs@kernel.org, baohua@kernel.org,
	usama.arif@linux.dev,  hannes@cmpxchg.org, alex@ghiti.fr,
	ziy@nvidia.com, baolin.wang@linux.alibaba.com,
	 liam@infradead.org, npache@redhat.com, ryan.roberts@arm.com,
	dev.jain@arm.com,  lance.yang@linux.dev, vbabka@kernel.org,
	rppt@kernel.org, surenb@google.com,  mhocko@suse.com,
	willy@infradead.org, linux-mm@kvack.org
Subject: Re: [PATCH v4 4/4] mm: add anonymous mTHP folios to the deferred split list
Date: Thu, 5 Nov 2026 12:37:39 +0000	[thread overview]
Message-ID: <aux4FcaEdTrJ60NR@thinkstation> (raw)
In-Reply-To: <CAJnrk1auD1u1J0yQrXOeJrxvVsQfbxYf+nsMS-9qFQ0hfchG-w@mail.gmail.com>

On Wed, Nov 04, 2026 at 03:50:58PM -0800, Joanne Koong wrote:
> On Wed, Nov 4, 2026 at 1:21 PM <sashiko-bot@kernel.org> wrote:
> >
> > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> > - [High] mm: try_to_migrate_one() triggers deferred_split_folio() on underused mTHP
> > --
> 
> Hi Sashiko,
> 
> I'll try to address these points below.
> 
> >
> > commit 82b7b7063b986d802fe52e75e17211e58f3f420c
> > Author: Joanne Koong <joannelkoong@gmail.com>
> >
> > mm: add anonymous mTHP folios to the deferred split list
> >
> > This commit queues newly mapped anonymous mTHP folios of at least 2M onto the
> > deferred split list in map_anon_folio_pte_nopf() so that underused mTHP folios
> > can be split by the deferred split shrinker under memory pressure.
> >
> > > diff --git a/mm/memory.c b/mm/memory.c
> > > index 0c9ed04528d88..44376321180b5 100644
> > > --- a/mm/memory.c
> > > +++ b/mm/memory.c
> > > @@ -5477,6 +5477,8 @@ void map_anon_folio_pte_nopf(struct folio *folio, pte_t *pte,
> > >       folio_add_lru_vma(folio, vma);
> > >       set_ptes(vma->vm_mm, addr, pte, entry, nr_pages);
> > >       update_mmu_cache_range(NULL, vma, addr, pte, nr_pages);
> > > +     if (folio_test_large(folio))
> > > +             deferred_split_folio(folio, false);
> > >  }
> >
> > [Severity: High]
> > When deferred_split_scan() splits an underused PTE-mapped mTHP folio queued
> > here with PG_partially_mapped left clear, doesn't unmap_folio() trigger a
> > false-positive deferred_split_folio(folio, true) transition during the split?
> 
> Yes, but I don't think this is specific to this series. Splitting any
> PTE-mapped anon large folio that isn't already marked partially mapped
> goes through the try_to_migrate_one() -> folio_remove_rmap_pte() path
> you describe below, where __folio_remove_rmap() requeues it as
> partially mapped mid-split. That already happens today (eg underused
> splits of PMD THPs whose PMD has been split). This series makes it
> more frequent since underused mTHP splits now take that path too, but
> this issue is pre-existing.

I think it is a bit of understatement.

For mTHP it is every underused split: the folio is always PTE-mapped and
try_to_migrate_one() drops one PTE at a time. Each underused split bumps
split_deferred for that size next to the new split_underused, and a split
that fails at folio_ref_freeze() leaves a fully mapped folio flagged
partially mapped on the queue, which the next scan splits without
calling thp_underused().

Can the fix go in before this series? I think it is hard requirement.
Let's not brush if off as pre-existing.

-- 
  Kiryl Shutsemau / Kirill A. Shutemov


  reply	other threads:[~2026-11-05 12:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 21:20 [PATCH v4 0/4] mm: split underused anonymous mTHP folios Joanne Koong
2026-11-03 21:20 ` [PATCH v4 1/4] mm/huge_memory: scale thp_underused() to the folio size Joanne Koong
2026-11-05 12:20   ` Kiryl Shutsemau
2026-11-10  3:54   ` Zi Yan
2026-11-12 23:50     ` Joanne Koong
2026-11-10  8:00   ` Baolin Wang
2026-11-03 21:20 ` [PATCH v4 2/4] mm/huge_memory: don't queue folios when underused splitting is inactive Joanne Koong
2026-11-03 22:15   ` Usama Arif
2026-11-05 12:23   ` Kiryl Shutsemau
2026-11-10  8:13   ` Baolin Wang
2026-11-03 21:20 ` [PATCH v4 3/4] mm/huge_memory: add a per-order counter for underused splits Joanne Koong
2026-11-03 22:20   ` Usama Arif
2026-11-05 12:26     ` Kiryl Shutsemau
2026-11-06  0:06       ` Joanne Koong
2026-11-10  8:10   ` Baolin Wang
2026-11-03 21:20 ` [PATCH v4 4/4] mm: add anonymous mTHP folios to the deferred split list Joanne Koong
2026-11-03 22:20   ` Barry Song
2026-11-04 21:21   ` sashiko-bot
2026-11-04 23:50     ` Joanne Koong
2026-11-05 12:37       ` Kiryl Shutsemau [this message]
2026-11-06  0:05         ` Joanne Koong
2026-11-09 22:29           ` Joanne Koong

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=aux4FcaEdTrJ60NR@thinkstation \
    --to=kas@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=hannes@cmpxchg.org \
    --cc=joannelkoong@gmail.com \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=npache@redhat.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=surenb@google.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=willy@infradead.org \
    --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.