Re: [PATCH v3 4/6] mm: Introduce a pageflag for partially mapped folios

Yu Zhao
2024-08-16T02:51:07Z

On Thu, Aug 15, 2024 at 5:30 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Thu, 15 Aug 2024 16:25:09 +0100 Usama Arif <usamaarif642@gmail.com> wrote:
>
> >
> >
> > commit c627655548fa09b59849e942da4decc84fa0b0f2
> > Author: Usama Arif <usamaarif642@gmail.com>
> > Date: Thu Aug 15 16:07:20 2024 +0100
> >
> > mm: Introduce a pageflag for partially mapped folios fix
> >
> > Fixes the original commit by not clearing partially mapped bit
> > in hugeTLB folios and fixing deferred split THP stats.
> >
> > ...
> >
>
> Life is getting complicated.
>
> > --- a/mm/hugetlb.c
> > +++ b/mm/hugetlb.c
> > @@ -1758,7 +1758,6 @@ static void __update_and_free_hugetlb_folio(struct hstate *h,
> > free_gigantic_folio(folio, huge_page_order(h));
> > } else {
> > INIT_LIST_HEAD(&folio->_deferred_list);
> > - folio_clear_partially_mapped(folio);
> > folio_put(folio);
> > }
> > }
>
> Yu Zhao's "mm/hugetlb: use __GFP_COMP for gigantic folios" was
> expecting that folio_clear_partially_mapped() to be there.
>
> I resolved this within
> mm-hugetlb-use-__gfp_comp-for-gigantic-folios.patch thusly:
>
> @@ -1748,18 +1704,8 @@ static void __update_and_free_hugetlb_fo
>
> folio_ref_unfreeze(folio, 1);
>
> - /*
> - * Non-gigantic pages demoted from CMA allocated gigantic pages
> - * need to be given back to CMA in free_gigantic_folio.
> - */
> - if (hstate_is_gigantic(h) ||
> - hugetlb_cma_folio(folio, huge_page_order(h))) {
> - destroy_compound_gigantic_folio(folio, huge_page_order(h));
> - free_gigantic_folio(folio, huge_page_order(h));
> - } else {
> - INIT_LIST_HEAD(&folio->_deferred_list);
> - folio_put(folio);
> - }
> + INIT_LIST_HEAD(&folio->_deferred_list);
> + hugetlb_free_folio(folio);
> }
>
> /*
>
> Please check.

Confirmed, thanks.