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/20240307181854.138928-2-zi.yan@sent.com Signed-off-by: Zi Yan <ziy@nvidia.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/linux-mm/7dda9283-b437-4cf8-ab0d-83c330deb9c0@moroto.mountain/ Cc: David Hildenbrand <david@redhat.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Yang Shi <shy828301@gmail.com> Cc: Yu Zhao <yuzhao@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 1412ecb commit 2394aef

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

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)