hugetlb: Try to grow hugetlb pool for MAP_SHARED mappings
hugetlb: Try to grow hugetlb pool for MAP_SHARED mappings

Shared mappings require special handling because the huge pages needed to
fully populate the VMA must be reserved at mmap time.  If not enough pages are
available when making the reservation, allocate all of the shortfall at once
from the buddy allocator and add the pages directly to the hugetlb pool.  If
they cannot be allocated, then fail the mapping.  The page surplus is
accounted for in the same way as for private mappings; faulted surplus pages
will be freed at unmap time.  Reserved, surplus pages that have not been used
must be freed separately when their reservation has been released.

Signed-off-by: Adam Litke <db68fba232b2c49ed3e9d3081df349dde7b61dfd@us.ibm.com>
Acked-by: Andy Whitcroft <b4658fdd7fbd645c2859b0e39d71018f32058d12@shadowen.org>
Acked-by: Dave McCracken <d37a945b95428014e6f5eb1f46b62e1499d9352b@oracle.com>
Cc: William Irwin <2a9f47684a36ba33aae417574f7f6bc5c37d9bbf@oracle.com>
Cc: David Gibson <aa743a0aaec8f7d7a1f01442503957f4d7a2d634@gibson.dropbear.id.au>
Cc: Ken Chen <76daf34ccc35c39bb215f117423bdc362ed1c854@google.com>
Cc: Badari Pulavarty <a0471031ec5071754e15184cabeebf7217ef1fd9@us.ibm.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,KristFoundation/Programs