Re: [RFC PATCH] mm: madvise: don't split a PMD on partial THP MADV_DONTNEED
From: Shakeel Butt
Date: Wed Dec 02 2026 - 13:04:32 EST
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@xxxxxxxxxx/