hugetlb: Try to grow hugetlb pool for MAP_PRIVATE mappings
authorAdam Litke <[email protected]>
Tue, 16 Oct 2007 08:26:18 +0000 (01:26 -0700)
committerLinus Torvalds <[email protected]>
Tue, 16 Oct 2007 16:43:02 +0000 (09:43 -0700)
commit7893d1d505d59db9d4f35165c8b6d3c6dff40a32
tree6bea3b41e111b1d1774980296a032012a3926e9c
parent6af2acb6619688046039234f716fd003e6ed2b3f
hugetlb: Try to grow hugetlb pool for MAP_PRIVATE mappings

Because we overcommit hugepages for MAP_PRIVATE mappings, it is possible that
the hugetlb pool will be exhausted or completely reserved when a hugepage is
needed to satisfy a page fault.  Before killing the process in this situation,
try to allocate a hugepage directly from the buddy allocator.

The explicitly configured pool size becomes a low watermark.  When dynamically
grown, the allocated huge pages are accounted as a surplus over the watermark.
 As huge pages are freed on a node, surplus pages are released to the buddy
allocator so that the pool will shrink back to the watermark.

Surplus accounting also allows for friendlier explicit pool resizing.  When
shrinking a pool that is fully in-use, increase the surplus so pages will be
returned to the buddy allocator as soon as they are freed.  When growing a
pool that has a surplus, consume the surplus first and then allocate new
pages.

Signed-off-by: Adam Litke <[email protected]>
Signed-off-by: Mel Gorman <[email protected]>
Acked-by: Andy Whitcroft <[email protected]>
Acked-by: Dave McCracken <[email protected]>
Cc: William Irwin <[email protected]>
Cc: David Gibson <[email protected]>
Cc: Ken Chen <[email protected]>
Cc: Badari Pulavarty <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/hugetlb.c