Re: [PATCH v5 4/8] hugetlb: create remove_hugetlb_page() to separate functionality

From: Mike Kravetz
Date: Mon Apr 12 2021 - 14:05:17 EST


On 4/12/21 12:33 AM, Oscar Salvador wrote:
> On Fri, Apr 09, 2021 at 01:52:50PM -0700, Mike Kravetz wrote:
>> The new remove_hugetlb_page() routine is designed to remove a hugetlb
>> page from hugetlbfs processing. It will remove the page from the active
>> or free list, update global counters and set the compound page
>> destructor to NULL so that PageHuge() will return false for the 'page'.
>> After this call, the 'page' can be treated as a normal compound page or
>> a collection of base size pages.
>>
>> update_and_free_page no longer decrements h->nr_huge_pages{_node} as
>> this is performed in remove_hugetlb_page. The only functionality
>> performed by update_and_free_page is to free the base pages to the lower
>> level allocators.
>>
>> update_and_free_page is typically called after remove_hugetlb_page.
>>
>> remove_hugetlb_page is to be called with the hugetlb_lock held.
>>
>> Creating this routine and separating functionality is in preparation for
>> restructuring code to reduce lock hold times. This commit should not
>> introduce any changes to functionality.
>>
>> Signed-off-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
>> Acked-by: Michal Hocko <mhocko@xxxxxxxx>
>> Reviewed-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
>> Reviewed-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
>
> Reviewed-by: Oscar Salvador <osalvador@xxxxxxx>
>
> A "nit" below:
>
>> static void update_and_free_page(struct hstate *h, struct page *page)
>> {
>> int i;
>> @@ -1334,8 +1369,6 @@ static void update_and_free_page(struct hstate *h, struct page *page)
>
> After this, update_and_free_page()'s job is to reset subpage's flags and free
> the page.
> Maybe we want to rename that function at some point, or maybe not as "update" might
> already imply that. Just speaking out loud.

Thanks Oscar,

I did not think about a name change as the routine is still "updating"
subpages before freeing. We can certainly keep this in mind in the future,
especially if there are more functionality changes.
--
Mike Kravetz