Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

huge_memory: return -EINVAL in folio split functions when THP is disabled

split_huge_page_to_list_[to_order](), split_huge_page() and
try_folio_split() return 0 on success and error codes on failure.

When THP is disabled, these functions return 0 indicating success even
though an error code should be returned as it is not possible to split a
folio when THP is disabled.

Make all these functions return -EINVAL to indicate failure instead of 0.
As large folios depend on CONFIG_THP, issue warning as this function
should not be called without a large folio.

Link: https://lkml.kernel.org/r/20250905150012.93714-1-kernel@pankajraghav.com
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202509051753.riCeG7LC-lkp@intel.com/
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Acked-by: Kiryl Shutsemau <kas@kernel.org>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Barry Song <baohua@kernel.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Pankaj Raghav and committed by
Andrew Morton
a488ba31 0faa77af

+8 -4
+8 -4
include/linux/huge_mm.h
··· 588 588 split_huge_page_to_list_to_order(struct page *page, struct list_head *list, 589 589 unsigned int new_order) 590 590 { 591 - return 0; 591 + VM_WARN_ON_ONCE_PAGE(1, page); 592 + return -EINVAL; 592 593 } 593 594 static inline int split_huge_page(struct page *page) 594 595 { 595 - return 0; 596 + VM_WARN_ON_ONCE_PAGE(1, page); 597 + return -EINVAL; 596 598 } 597 599 598 600 static inline int split_folio_to_list(struct folio *folio, struct list_head *list) 599 601 { 600 - return 0; 602 + VM_WARN_ON_ONCE_FOLIO(1, folio); 603 + return -EINVAL; 601 604 } 602 605 603 606 static inline int try_folio_split(struct folio *folio, struct page *page, 604 607 struct list_head *list) 605 608 { 606 - return 0; 609 + VM_WARN_ON_ONCE_FOLIO(1, folio); 610 + return -EINVAL; 607 611 } 608 612 609 613 static inline void deferred_split_folio(struct folio *folio, bool partially_mapped) {}