Re: [PATCH v2 3/7] mm/khugepaged: introduce a count_collapse_event() helper

Nico Pache <[email protected]>
Newsgroups org.kernel.vger.linux-kernel,org.kernel.vger.linux-doc,org.kvack.linux-mm
Message-ID <CAA1CXcCofU8t_um5K0GWZY8_qOM7VC1tmw5B=Q56fGTAZHZ58A@mail.gmail.com>
On Wed, Jul 29, 2026 at 3:43 AM David Hildenbrand (Arm)
<[email protected]> wrote:
>
> 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 <[email protected]>
> > Acked-by: Usama Arif <[email protected]>
> > Signed-off-by: Nico Pache <[email protected]>
> > ---
> >  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.

Ok sounds good I'll get those fixed and send a new version soon.

>
> --
> Cheers,
>
> David
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.