Re: [PATCH v5 02/14] mm: shmem: shmem_getattr(): set blksize to highest supported THP order
From: Zi Yan
Date: Tue Jun 02 2026 - 11:14:28 EST
On 29 May 2026, at 10:55, Luiz Capitulino wrote:
> Today, shmem_getattr() sets stat->blksize to PMD size whenever
> shmem_huge_global_enabled() returns non-zero. While this works fine
> for the normal THP-enabled case as explained by Baolin in [1], this
> has two problems:
>
> 1. Theoretically, when shmem is configured for within_size, this
> could set blksize to PMD size even though the allocation may
> be a smaller mTHP order
>
> 2. A future commit will allow shmem THP support to be enabled
> even when the CPU doesn't support PMD-sized pages. We should
> not allow blksize to be set to PMD size in this case
>
> In order to fix #1 and prepare for #2, this commit sets blksize
> to the size of the highest supported order returned by
> shmem_huge_global_enabled().
>
> [1] https://lore.kernel.org/linux-mm/6591a74c-7ef9-4614-9ae9-cb2fbed86ebf@xxxxxxxxxxxxxxxxx/
>
> Suggested-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Luiz Capitulino <luizcap@xxxxxxxxxx>
> ---
> mm/shmem.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
Make sense.
Acked-by: Zi Yan <ziy@xxxxxxxxxx>
Best Regards,
Yan, Zi