Re: [PATCH v2 2/4] hugetlb: add HPageCma flag and code to free non-gigantic pages in CMA

From: David Hildenbrand
Date: Fri Sep 24 2021 - 05:36:55 EST


On 23.09.21 19:53, Mike Kravetz wrote:
When huge page demotion is fully implemented, gigantic pages can be
demoted to a smaller huge page size. For example, on x86 a 1G page
can be demoted to 512 2M pages. However, gigantic pages can potentially
be allocated from CMA. If a gigantic page which was allocated from CMA
is demoted, the corresponding demoted pages needs to be returned to CMA.

In order to track hugetlb pages that need to be returned to CMA, add the
hugetlb specific flag HPageCma. Flag is set when a huge page is
allocated from CMA and transferred to any demoted pages. Non-gigantic
huge page freeing code checks for the flag and takes appropriate action.

Do we really need that flag or couldn't we simply always try cma_release() and fallback to out ordinary freeing-path?

IIRC, cma knows exactly if something was allocated via a CMA are and can be free via it. No need for additional tracking usually.

--
Thanks,

David / dhildenb