Re: [PATCH v1] hugetlb: pass head page to remove_hugetlb_page()

From: Mike Kravetz
Date: Thu May 27 2021 - 17:12:41 EST


On 5/27/21 12:54 PM, Michal Hocko wrote:
> On Thu 27-05-21 09:28:51, Mike Kravetz wrote:
>> On 5/26/21 4:52 PM, Naoya Horiguchi wrote:
>>> From: Naoya Horiguchi <naoya.horiguchi@xxxxxxx>
>>>
>>> remove_hugetlb_page() dereferences page->lru, so it's assumed that the
>>> page points to a head page, but one of the caller,
>>> dissolve_free_huge_page(), provides remove_hugetlb_page() with 'page'
>>> which could be a tail page. So pass 'head' to it, instead.
>>>
>>
>> I believe we have the same problem later in the routine when calling
>> add_hugetlb_page()?
>
> Can we ever get a tail page there?
>

Yes. Actually alloc_huge_page_vmemmap() and add_hugetlb_page() calls
later in the same block of code expect head page but we pass 'page' which
could be a tail page.

>> If so, should we combine the changes? Or, do we need two patches as
>> the bugs were introduced with different commits?
>
> If there is an issue then I would go with a separate patch.
>

The calls to alloc_huge_page_vmemmap() and add_hugetlb_page() are only
in Andrew's tree (and next). So, they can be fixed there.

I'll send a patch shortly.
--
Mike Kravetz