Re: [PATCH v3 4/8] mm/hugetlb: make hugetlb migration callback CMA aware

From: Mike Kravetz
Date: Tue Jun 30 2020 - 12:37:53 EST


On 6/30/20 12:22 AM, Joonsoo Kim wrote:
> 2020ë 6ì 30ì (í) ìí 3:42, Michal Hocko <mhocko@xxxxxxxxxx>ëì ìì:
>>
>> On Tue 30-06-20 15:30:04, Joonsoo Kim wrote:
>>> 2020ë 6ì 29ì (ì) ìí 4:55, Michal Hocko <mhocko@xxxxxxxxxx>ëì ìì:
>> [...]
>>>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>>>> index 57ece74e3aae..c1595b1d36f3 100644
>>>> --- a/mm/hugetlb.c
>>>> +++ b/mm/hugetlb.c
>>>> @@ -1092,10 +1092,14 @@ static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask,
>>>> /* Movability of hugepages depends on migration support. */
>>>> static inline gfp_t htlb_alloc_mask(struct hstate *h)
>>>> {
>>>> + gfp_t gfp;
>>>> +
>>>> if (hugepage_movable_supported(h))
>>>> - return GFP_HIGHUSER_MOVABLE;
>>>> + gfp = GFP_HIGHUSER_MOVABLE;
>>>> else
>>>> - return GFP_HIGHUSER;
>>>> + gfp = GFP_HIGHUSER;
>>>> +
>>>> + return current_gfp_context(gfp);
>>>> }
>>>>
>>>> static struct page *dequeue_huge_page_vma(struct hstate *h,
>>>>
>>>> If we even fix this general issue for other allocations and allow a
>>>> better CMA exclusion then it would be implemented consistently for
>>>> everybody.
>>>
>>> Yes, I have reviewed the memalloc_nocma_{} APIs and found the better way
>>> for CMA exclusion. I will do it after this patch is finished.
>>>
>>>> Does this make more sense to you are we still not on the same page wrt
>>>> to the actual problem?
>>>
>>> Yes, but we have different opinions about it. As said above, I will make
>>> a patch for better CMA exclusion after this patchset. It will make
>>> code consistent.
>>> I'd really appreciate it if you wait until then.
>>
>> As I've said I would _prefer_ simplicity over "correctness" if it is only
>> partial and hard to reason about from the userspace experience but this
>> is not something I would _insist_ on. If Mike as a maintainer of the
>> code is ok with that then I will not stand in the way.
>
> Okay.

I was OK with Joonsoo's original patch which is why I Ack'ed it. However,
my sense of simplicity and style may not be the norm as I have spent too
much time with the hugetlbfs code. :) That is why I did not chime in and
let Michal and Joonsoo discuss. I can see both sides of the issue. For
now, I am OK to go with Joonsoo's patch as long as the issue below is
considered in the the next patchset.
--
Mike Kravetz

>> But please note that a missing current_gfp_context inside
>> htlb_alloc_mask is a subtle bug. I do not think it matters right now but
>> with a growing use of scoped apis this might actually hit some day so I
>> believe we want to have it in place.
>
> Okay. I will keep in mind and consider it when fixing CMA exclusion on the
> other patchset.
>
> Thanks.