Skip to content

Commit 2394aef

Browse files
x-y-zakpm00
authored andcommitted
mm/huge_memory: skip invalid debugfs new_order input for folio split
User can put arbitrary new_order via debugfs for folio split test. Although new_order check is added to split_huge_page_to_list_order() in the prior commit, these two additional checks can avoid unnecessary folio locking and split_folio_to_order() calls. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Zi Yan <[email protected]> Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/linux-mm/[email protected]/ Cc: David Hildenbrand <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Yang Shi <[email protected]> Cc: Yu Zhao <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 1412ecb commit 2394aef

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mm/huge_memory.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3486,6 +3486,9 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start,
34863486
if (!is_transparent_hugepage(folio))
34873487
goto next;
34883488

3489+
if (new_order >= folio_order(folio))
3490+
goto next;
3491+
34893492
total++;
34903493
/*
34913494
* For folios with private, split_huge_page_to_list_to_order()
@@ -3553,6 +3556,9 @@ static int split_huge_pages_in_file(const char *file_path, pgoff_t off_start,
35533556
total++;
35543557
nr_pages = folio_nr_pages(folio);
35553558

3559+
if (new_order >= folio_order(folio))
3560+
goto next;
3561+
35563562
if (!folio_trylock(folio))
35573563
goto next;
35583564

0 commit comments

Comments
 (0)