Re: [RFC PATCH 02/12] khugepaged: Generalize alloc_charge_folio()

Matthew Wilcox
2024-12-17T04:17:55Z

On Mon, Dec 16, 2024 at 10:20:55PM +0530, Dev Jain wrote:
> static int alloc_charge_folio(struct folio **foliop, struct mm_struct *mm,
> - struct collapse_control *cc)
> + int order, struct collapse_control *cc)

unsigned, surely?

> if (!folio) {
> *foliop = NULL;
> count_vm_event(THP_COLLAPSE_ALLOC_FAILED);
> + if (order != HPAGE_PMD_ORDER)
> + count_mthp_stat(order, MTHP_STAT_ANON_COLLAPSE_ALLOC_FAILED);

i don't understand why we need new statistics here. we already have a
signal that memory allocation failures are preventing collapse from
being successful, why do we care if it's mthp or actual thp?

> count_vm_event(THP_COLLAPSE_ALLOC);
> + if (order != HPAGE_PMD_ORDER)
> + count_mthp_stat(order, MTHP_STAT_ANON_COLLAPSE_ALLOC);

similar question