]> Git Repo - linux.git/commitdiff
mm: shmem: avoid allocating huge pages larger than MAX_PAGECACHE_ORDER for shmem
authorBaolin Wang <[email protected]>
Wed, 31 Jul 2024 05:46:19 +0000 (13:46 +0800)
committerAndrew Morton <[email protected]>
Thu, 8 Aug 2024 01:33:56 +0000 (18:33 -0700)
Similar to commit d659b715e94ac ("mm/huge_memory: avoid PMD-size page
cache if needed"), ARM64 can support 512MB PMD-sized THP when the base
page size is 64KB, which is larger than the maximum supported page cache
size MAX_PAGECACHE_ORDER.

This is not expected.  To fix this issue, use THP_ORDERS_ALL_FILE_DEFAULT
for shmem to filter allowable huge orders.

[[email protected]: remove comment, per Barry]
Link: https://lkml.kernel.org/r/[email protected]
[[email protected]: remove local `orders']
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/117121665254442c3c7f585248296495e5e2b45c.1722404078.git.baolin.wang@linux.alibaba.com
Fixes: e7a2ab7b3bb5 ("mm: shmem: add mTHP support for anonymous shmem")
Signed-off-by: Baolin Wang <[email protected]>
Signed-off-by: Kefeng Wang <[email protected]>
Reviewed-by: Barry Song <[email protected]>
Cc: Barry Song <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Gavin Shan <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Lance Yang <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Ryan Roberts <[email protected]>
Cc: Zi Yan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
mm/shmem.c

index 2faa9daaf54baaf853460fcd424d6bfe5fb1a056..b5be73b043290e861e66362b1d73ba29ec0c13af 100644 (file)
@@ -1629,11 +1629,6 @@ unsigned long shmem_allowable_huge_orders(struct inode *inode,
        unsigned long mask = READ_ONCE(huge_shmem_orders_always);
        unsigned long within_size_orders = READ_ONCE(huge_shmem_orders_within_size);
        unsigned long vm_flags = vma->vm_flags;
-       /*
-        * Check all the (large) orders below HPAGE_PMD_ORDER + 1 that
-        * are enabled for this vma.
-        */
-       unsigned long orders = BIT(PMD_ORDER + 1) - 1;
        loff_t i_size;
        int order;
 
@@ -1678,7 +1673,7 @@ unsigned long shmem_allowable_huge_orders(struct inode *inode,
        if (global_huge)
                mask |= READ_ONCE(huge_shmem_orders_inherit);
 
-       return orders & mask;
+       return THP_ORDERS_ALL_FILE_DEFAULT & mask;
 }
 
 static unsigned long shmem_suitable_orders(struct inode *inode, struct vm_fault *vmf,
This page took 0.078659 seconds and 4 git commands to generate.