• Pasha Tatashin's avatar
    mm: hugetlb_vmemmap: provide stronger vmemmap allocation guarantees · eb83f652
    Pasha Tatashin authored
    HugeTLB pages have a struct page optimizations where struct pages for tail
    pages are freed.  However, when HugeTLB pages are destroyed, the memory
    for struct pages (vmemmap) need to be allocated again.
    
    Currently, __GFP_NORETRY flag is used to allocate the memory for vmemmap,
    but given that this flag makes very little effort to actually reclaim
    memory the returning of huge pages back to the system can be problem. 
    Lets use __GFP_RETRY_MAYFAIL instead.  This flag is also performs graceful
    reclaim without causing ooms, but at least it may perform a few retries,
    and will fail only when there is genuinely little amount of unused memory
    in the system.
    
    Freeing a 1G page requires 16M of free memory.  A machine might need to be
    reconfigured from one task to another, and release a large number of 1G
    pages back to the system if allocating 16M fails, the release won't work.
    
    Link: https://lkml.kernel.org/r/20230508234059.2529638-1-pasha.tatashin@so...
    eb83f652
hugetlb_vmemmap.c 16.7 KB