On 4/15/21 1:40 AM, Muchun Song wrote: > Every HugeTLB has more than one struct page structure. We __know__ that > we only use the first 4 (__NR_USED_SUBPAGE) struct page structures > to store metadata associated with each HugeTLB. > > There are a lot of struct page structures associated with each HugeTLB > page. For tail pages, the value of compound_head is the same. So we can > reuse first page of tail page structures. We map the virtual addresses > of the remaining pages of tail page structures to the first tail page > struct, and then free these page frames. Therefore, we need to reserve > two pages as vmemmap areas. > > When we allocate a HugeTLB page from the buddy, we can free some vmemmap > pages associated with each HugeTLB page. It is more appropriate to do it > in the prep_new_huge_page(). > > The free_vmemmap_pages_per_hpage(), which indicates how many vmemmap > pages associated with a HugeTLB page can be freed, returns zero for > now, which means the feature is disabled. We will enable it once all > the infrastructure is there. > > Signed-off-by: Muchun Song <songmuc...@bytedance.com> > Reviewed-by: Oscar Salvador <osalva...@suse.de> > Tested-by: Chen Huang <chenhua...@huawei.com> > Tested-by: Bodeddula Balasubramaniam <boded...@amazon.com> > Acked-by: Michal Hocko <mho...@suse.com>
There may need to be some trivial rebasing due to Oscar's changes when they go in. Reviewed-by: Mike Kravetz <mike.krav...@oracle.com> -- Mike Kravetz