]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm/migrate_device: document folio_get requirement before frozen PMD split
authorUsama Arif <usama.arif@linux.dev>
Mon, 9 Mar 2026 21:25:02 +0000 (14:25 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:19 +0000 (13:53 -0700)
split_huge_pmd_address() with freeze=true splits a PMD migration entry
into PTE migration entries, consuming one folio reference in the process.
The folio_get() before it provides this reference.

Add a comment explaining this relationship.  The expected folio refcount
at the start of migrate_vma_split_unmapped_folio() is 1.

Link: https://lkml.kernel.org/r/20260309212502.3922825-1-usama.arif@linux.dev
Signed-off-by: Usama Arif <usama.arif@linux.dev>
Suggested-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Nico Pache <npache@redhat.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
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: Johannes Weiner <hannes@cmpxchg.org>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Ying Huang <ying.huang@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/migrate_device.c

index 8079676c8f1f35bcee31c2abe53b016e2998acea..2912eba575d5eaa06470a30ca2b7e61a28d389d3 100644 (file)
@@ -914,6 +914,10 @@ static int migrate_vma_split_unmapped_folio(struct migrate_vma *migrate,
        unsigned long flags;
        int ret = 0;
 
+       /*
+        * take a reference, since split_huge_pmd_address() with freeze = true
+        * drops a reference at the end.
+        */
        folio_get(folio);
        split_huge_pmd_address(migrate->vma, addr, true);
        ret = folio_split_unmapped(folio, 0);