Re: [RFC PATCH 3/3] mm: unclutter THP migration

From: Zi Yan
Date: Fri Dec 29 2017 - 10:45:59 EST


On 29 Dec 2017, at 6:36, Michal Hocko wrote:

> On Tue 26-12-17 21:19:35, Zi Yan wrote:
>> On 8 Dec 2017, at 11:15, Michal Hocko wrote:
> [...]
>>> @@ -1394,6 +1390,21 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
>>>
>>> switch(rc) {
>>> case -ENOMEM:
>>> + /*
>>> + * THP migration might be unsupported or the
>>> + * allocation could've failed so we should
>>> + * retry on the same page with the THP split
>>> + * to base pages.
>>> + */
>>> + if (PageTransHuge(page)) {
>>> + lock_page(page);
>>> + rc = split_huge_page_to_list(page, from);
>>> + unlock_page(page);
>>> + if (!rc) {
>>> + list_safe_reset_next(page, page2, lru);
>>> + goto retry;
>>> + }
>>> + }
>>
>> The hunk splits the THP and adds all tail pages at the end of the list âfromâ.
>> Why do we need âlist_safe_reset_next(page, page2, lru);â here, when page2 is not changed here?
>
> Because we need to handle the case when the page2 was the last on the
> list.

Got it. Thanks for the explanation.

>
>> And it seems a little bit strange to only re-migrate the head page, then come back to all tail
>> pages after migrating the rest of pages in the list âfromâ. Is it better to split the THP into
>> a list other than âfromâ and insert the list after âpageâ, then retry from the split âpageâ?
>> Thus, we attempt to migrate all sub pages of the THP after it is split.
>
> Why does this matter?

Functionally, it does not matter.

This behavior is just less intuitive and a little different from current one,
which implicitly preserves its original order of the not-migrated pages
in the âfromâ list, although no one relies on this implicit behavior now.

Adding one line comment about this difference would be good for code maintenance. :)

Reviewed-by: Zi Yan <zi.yan@xxxxxxxxxxxxxx>

â
Best Regards,
Yan Zi

Attachment: signature.asc
Description: OpenPGP digital signature