]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/migrate_device: cleanup up PMD Checks and warnings
authorSunny Patel <nueralspacetech@gmail.com>
Sun, 19 Apr 2026 17:47:43 +0000 (23:17 +0530)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 29 May 2026 04:04:47 +0000 (21:04 -0700)
Remove the odd VM_WARN_ON_FOLIO(!folio, folio) usage and replace it with a
simpler VM_WARN_ON_ONCE(!folio) check.

Drop the redundant VM_WARN_ON_ONCE(!pmd_none(*pmdp) &&
!is_huge_zero_pmd(*pmdp)).

Refactor the PMD checks, making the control flow clearer and avoiding
duplicate condition checks.

Link: https://lore.kernel.org/20260419174747.10701-1-nueralspacetech@gmail.com
Signed-off-by: Sunny Patel <nueralspacetech@gmail.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Huang Ying <ying.huang@linux.alibaba.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/migrate_device.c

index 19cd14b3411469763b5eebc25a8483c940bb443c..554754eb26ff2f0a59b8cbd20f9f6a187005e7c7 100644 (file)
@@ -801,8 +801,7 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate,
        bool flush = false;
        unsigned long i;
 
-       VM_WARN_ON_FOLIO(!folio, folio);
-       VM_WARN_ON_ONCE(!pmd_none(*pmdp) && !is_huge_zero_pmd(*pmdp));
+       VM_WARN_ON_ONCE(!folio);
 
        if (!thp_vma_suitable_order(vma, addr, HPAGE_PMD_ORDER))
                return -EINVAL;
@@ -859,11 +858,9 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate,
        if (userfaultfd_missing(vma))
                goto unlock_abort;
 
-       if (!pmd_none(*pmdp)) {
-               if (!is_huge_zero_pmd(*pmdp))
-                       goto unlock_abort;
+       if (is_huge_zero_pmd(*pmdp))
                flush = true;
-       else if (!pmd_none(*pmdp))
+       else if (!pmd_none(*pmdp))
                goto unlock_abort;
 
        add_mm_counter(vma->vm_mm, MM_ANONPAGES, HPAGE_PMD_NR);