Re: [PATCH v2 5/5] mm: add per-order mTHP swpin_refault counter

From: SeongJae Park
Date: Thu Apr 11 2024 - 13:42:48 EST


Hi Barry,

On Thu, 11 Apr 2024 13:46:36 +1200 Barry Song <21cnbao@xxxxxxxxx> wrote:

> >> + count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPIN_REFAULT);
> >> }
> >>
> > From the latest mm-unstable tree, I get below kunit build failure and
> > 'git bisect' points this patch.
> >
> > $ ./tools/testing/kunit/kunit.py run --build_dir ../kunit.out/
> > [16:07:40] Configuring KUnit Kernel ...
> > [16:07:40] Building KUnit Kernel ...
> > Populating config with:
> > $ make ARCH=um O=../kunit.out/ olddefconfig
> > Building with:
> > $ make ARCH=um O=../kunit.out/ --jobs=36
> > ERROR:root:.../mm/memory.c: In function ‘do_swap_page’:
> > .../mm/memory.c:4169:17: error: implicit declaration of function ‘count_mthp_stat’ [-Werror=implicit-function-declaration]
> > 4169 | count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPIN_REFAULT);
> > | ^~~~~~~~~~~~~~~
> > .../mm/memory.c:4169:53: error: ‘MTHP_STAT_ANON_SWPIN_REFAULT’ undeclared (first use in this function)
> > 4169 | count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPIN_REFAULT);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > .../mm/memory.c:4169:53: note: each undeclared identifier is reported only once for each function it appears in
> > cc1: some warnings being treated as errors
> >
> > My kunit build config doesn't have CONFIG_TRANSPARE_HUGEPAGE. Maybe that's the
> > reason and this patch, or the patch that introduced the function and the enum
> > need to take care of the case?
>
> Hi SeongJae,
> Thanks very much, can you check if the below fix the build? If yes, I will
> include this fix while sending v3.

Thank you for quick and kind reply :) I confirmed this fixes the build failure.

>
> Subject: [PATCH] mm: fix build errors on CONFIG_TRANSPARENT_HUGEPAGE=N
>
> Signed-off-by: Barry Song <v-songbaohua@xxxxxxxx>
Tested-by: SeongJae Park <sj@xxxxxxxxxx>


Thanks,
SJ

> ---
> mm/memory.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index acc023795a4d..1d587d1eb432 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -4142,6 +4142,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
> vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, vmf->address,
> &vmf->ptl);
>
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> /* We hit large folios in swapcache */
> if (start_pte && folio_test_large(folio) && folio_test_swapcache(folio)) {
> int nr = folio_nr_pages(folio);
> @@ -4171,6 +4172,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
> }
>
> check_pte:
> +#endif
> if (unlikely(!vmf->pte || !pte_same(ptep_get(vmf->pte), vmf->orig_pte)))
> goto out_nomap;
>
> --
> 2.34.1
>
>