Re: [PATCH v1] mm/huge_memory: improve split_huge_page_to_list_to_order() return value documentation

From: John Hubbard
Date: Mon Apr 22 2024 - 15:37:20 EST


On 4/22/24 12:31 PM, David Hildenbrand wrote:
On 19.04.24 02:15, John Hubbard wrote:
On 4/18/24 8:18 AM, David Hildenbrand wrote:
..
    *
    * Returns 0 if the huge page was split successfully.
    *
- * Returns -EBUSY if @page's folio is pinned, or if the anon_vma disappeared
- * from under us.
+ * Returns -EAGAIN if the folio has unexpected reference (e.g., GUP).

...or if the folio was removed from the page cache before this routine
got a chance to lock it, right? (See the "fail:" path.)

Right, that is sneaky. Let me extend to cover that case as well.

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 824eff9211db8..a7406267323ed 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2975,7 +2975,8 @@ bool can_split_folio(struct folio *folio, int *pextra_pins)
  *
  * Returns 0 if the huge page was split successfully.
  *
- * Returns -EAGAIN if the folio has unexpected reference (e.g., GUP).
+ * Returns -EAGAIN if the folio has unexpected reference (e.g., GUP) or if
+ * the folio was concurrently removed from the page cache.

Looks good,

Reviewed-by: John Hubbard <jhubbard@xxxxxxxxxx>

thanks,
--
John Hubbard
NVIDIA