Skip to content

Commit e3927e1

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 ca6b349 commit e3927e1

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
@@ -710,4 +710,21 @@ static inline int split_folio_to_order(struct folio *folio, int new_order)
710710
return split_folio_to_list_to_order(folio, NULL, new_order);
711711
}
712712

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

0 commit comments

Comments
 (0)