For variable-order anonymous folios, we want to tune the order that we prefer to allocate based on the vma. Add the routines to manage that heuristic. TODO: Currently we always use the global maximum. Add per-vma logic! Signed-off-by: Ryan Roberts <ryan.roberts@xxxxxxx> --- include/linux/mm.h | 5 +++++ mm/memory.c | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index cdb8c6031d0f..cc8d0b239116 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3674,4 +3674,9 @@ madvise_set_anon_name(struct mm_struct *mm, unsigned long start, } #endif +/* + * TODO: Should this be set per-architecture? + */ +#define ANON_FOLIO_ORDER_MAX 4 + #endif /* _LINUX_MM_H */ diff --git a/mm/memory.c b/mm/memory.c index ca32f59acef2..d7e34a8c46aa 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3022,6 +3022,14 @@ static struct folio *try_vma_alloc_movable_folio(struct vm_area_struct *vma, return vma_alloc_movable_folio(vma, vaddr, 0, zeroed); } +static inline int max_anon_folio_order(struct vm_area_struct *vma) +{ + /* + * TODO: Policy for maximum folio order should likely be per-vma. + */ + return ANON_FOLIO_ORDER_MAX; +} + /* * Handle write page faults for pages that can be reused in the current vma * -- 2.25.1