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

From: Matthew Wilcox
Date: Mon Dec 16 2024 - 23:18:32 EST


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