All of 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
Subject: Re: [PATCH v1 0/2] mm: split underused anonymous mTHP folios
Date: Thu, 30 Jul 2026 15:52:55 +0200	[thread overview]
Message-ID: <411318eb-3156-4e5d-9e11-4c319bb9e755@kernel.org> (raw)
In-Reply-To: <CAJnrk1Y-4-_0udtGKeva=f5=xYRCWcyCnBA_1aVQ8oUZRKGkAg@mail.gmail.com>

On 7/8/26 20:19, Joanne Koong wrote:
> On Wed, Jul 8, 2026 at 12:47 AM David Hildenbrand (Arm)
> <david@kernel.org> wrote:
>>
>> On 7/7/26 22:17, Joanne Koong wrote:
>>> PMD-sized THPs that are mostly zero-filled are reclaimed under memory pressure
>>> by the deferred split shrinker, but this is not done for mTHP folios. At Meta,
>>> we would like to deploy 2M THP=always on ARM (with 64k base pages), as 2M
>>> provides contpte benefits and 512M is too big. However, 2M THP=always will
>>> result in a memory regression unless the extra unused portions of THPs can be
>>> broken down and reclaimed.
>>>
>>> This series has two patches:
>>> Patch 1 - makes thp_underused() work for non-PMD-sized folios by scaling
>>> khugepaged_max_ptes_none proportionally to the folio size and using that
>>> as the threshold for how many zero-filled pages a folio can contain before
>>> it's considered underused.
>> Did you look at the khugepaged side, and how we handle it there?
> 
> I'm not sure if I'm interpreting your suggestion correctly - is your
> suggestion about using the khugepaged mTHP collapse threshold in
> collapse_max_ptes_none()? I had looked at Nico's patchset in [1] and
> my understanding of it was that the mTHP collapse threshold currently
> only supports values of 0 and HPAGE_PMD_NR - 1. The patch 1 changes
> use khugepaged_max_ptes_none's value as a proportional per-order
> threshold for mTHP because 0 and HPAGE_PMD_NR - 1 are too extreme for
> our use case where we're trying to find a middle ground that keeps
> mostly-populated 2M folios whole but splits mostly zero-filled ones.
> 
> Is that what you had in mind or were you pointing at something else on
> the khugepaged side?

Yes, essentially that khugepaged does not apply the scaling because we discussed
it back and forth and it either results slowly consuming more memory than
intended (creep), or ends up being completely confusing for users.

So khugepaged will currently only collapse mTHP if it can either not waste any
memory, or is told to waste as much memory as it wants.

Adding scaling here when we explicitly rejected it in the collapse path looked
odd at first.

I assume your point would be that just mTHP over-allocation (not due to
khugepaged) could make scaling here a good choice, correct?

-- 
Cheers,

David


  reply	other threads:[~2026-07-30 13:53 UTC|newest]

Thread overview: 20+ 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-30 13:28           ` David Hildenbrand (Arm)
2026-07-08 17:52     ` Joanne Koong
2026-07-29 12:38       ` David Hildenbrand (Arm)
2026-07-29 15:04         ` Johannes Weiner
2026-07-30 13:46           ` David Hildenbrand (Arm)
2026-07-30 15:37             ` Johannes Weiner
2026-07-30 21:31               ` Barry Song
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
2026-07-30 13:52     ` David Hildenbrand (Arm) [this message]
2026-07-30 23:10       ` 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=411318eb-3156-4e5d-9e11-4c319bb9e755@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=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 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.