• Barry Song's avatar
    mm/cma.c: use exact_nid true to fix possible per-numa cma leak · 84524e70
    Barry Song authored
    commit 40366bd7 upstream.
    
    Calling cma_declare_contiguous_nid() with false exact_nid for per-numa
    reservation can easily cause cma leak and various confusion.  For example,
    mm/hugetlb.c is trying to reserve per-numa cma for gigantic pages.  But it
    can easily leak cma and make users confused when system has memoryless
    nodes.
    
    In case the system has 4 numa nodes, and only numa node0 has memory.  if
    we set hugetlb_cma=4G in bootargs, mm/hugetlb.c will get 4 cma areas for 4
    different numa nodes.  since exact_nid=false in current code, all 4 numa
    nodes will get cma successfully from node0, but hugetlb_cma[1 to 3] will
    never be available to hugepage will only allocate memory from
    hugetlb_cma[0].
    
    In case the system has 4 numa nodes, both numa node0&2 has memory, other
    nodes have no memory.  if we set hugetlb_cma=4G in bootargs, mm/hugetlb.c
    will get 4 cma areas for 4 different numa nodes.  since exact_nid=false in
    cur...
    84524e70
cma.c 14.4 KB