Skip to content

Commit

Permalink
mm/huge_memory: improve split_huge_page_to_list_to_order() return val…
Browse files Browse the repository at this point in the history
…ue documentation

The documentation is wrong and relying on it almost resulted in BUGs in
new callers: ever since fd4a7ac ("mm: migrate: try again if THP split
is failed due to page refcnt") we return -EAGAIN on unexpected folio
references, not -EBUSY.

Let's fix that and also document which other return values we can
currently see and why they could happen.

[[email protected]: v2]
  Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: David Hildenbrand <[email protected]>
Reviewed-by: Zi Yan <[email protected]>
Reviewed-by: John Hubbard <[email protected]>
Reviewed-by: Baolin Wang <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
davidhildenbrand authored and akpm00 committed May 6, 2024
1 parent 8430557 commit d21f996
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2956,7 +2956,7 @@ bool can_split_folio(struct folio *folio, int *pextra_pins)
*
* 3) The folio must not be pinned. Any unexpected folio references, including
* GUP pins, will result in the folio not getting split; instead, the caller
* will receive an -EBUSY.
* will receive an -EAGAIN.
*
* 4) @new_order > 1, usually. Splitting to order-1 anonymous folios is not
* supported for non-file-backed folios, because folio->_deferred_list, which
Expand All @@ -2975,8 +2975,16 @@ bool can_split_folio(struct folio *folio, int *pextra_pins)
*
* 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 concurrently removed from the page cache.
*
* Returns -EBUSY when trying to split the huge zeropage, if the folio is
* under writeback, if fs-specific folio metadata cannot currently be
* released, or if some unexpected race happened (e.g., anon VMA disappeared,
* truncation).
*
* Returns -EINVAL when trying to split to an order that is incompatible
* with the folio. Splitting to order 0 is compatible with all folios.
*/
int split_huge_page_to_list_to_order(struct page *page, struct list_head *list,
unsigned int new_order)
Expand Down

0 comments on commit d21f996

Please sign in to comment.