Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Barry Song <baohua@kernel.org>
Cc: "David Hildenbrand (Arm)" <david@kernel.org>,
	Joanne Koong <joannelkoong@gmail.com>,
	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, 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 2/2] mm/memory: add anonymous mTHP folios to deferred split list
Date: Tue, 4 Aug 2026 10:03:41 -0400	[thread overview]
Message-ID: <anHxPU17Ui4MTcCb@cmpxchg.org> (raw)
In-Reply-To: <CAGsJ_4z7bsDzMtO5PzaSHV4CBYBFS=wmmG3H8xfj-mdUo4VyxA@mail.gmail.com>

On Tue, Aug 04, 2026 at 10:03:14AM +0800, Barry Song wrote:
> On Tue, Aug 4, 2026 at 8:48 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
> >
> [...]
> > >
> > > #define LARGE_FOLIO_ZERO_SCAN_MIN_SIZE SZ_2M
> > >
> > > if (folio_size(folio) >= LARGE_FOLIO_ZERO_SCAN_MIN_SIZE)
> > >      deferred_split_folio(folio, false);
> > >
> > > If, someday, people find that 1 MiB also helps, they can provide
> > > data to support it.
> >
> > I am very confused. Did you not see my proposal above?
> >
> > Why not this?
> 
> Hi Johannes,
> 
> For arm64, if the base page size is 64KB, a PMD would be 512MB,
> and PMD-1 would be 256MB. Usama mentioned 2MB, which is just
> order-5, not PMD-1 on arm64.
> 
> BTW, I assume khugepaged_max_ptes_none is intended for collapse,
> not splitting. I am a bit concerned that reusing it for this
> purpose would be quite disruptive.

It already is:

static bool thp_underused(struct folio *folio)
{
	int num_zero_pages = 0, num_filled_pages = 0;
	int i;

	if (khugepaged_max_ptes_none == HPAGE_PMD_NR - 1)
		return false;

	if (folio_contain_hwpoisoned_page(folio))
		return false;

	for (i = 0; i < folio_nr_pages(folio); i++) {
		if (pages_identical(folio_page(folio, i), ZERO_PAGE(0))) {
			if (++num_zero_pages > khugepaged_max_ptes_none)
				return true;
		} else {
			/*
			 * Another path for early exit once the number
			 * of non-zero filled pages exceeds threshold.
			 */
			if (++num_filled_pages >= HPAGE_PMD_NR - khugepaged_max_ptes_none)
				return false;
		}
	}
	return false;
}

That's ABI and setups are relying on it.

All I'm proposing is to only queue pages that the shrinker would
actually split under currently existing rules. That's a mostly
transparent optimization, not a new policy.

No new sysctls. No new policy hardcoded in kernel code. Default
behavior remains unchanged.


  reply	other threads:[~2026-08-04 14:03 UTC|newest]

Thread overview: 33+ 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-30 23:32                 ` Barry Song
2026-07-31 15:04                 ` Johannes Weiner
2026-08-01  7:33                   ` Barry Song
2026-08-03 14:45                     ` Johannes Weiner
2026-08-03 21:20                       ` Barry Song
2026-08-04  0:48                         ` Johannes Weiner
2026-08-04  2:03                           ` Barry Song
2026-08-04 14:03                             ` Johannes Weiner [this message]
2026-08-04 14:11                               ` David Hildenbrand (Arm)
2026-08-04 18:54                                 ` Johannes Weiner
2026-08-04 14:39                             ` Usama Arif
2026-08-04 22:07                               ` Barry Song
2026-08-04 23:26                                 ` Joanne Koong
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)
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=anHxPU17Ui4MTcCb@cmpxchg.org \
    --to=hannes@cmpxchg.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=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