Skip to content

Commit adbd532

Browse files
Panky-codeskawasaki
authored andcommitted
mm: add largest_zero_folio() routine
Add largest_zero_folio() routine so that huge_zero_folio can be used directly when CONFIG_STATIC_HUGE_ZERO_FOLIO is enabled. This will return ZERO_PAGE folio if CONFIG_STATIC_HUGE_ZERO_FOLIO is disabled or if we failed to allocate a huge_zero_folio. Co-developed-by: David Hildenbrand <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Pankaj Raghav <[email protected]>
1 parent 1d8bc89 commit adbd532

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

include/linux/huge_mm.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,4 +716,21 @@ static inline int split_folio_to_order(struct folio *folio, int new_order)
716716
return split_folio_to_list_to_order(folio, NULL, new_order);
717717
}
718718

719+
/*
720+
* largest_zero_folio - Get the largest zero size folio available
721+
*
722+
* This function will return huge_zero_folio if CONFIG_STATIC_HUGE_ZERO_FOLIO
723+
* is enabled. Otherwise, a ZERO_PAGE folio is returned.
724+
*
725+
* Deduce the size of the folio with folio_size instead of assuming the
726+
* folio size.
727+
*/
728+
static inline struct folio *largest_zero_folio(void)
729+
{
730+
struct folio *folio = get_static_huge_zero_folio();
731+
732+
if (folio)
733+
return folio;
734+
return page_folio(ZERO_PAGE(0));
735+
}
719736
#endif /* _LINUX_HUGE_MM_H */

0 commit comments

Comments
 (0)