On 05/22/2018 06:04 AM, TSUKADA Koutaro wrote: > > I stared at the commit log of mm/hugetlb_cgroup.c, but it did not seem to > have specially considered of surplus hugepages. Later, I will send a mail > to hugetlb cgroup's committer to ask about surplus hugepages charge > specifications. > I went back and looked at surplus huge page allocation. Previously, I made a statement that the hugetlb controller accounts for surplus huge pages. Turns out that may not be 100% correct. Thanks to Michal, all surplus huge page allocation is performed via the alloc_surplus_huge_page() routine. This will ultimately call into the buddy allocator without any cgroup charges. Calls to alloc_surplus_huge_page are made from: - alloc_huge_page() when allocating a huge page to a mapping/file. In this case, appropriate calls to the hugetlb controller are in place. So, any limits are enforced here. - gather_surplus_pages() when allocating and setting aside 'reserved' huge pages. No accounting is performed here. Do note that in this case the allocated huge pages are not assigned to the mapping/file. Even though 'reserved', they are deposited into the global pool and also counted as 'free'. When these reserved pages are ultimately used to populate a file/mapping, the code path goes through alloc_huge_page() where appropriate calls to the hugetlb controller are in place. So, the bottom line is that surplus huge pages are not accounted for when they are allocated as 'reserves'. It is not until these reserves are actually used that accounting limits are checked. This 'seems' to align with general allocation of huge pages within the pool. No accounting is done until they are actually allocated to a mapping/file. -- Mike Kravetz -- To unsubscribe from this list: send the line "unsubscribe cgroups" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html