]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - mm/hugetlb.c
mm: fix negative commitlimit when gigantic hugepages are allocated
[karo-tx-linux.git] / mm / hugetlb.c
index 0cf9863801f698f0fd8e86481e2d52fdb9331b0f..5e1e5083c3b5f0b1f4b43595e3078f361d4ddbdf 100644 (file)
@@ -1074,6 +1074,14 @@ static void __init gather_bootmem_prealloc(void)
                WARN_ON(page_count(page) != 1);
                prep_compound_huge_page(page, h->order);
                prep_new_huge_page(h, page, page_to_nid(page));
+               /*
+                * If we had gigantic hugepages allocated at boot time, we need
+                * to restore the 'stolen' pages to totalram_pages in order to
+                * fix confusing memory reports from free(1) and another
+                * side-effects, like CommitLimit going negative.
+                */
+               if (h->order > (MAX_ORDER - 1))
+                       totalram_pages += 1 << h->order;
        }
 }