From: Usama Arif Date: Mon, 9 Mar 2026 21:25:02 +0000 (-0700) Subject: mm/migrate_device: document folio_get requirement before frozen PMD split X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a14198ec63c130b7377911d3cf99c93547d5fb8;p=thirdparty%2Flinux.git mm/migrate_device: document folio_get requirement before frozen PMD split 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 Suggested-by: Zi Yan Reviewed-by: Zi Yan Reviewed-by: Nico Pache Acked-by: David Hildenbrand (Arm) Reviewed-by: Wei Yang Cc: Alistair Popple Cc: Byungchul Park Cc: Gregory Price Cc: "Huang, Ying" Cc: Johannes Weiner Cc: Joshua Hahn Cc: Matthew Brost Cc: Rakie Kim Cc: Ying Huang Signed-off-by: Andrew Morton --- diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 8079676c8f1f3..2912eba575d5e 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -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);