aboutsummaryrefslogtreecommitdiffstats
path: root/mm/hugetlb.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-06-20 11:25:44 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-06-20 11:25:44 -0400
commitaf52739b922f656eb1f39016fabaabe4baeda2e2 (patch)
tree79a7aa810d0493cd0cf4adebac26d37f12e8b545 /mm/hugetlb.c
parent25ed6a5e97809129a1bc852b6b5c7d03baa112c4 (diff)
parent33688abb2802ff3a230bd2441f765477b94cc89e (diff)
Merge 4.7-rc4 into staging-next
We want the fixes in here, and we can resolve a merge issue in drivers/iio/industrialio-trigger.c Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm/hugetlb.c')
-rw-r--r--mm/hugetlb.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index d26162e81fea..388c2bb9b55c 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -832,8 +832,27 @@ static bool vma_has_reserves(struct vm_area_struct *vma, long chg)
832 * Only the process that called mmap() has reserves for 832 * Only the process that called mmap() has reserves for
833 * private mappings. 833 * private mappings.
834 */ 834 */
835 if (is_vma_resv_set(vma, HPAGE_RESV_OWNER)) 835 if (is_vma_resv_set(vma, HPAGE_RESV_OWNER)) {
836 return true; 836 /*
837 * Like the shared case above, a hole punch or truncate
838 * could have been performed on the private mapping.
839 * Examine the value of chg to determine if reserves
840 * actually exist or were previously consumed.
841 * Very Subtle - The value of chg comes from a previous
842 * call to vma_needs_reserves(). The reserve map for
843 * private mappings has different (opposite) semantics
844 * than that of shared mappings. vma_needs_reserves()
845 * has already taken this difference in semantics into
846 * account. Therefore, the meaning of chg is the same
847 * as in the shared case above. Code could easily be
848 * combined, but keeping it separate draws attention to
849 * subtle differences.
850 */
851 if (chg)
852 return false;
853 else
854 return true;
855 }
837 856
838 return false; 857 return false;
839} 858}
@@ -1816,6 +1835,25 @@ static long __vma_reservation_common(struct hstate *h,
1816 1835
1817 if (vma->vm_flags & VM_MAYSHARE) 1836 if (vma->vm_flags & VM_MAYSHARE)
1818 return ret; 1837 return ret;
1838 else if (is_vma_resv_set(vma, HPAGE_RESV_OWNER) && ret >= 0) {
1839 /*
1840 * In most cases, reserves always exist for private mappings.
1841 * However, a file associated with mapping could have been
1842 * hole punched or truncated after reserves were consumed.
1843 * As subsequent fault on such a range will not use reserves.
1844 * Subtle - The reserve map for private mappings has the
1845 * opposite meaning than that of shared mappings. If NO
1846 * entry is in the reserve map, it means a reservation exists.
1847 * If an entry exists in the reserve map, it means the
1848 * reservation has already been consumed. As a result, the
1849 * return value of this routine is the opposite of the
1850 * value returned from reserve map manipulation routines above.
1851 */
1852 if (ret)
1853 return 0;
1854 else
1855 return 1;
1856 }
1819 else 1857 else
1820 return ret < 0 ? ret : 0; 1858 return ret < 0 ? ret : 0;
1821} 1859}