Skip to content

Commit 6393d21

Browse files
x-y-zgregkh
authored andcommitted
mm/huge_memory: do not change split_huge_page*() target order silently
commit 77008e1 upstream. Page cache folios from a file system that support large block size (LBS) can have minimal folio order greater than 0, thus a high order folio might not be able to be split down to order-0. Commit e220917 ("mm: split a folio in minimum folio order chunks") bumps the target order of split_huge_page*() to the minimum allowed order when splitting a LBS folio. This causes confusion for some split_huge_page*() callers like memory failure handling code, since they expect after-split folios all have order-0 when split succeeds but in reality get min_order_for_split() order folios and give warnings. Fix it by failing a split if the folio cannot be split to the target order. Rename try_folio_split() to try_folio_split_to_order() to reflect the added new_order parameter. Remove its unused list parameter. [The test poisons LBS folios, which cannot be split to order-0 folios, and also tries to poison all memory. The non split LBS folios take more memory than the test anticipated, leading to OOM. The patch fixed the kernel warning and the test needs some change to avoid OOM.] Link: https://lkml.kernel.org/r/[email protected] Fixes: e220917 ("mm: split a folio in minimum folio order chunks") Signed-off-by: Zi Yan <[email protected]> Reported-by: [email protected] Closes: https://lore.kernel.org/all/[email protected]/ Reviewed-by: Luis Chamberlain <[email protected]> Reviewed-by: Pankaj Raghav <[email protected]> Reviewed-by: Wei Yang <[email protected]> Acked-by: David Hildenbrand <[email protected]> Reviewed-by: Lorenzo Stoakes <[email protected]> Reviewed-by: Miaohe Lin <[email protected]> Cc: Baolin Wang <[email protected]> Cc: Barry Song <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Dev Jain <[email protected]> Cc: Jane Chu <[email protected]> Cc: Lance Yang <[email protected]> Cc: Liam Howlett <[email protected]> Cc: Mariano Pache <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Christian Brauner <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 52f2d5c commit 6393d21

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

include/linux/huge_mm.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -353,20 +353,7 @@ int min_order_for_split(struct folio *folio);
353353
int split_folio_to_list(struct folio *folio, struct list_head *list);
354354
static inline int split_huge_page(struct page *page)
355355
{
356-
struct folio *folio = page_folio(page);
357-
int ret = min_order_for_split(folio);
358-
359-
if (ret < 0)
360-
return ret;
361-
362-
/*
363-
* split_huge_page() locks the page before splitting and
364-
* expects the same page that has been split to be locked when
365-
* returned. split_folio(page_folio(page)) cannot be used here
366-
* because it converts the page to folio and passes the head
367-
* page to be split.
368-
*/
369-
return split_huge_page_to_list_to_order(page, NULL, ret);
356+
return split_huge_page_to_list_to_order(page, NULL, 0);
370357
}
371358
void deferred_split_folio(struct folio *folio, bool partially_mapped);
372359

@@ -538,6 +525,12 @@ static inline int split_huge_page(struct page *page)
538525
return 0;
539526
}
540527

528+
static inline int min_order_for_split(struct folio *folio)
529+
{
530+
VM_WARN_ON_ONCE_FOLIO(1, folio);
531+
return -EINVAL;
532+
}
533+
541534
static inline int split_folio_to_list(struct folio *folio, struct list_head *list)
542535
{
543536
return 0;

mm/huge_memory.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3597,12 +3597,7 @@ int min_order_for_split(struct folio *folio)
35973597

35983598
int split_folio_to_list(struct folio *folio, struct list_head *list)
35993599
{
3600-
int ret = min_order_for_split(folio);
3601-
3602-
if (ret < 0)
3603-
return ret;
3604-
3605-
return split_huge_page_to_list_to_order(&folio->page, list, ret);
3600+
return split_huge_page_to_list_to_order(&folio->page, list, 0);
36063601
}
36073602

36083603
/*

0 commit comments

Comments
 (0)