Re: [PATCH] mm: shmem: ignore sysfs configs for shmem forced collapse
From: Zi Yan
Date: Fri Sep 11 2026 - 10:47:44 EST
On 11 Sep 2026, at 0:04, Baolin Wang wrote:
> According to Documentation/mm/transhuge.rst, MADV_COLLAPSE is expected to
> ignore any THP or mTHP interface settings.
>
> However, after commit 6beeab870e70 ("mm: shmem: move shmem_huge_global_enabled()
> into shmem_allowable_huge_orders()"), 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.
>
> 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: 6beeab870e70 ("mm: shmem: move shmem_huge_global_enabled() into shmem_allowable_huge_orders()")
> Reported-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/20260908125105.1510704-7-kirill@xxxxxxxxxxxxx/
> Signed-off-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
> ---
> Hi Kiryl,
>
> I did not update the selftests, as I hope this fix will be merged first.
> After this fix has landed, I can send a patch to update the selftests.
> ---
> mm/shmem.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
Makes sense.
Acked-by: Zi Yan <ziy@xxxxxxxxxx>
Best Regards,
Yan, Zi