Re: [PATCH v2 3/3] mm: shmem: move shmem_huge_global_enabled() into shmem_allowable_huge_orders()

From: Baolin Wang
Date: Thu Jul 25 2024 - 21:09:49 EST




On 2024/7/25 21:09, David Hildenbrand wrote:
   /*
@@ -1625,27 +1632,39 @@ static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp)
   #ifdef CONFIG_TRANSPARENT_HUGEPAGE
   unsigned long shmem_allowable_huge_orders(struct inode *inode,
                   struct vm_area_struct *vma, pgoff_t index,
-                bool global_huge)
+                bool shmem_huge_force)
   {
       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;
+    unsigned long vm_flags = vma ? vma->vm_flags : 0;
+    struct mm_struct *fault_mm = vma ? vma->vm_mm : NULL;

nit: rather than deriving the fault_mm here, I wonder if its cleaner to just
pass vma to shmem_huge_global_enabled()? shmem_huge_global_enabled() is just
using it as a guard to access vm_flags, which you can just as easily do by
testing the vma for non-NULL. And you can access mm flags with vma->vm_mm->flags
after testing the vma too.

Make sense to me, and will do in next version.

Feel free to add my

Acked-by: David Hildenbrand <david@xxxxxxxxxx>

Thanks David.

Andrew has already queued my v3 patchset into the mm-unstable branch.

Andrew, please help to add David's acked tag for v3 series. Thanks.