Re: [PATCH v23 6/9] mm: hugetlb: alloc the vmemmap pages associated with each HugeTLB page

From: Oscar Salvador
Date: Mon May 10 2021 - 07:08:27 EST


On Mon, May 10, 2021 at 11:00:24AM +0800, Muchun Song wrote:
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1376,6 +1376,39 @@ static void remove_hugetlb_page(struct hstate *h, struct page *page,
> h->nr_huge_pages_node[nid]--;
> }
>
> +static void add_hugetlb_page(struct hstate *h, struct page *page,
> + bool adjust_surplus)
> +{
> + int zeroed;
> + int nid = page_to_nid(page);
> +
> + VM_BUG_ON_PAGE(!HPageVmemmapOptimized(page), page);
> +
> + lockdep_assert_held(&hugetlb_lock);
> +
> + INIT_LIST_HEAD(&page->lru);
> + h->nr_huge_pages++;
> + h->nr_huge_pages_node[nid]++;
> +
> + if (adjust_surplus) {
> + h->surplus_huge_pages++;
> + h->surplus_huge_pages_node[nid]++;
> + }
> +
> + set_compound_page_dtor(page, HUGETLB_PAGE_DTOR);
> + set_page_private(page, 0);

I think this has already been discused, so sorry about this.

The only reason to need the set_page_private() is because of the dissolving
function right? add_hugetlb_page() can only get reached via free_huge_page(),
or dissolve_free_huge_page, and while the former clears the flags, the latter
it does not.

I think this function would benefit from some renaming. add_hugetlb_page() gives
me no hint of what is this about, although I can figure it out reading the code.

With that: Reviewed-by: Oscar Salvador <osalvador@xxxxxxx>




--
Oscar Salvador
SUSE L3