diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-03-17 16:21:20 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-17 16:21:20 +0100 |
commit | 47239561e39bceefecc3cd67f71fcf86a198a8ff (patch) | |
tree | 9823d0973494ea8acabb744bc3aba42b610fb434 /mm/hugetlb.c | |
parent | ed681a91ab805341675d166a9592551093c0a2d9 (diff) | |
parent | 5bee17f18b595937e6beafeee5197868a3f74a06 (diff) | |
download | op-kernel-dev-47239561e39bceefecc3cd67f71fcf86a198a8ff.zip op-kernel-dev-47239561e39bceefecc3cd67f71fcf86a198a8ff.tar.gz |
Merge branch 'linus' into core/printk
Diffstat (limited to 'mm/hugetlb.c')
-rw-r--r-- | mm/hugetlb.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 618e983..107da3d 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2269,12 +2269,18 @@ void hugetlb_change_protection(struct vm_area_struct *vma, int hugetlb_reserve_pages(struct inode *inode, long from, long to, - struct vm_area_struct *vma) + struct vm_area_struct *vma, + int acctflag) { long ret, chg; struct hstate *h = hstate_inode(inode); - if (vma && vma->vm_flags & VM_NORESERVE) + /* + * Only apply hugepage reservation if asked. At fault time, an + * attempt will be made for VM_NORESERVE to allocate a page + * and filesystem quota without using reserves + */ + if (acctflag & VM_NORESERVE) return 0; /* @@ -2299,13 +2305,31 @@ int hugetlb_reserve_pages(struct inode *inode, if (chg < 0) return chg; + /* There must be enough filesystem quota for the mapping */ if (hugetlb_get_quota(inode->i_mapping, chg)) return -ENOSPC; + + /* + * Check enough hugepages are available for the reservation. + * Hand back the quota if there are not + */ ret = hugetlb_acct_memory(h, chg); if (ret < 0) { hugetlb_put_quota(inode->i_mapping, chg); return ret; } + + /* + * Account for the reservations made. Shared mappings record regions + * that have reservations as they are shared by multiple VMAs. + * When the last VMA disappears, the region map says how much + * the reservation was and the page cache tells how much of + * the reservation was consumed. Private mappings are per-VMA and + * only the consumed reservations are tracked. When the VMA + * disappears, the original reservation is the VMA size and the + * consumed reservations are stored in the map. Hence, nothing + * else has to be done for private mappings here + */ if (!vma || vma->vm_flags & VM_SHARED) region_add(&inode->i_mapping->private_list, from, to); return 0; |