From: Pedro Falcato <pfalcato@suse.de>
To: Alexandre Ghiti <alexghiti@meta.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>,
Alexandre Ghiti <alex@ghiti.fr>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>, Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <liam@infradead.org>,
Nico Pache <nico.pache@linux.dev>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>,
Lance Yang <lance.yang@linux.dev>,
Usama Arif <usama.arif@linux.dev>,
Kiryl Shutsemau <kas@kernel.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>,
Lorenzo Stoakes <ljs@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Jann Horn <jannh@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] mm: madvise: don't split a PMD on partial THP MADV_DONTNEED
Date: Thu, 3 Dec 2026 15:08:32 +0000 [thread overview]
Message-ID: <axGEZylbb6Xx2sbT@pedro-suse.tail5790ac.ts.net> (raw)
In-Reply-To: <CAEmasaW1OYAiUaeDHXzK+sxsD_bPFD1wo-+dPLJ4BzNffABkmA@mail.gmail.com>
On Thu, Dec 03, 2026 at 03:53:08PM +0100, Alexandre Ghiti wrote:
> Hi Shakeel,
>
> On Wed, Dec 2, 2026 at 7:04 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
> >
> > >
> > On Wed, Dec 02, 2026 at 11:28:10AM +0100, Alexandre Ghiti wrote:
> > > MADV_DONTNEED on a range that covers only part of a PMD-mapped THP splits
> > > the PMD and zaps the PTEs of the range. The THP itself is not freed: it
> > > stays allocated and charged as a whole, now partially mapped, until the
> > > deferred split shrinker splits it under memory pressure. Until then the
> > > process has lost the PMD mapping, and the TLB reach that comes with it, for
> > > no memory benefit.
> >
> > Isn't the actual problem higher and unexpected memory usage? Application or the
> > malloc implementations do madvise(MADV_DONTNEED) to release memory and expect at
> > least decrease in RSS. Why not fix the cgroup memory usage as well by
> > synchronously break the THP as well. See
> > https://lore.kernel.org/all/20211120201230.920082-1-shakeelb@google.com/
> >
> >
>
> The memcg charge is not the problem I'm facing (though it exists!). My
> issue is that the allocator leaves many partially mapped THPs, even
> when that memory may be reused soon after (which userspace can't
> easily know), and the TLB benefit goes away.
I would say doing a madvise() *at all* is silly; at least every time a range
is free.
>
> If the allocator stops purging hugepages that are only partly free,
> the THPs stay intact (along with the TLB benefit) but RSS grows
> noticeably, which is also unacceptable.
>
> So what I'm looking for is a way for userspace to tell the kernel
> which parts of a THP are free, so that the kernel can reclaim that
> internal fragmentation when the memory is actually needed.
>
> But since David says MADV_DONTNEED means zap, I'll try something else.
MADV_NOHUGEPAGE? But that requires a VMA split, which sucks. I had the
idea (from Kiryl IIRC) on my post-LPC list that splitting off these
hints onto a separate tree (freeing us from VMA splitting) could be a
good idea.
Either way, you still pay the system call, which still sucks.
*Something something *transparent* huge pages*
(I didn't have time lately to work on this :/)
--
Pedro
next prev parent reply other threads:[~2026-12-03 15:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 10:28 Alexandre Ghiti
2026-12-02 11:22 ` Lorenzo Stoakes (ARM)
2026-12-03 14:10 ` Alexandre Ghiti
2026-12-02 11:22 ` David Hildenbrand (Arm)
2026-12-02 14:26 ` Alexandre Ghiti
2026-12-03 12:32 ` David Hildenbrand (Arm)
2026-12-02 16:37 ` Zi Yan
2026-12-02 17:39 ` Alexandre Ghiti
2026-12-02 20:28 ` David Hildenbrand (Arm)
2026-12-02 18:04 ` Shakeel Butt
2026-12-03 14:53 ` Alexandre Ghiti
2026-12-03 15:08 ` Pedro Falcato [this message]
2026-12-03 15:36 ` Alexandre Ghiti
2026-12-03 20:07 ` Shakeel Butt
2026-12-03 20:06 ` Shakeel Butt
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=axGEZylbb6Xx2sbT@pedro-suse.tail5790ac.ts.net \
--to=pfalcato@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=alexghiti@meta.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=jannh@google.com \
--cc=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=nico.pache@linux.dev \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.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
all inboxes | Powered by JetHome®