Re: [PATCH v3 1/4] mm,hwpoison,hugetlb,memory_hotplug: hotremove memory section with hwpoisoned hugepage

From: Miaohe Lin
Date: Fri Oct 07 2022 - 22:34:01 EST


On 2022/10/7 8:45, HORIGUCHI NAOYA(堀口 直也) wrote:
> On Wed, Sep 28, 2022 at 05:32:12PM +0800, Miaohe Lin wrote:
>> On 2022/9/28 9:26, Naoya Horiguchi wrote:
>>>>> @@ -1815,6 +1815,13 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags)
> ...
>>>>> @@ -1862,6 +1869,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
>>>>>
>>>>> if (hwpoison_filter(p)) {
>>>>> hugetlb_clear_page_hwpoison(head);
>>>>> + SetHPageMigratable(head);
>>>>
>>>> Would we set HPageMigratable flag for free hugetlb pages here? IIUC, they're not expected to have this flag set.
>>>
>>> Thank you, you're right. This should be done in "if (res == 1)" block.
>>
>> If res == 1, it means hugetlb page refcnt is incremented. But it seems this does not necessarily mean
>> HPageMigratable is cleared by __get_huge_page_for_hwpoison() if the hugetlb page is already isolated.
>> If so, we might set HPageMigratable flag back for already isolated hugetlb pages?
>
> # sorry for my late reply, I was busy with personal matters these days...

That's all right. I was back from my vacation too. Thanks for your work. :)

>
> Yes, that could happen (and also in the case where MF_COUNT_INCREASED is
> set). We need store whether HPageMigratable flag is cleared or not in
> __get_huge_page_for_hwpoison(). I'll add a parameter to
> __get_huge_page_for_hwpoison() to return the flag change to the caller.
> But I also think that there're a few internal states during error handling,
> so it might be good to add some structure like "struct hwpoison_control"
> to save such internal states over related functions (not in this series).

That sounds like a good idea.

Thanks,
Miaohe Lin

>
> Thanks,
> Naoya Horiguchi
>