Re: [PATCH] mm: shmem: fix too little space for tmpfs only fallback 4KB

From: Vernon Yang
Date: Tue Sep 09 2025 - 10:18:24 EST




> On Sep 9, 2025, at 07:22, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Mon, 8 Sep 2025 20:31:28 +0800 Vernon Yang <vernon2gm@xxxxxxxxx> wrote:
>
>> From: Vernon Yang <yanglincheng@xxxxxxxxxx>
>>
>> When the system memory is sufficient, allocating memory is always
>> successful, but when tmpfs size is low (e.g. 1MB), it falls back
>> directly from 2MB to 4KB, and other small granularity (8KB ~ 1024KB)
>> will not be tried.
>>
>> Therefore add check whether the remaining space of tmpfs is sufficient
>> for allocation. If there is too little space left, try smaller large
>> folio.
>
> Thanks.
>
> What are the effects of this change? I'm assuming it's an
> *improvement*, rather than a fix for some misbehavior?
>

When we use tmpfs and the tmpfs space is getting smaller and smaller
(e.g. less than 2MB), it can still allocate 8KB~1MB large folio.

Thank you for your feedback.