Re: [PATCH v2 3/7] mm/khugepaged: introduce a count_collapse_event() helper
From: David Hildenbrand (Arm)
Date: Wed Jul 29 2026 - 06:26:12 EST
On 7/15/26 04:59, Nico Pache wrote:
> Provide a simple helper function to help reduce a often used, and
> duplicate pattern across the khugepaged code.
>
> When collapsing to a PMD we need to record a vm_event and the mTHP_stat
> event. When doing mTHP collapse we only update the mTHP stat.
>
> Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
> Acked-by: Usama Arif <usama.arif@xxxxxxxxx>
> Signed-off-by: Nico Pache <npache@xxxxxxxxxx>
> ---
> mm/khugepaged.c | 36 ++++++++++++++++++------------------
> 1 file changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index e92e2b928f17..f65bbe2051b3 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -689,6 +689,14 @@ static inline bool collapse_is_referenced(struct collapse_control *cc, pte_t pte
> mmu_notifier_test_young(vma->vm_mm, addr));
> }
>
> +static void count_collapse_event(unsigned int order, enum vm_event_item vm_event,
> + enum mthp_stat_item mthp_event)
> +{
> + if (is_pmd_order(order))
> + count_vm_event(vm_event);
> + count_mthp_stat(order, mthp_event);
> +}
> +
> static enum scan_result __collapse_huge_page_isolate(struct vm_area_struct *vma,
> unsigned long start_addr, pte_t *pte, struct collapse_control *cc,
> unsigned int order, struct list_head *compound_pagelist)
> @@ -709,9 +717,8 @@ static enum scan_result __collapse_huge_page_isolate(struct vm_area_struct *vma,
> if (pte_none_or_zero(pteval)) {
> if (++none_or_zero > max_ptes_none) {
> result = SCAN_EXCEED_NONE_PTE;
> - if (is_pmd_order(order))
> - count_vm_event(THP_SCAN_EXCEED_NONE_PTE);
> - count_mthp_stat(order, MTHP_STAT_COLLAPSE_EXCEED_NONE);
> + count_collapse_event(order, THP_SCAN_EXCEED_NONE_PTE,
> + MTHP_STAT_COLLAPSE_EXCEED_NONE);
That's not how we indent parameters here. Unless my mail client displays it in a
weird way (doubt).
Same applies to all other cases.
Apart from that LGTM.
--
Cheers,
David