Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: akpm@linux-foundation.org, ljs@kernel.org, usama.arif@linux.dev,
	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, baohua@kernel.org, lance.yang@linux.dev,
	vbabka@kernel.org, rppt@kernel.org, surenb@google.com,
	mhocko@suse.com, willy@infradead.org, linux-mm@kvack.org,
	Johannes Weiner <hannes@cmpxchg.org>
Subject: Re: [PATCH v1 2/2] mm/memory: add anonymous mTHP folios to deferred split list
Date: Wed, 29 Jul 2026 14:38:53 +0200	[thread overview]
Message-ID: <7da62e60-6ce2-411b-acaf-f9f77ef34752@kernel.org> (raw)
In-Reply-To: <CAJnrk1Zc1cZa5edmb6Z18nO3xfLBww-7wobxkOe2OJmWE9qzpA@mail.gmail.com>

On 7/8/26 19:52, Joanne Koong wrote:
> On Wed, Jul 8, 2026 at 12:56 AM David Hildenbrand (Arm)
> <david@kernel.org> wrote:
>>
>> On 7/7/26 22:17, Joanne Koong wrote:
>>> Unlike for PMD-sized folios, an anonymous mTHP folio doesn't get added
>>> to the deferred split list at fault or collapse time. As a result, a
>>> fully mapped mTHP folio that is mostly zero-filled doesn't get split by
>>> the deferred split shrinker when the system is under memory pressure.
>>>
>>> Add anonymous mTHP folios to the deferred split list so that if there's
>>> memory pressure, a zero-filled mTHP can be split with its zero pages
>>> remapped to the shared zero page and then reclaimed.
>>>
>>> To minimize overhead on the common order-0 fault path, the
>>> deferred_split_folio() call is guarded by an inline folio_test_large()
>>> check.
>>>
>>> Suggested-by: Usama Arif <usama.arif@linux.dev>
>>> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
>>> ---
>>>  mm/memory.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/mm/memory.c b/mm/memory.c
>>> index 6637c5b13c9b..441d918e3dc0 100644
>>> --- a/mm/memory.c
>>> +++ b/mm/memory.c
>>> @@ -5259,6 +5259,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);
>>>  }
>>>
>>>  static void map_anon_folio_pte_pf(struct folio *folio, pte_t *pte,
>>
>> I had a session [1] at LSF/MM about having essentially all large anon folios
>> part of the the deferred split queue.
>>
>> (1) I don't think this scales.
>>
>> (2) I suspect the shrinker should make smarter decisions of what to scan/reclaim
>> first.
>>
>> I think this needs more proper thought.
>>
>> [1]
>> https://docs.google.com/presentation/d/1RfKWCY1AMVns-WLn-QdAWbI2a-rA7fbFyh7XD1Wn5BY/edit?usp=sharing
> 
> Thanks for the link to the slides! Was there a conclusion from the
> LSF/MM discussion about the future path forward for deferred splitting
> or is that still being determined?

Sorry for the late reply. Unfortunately, it wasn't clear yet if we could
reporpuse the LRU, whereby we would just naturally benefit from the LRU cache
(soon) and only manage pages on a single list.

The concern was that we might end up scanning many items on the LRU to detect
splitting candidates.

I am not 100% sure if that is a real problem.

As raised during the last THP cabal, my gut feeling is that Johannes might have
an idea on how to improve things here.

-- 
Cheers,

David


  reply	other threads:[~2026-07-29 13:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 20:17 [PATCH v1 0/2] mm: split underused anonymous mTHP folios Joanne Koong
2026-07-07 20:17 ` [PATCH v1 1/2] mm/huge_memory: extend thp_underused() to " Joanne Koong
2026-07-08  4:03   ` Joanne Koong
2026-07-07 20:17 ` [PATCH v1 2/2] mm/memory: add anonymous mTHP folios to deferred split list Joanne Koong
2026-07-08  7:56   ` David Hildenbrand (Arm)
2026-07-08  9:58     ` Usama Arif
2026-07-29 12:36       ` David Hildenbrand (Arm)
2026-07-29 13:43         ` Usama Arif
2026-07-29 14:02           ` Usama Arif
2026-07-08 17:52     ` Joanne Koong
2026-07-29 12:38       ` David Hildenbrand (Arm) [this message]
2026-07-29 15:04         ` Johannes Weiner
2026-07-08  7:46 ` [PATCH v1 0/2] mm: split underused anonymous mTHP folios David Hildenbrand (Arm)
2026-07-08 18:19   ` 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=7da62e60-6ce2-411b-acaf-f9f77ef34752@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox