Re: [PATCH v2] mm: shmem: ignore sysfs configs for shmem forced collapse

From: Andrew Morton

Date: Sun Sep 13 2026 - 22:44:03 EST


On Mon, 14 Sep 2026 10:12:41 +0800 Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> wrote:

> According to Documentation/mm/transhuge.rst, MADV_COLLAPSE is expected to
> ignore any THP or mTHP interface settings.
>
> However, after commit 26c7d8413aaf ("mm: thp: support "THPeligible" semantics
> for mTHP with anonymous shmem"), performing MADV_COLLAPSE on shmem will
> depend on /sys/.../hugepages-2048kB/shmem_enabled being set to "inherit"
> (although that is the default), which can cause MADV_COLLAPSE to fail
> unexpectedly.

Userspace-visible runtime regression?

> Fix this by returning the result of shmem_huge_global_enabled() directly
> when MADV_COLLAPSE is requested, allowing PMD-order collapse while ignoring
> shmem THP/mTHP settings.
>
> Fixes: 26c7d8413aaf ("mm: thp: support "THPeligible" semantics for mTHP with anonymous shmem")

Should we backport?