Re: [PATCH v3] mm/hugetlb: split hugetlb_cma in nodes with memory

From: Mike Kravetz
Date: Thu Jul 16 2020 - 14:28:48 EST


On 7/16/20 1:12 AM, Will Deacon wrote:
> On Wed, Jul 15, 2020 at 09:59:24AM -0700, Mike Kravetz wrote:
>>
>> So, everything in the existing code really depends on the hugetlb definition
>> of gigantic page (order >= MAX_ORDER). The code to check for
>> 'order >= MAX_ORDER' in my proposed patch is just following the same
>> convention.
>
> Fair enough, and thanks for the explanation. Maybe just chuck a comment in,
> then? Alternatively, having something like:
>
> static inline bool page_order_is_gigantic(unsigned int order)
> {
> return order >= MAX_ORDER;
> }
>
> static inline bool hstate_is_gigantic(struct hstate *h)
> {
> return page_order_is_gigantic(huge_page_order(h));
> }

Ok, the updated patch below includes both as well as your other suggestions.

It would be great if Roman could comment/test as he provided the initial
code and has a well defined use case. Testing from Barry would also be
appreciated as most of the recent churn has come from his testing.

>> I think the current dependency on the hugetlb definition of gigantic page
>> may be too simplistic if using CMA for huegtlb pages becomes more common.
>> Some architectures (sparc, powerpc) have more than one gigantic pages size.
>> Currently there is no way to specify that CMA should be used for one and
>> not the other. In addition, I could imagine someone wanting to reserve/use
>> CMA for non-gigantic (PMD) sized pages. There is no mechainsm for that today.
>>
>> I honestly have not heard about many use cases for this CMA functionality.
>> When support was initially added, it was driven by a specific use case and
>> the 'all gigantic pages use CMA if defined' implementation was deemed
>> sufficient. If there are more use cases, or this seems too simple we can
>> revisit that decision.
>
> Agreed, I think your patch is an improvement regardless of that.

Anshuman and Barry have pending patches changing the place in arch specific
code where hugetlb_cma_reserve is called. This will not be necessary if the
proposed code proves successful.