diff options
author | Mel Gorman <mel@csn.ul.ie> | 2008-07-24 00:27:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-24 13:47:16 -0400 |
commit | a1e78772d72b2616ed20e54896e68e0e7044854e (patch) | |
tree | d752dd96c2a4fcc555779a7aa99f95069c9b95ae /include/linux/hugetlb.h | |
parent | fc1b8a73dd71226902a11928dd5500326e101df9 (diff) |
hugetlb: reserve huge pages for reliable MAP_PRIVATE hugetlbfs mappings until fork()
This patch reserves huge pages at mmap() time for MAP_PRIVATE mappings in
a similar manner to the reservations taken for MAP_SHARED mappings. The
reserve count is accounted both globally and on a per-VMA basis for
private mappings. This guarantees that a process that successfully calls
mmap() will successfully fault all pages in the future unless fork() is
called.
The characteristics of private mappings of hugetlbfs files behaviour after
this patch are;
1. The process calling mmap() is guaranteed to succeed all future faults until
it forks().
2. On fork(), the parent may die due to SIGKILL on writes to the private
mapping if enough pages are not available for the COW. For reasonably
reliable behaviour in the face of a small huge page pool, children of
hugepage-aware processes should not reference the mappings; such as
might occur when fork()ing to exec().
3. On fork(), the child VMAs inherit no reserves. Reads on pages already
faulted by the parent will succeed. Successful writes will depend on enough
huge pages being free in the pool.
4. Quotas of the hugetlbfs mount are checked at reserve time for the mapper
and at fault time otherwise.
Before this patch, all reads or writes in the child potentially needs page
allocations that can later lead to the death of the parent. This applies
to reads and writes of uninstantiated pages as well as COW. After the
patch it is only a write to an instantiated page that causes problems.
Signed-off-by: Mel Gorman <mel@csn.ul.ie>
Acked-by: Adam Litke <agl@us.ibm.com>
Cc: Andy Whitcroft <apw@shadowen.org>
Cc: William Lee Irwin III <wli@holomorphy.com>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/hugetlb.h')
-rw-r--r-- | include/linux/hugetlb.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index a79e80b689d8..185b14c9f021 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h | |||
@@ -17,6 +17,7 @@ static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) | |||
17 | return vma->vm_flags & VM_HUGETLB; | 17 | return vma->vm_flags & VM_HUGETLB; |
18 | } | 18 | } |
19 | 19 | ||
20 | void reset_vma_resv_huge_pages(struct vm_area_struct *vma); | ||
20 | int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); | 21 | int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); |
21 | int hugetlb_overcommit_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); | 22 | int hugetlb_overcommit_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); |
22 | int hugetlb_treat_movable_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); | 23 | int hugetlb_treat_movable_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); |
@@ -30,7 +31,8 @@ int hugetlb_report_node_meminfo(int, char *); | |||
30 | unsigned long hugetlb_total_pages(void); | 31 | unsigned long hugetlb_total_pages(void); |
31 | int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, | 32 | int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, |
32 | unsigned long address, int write_access); | 33 | unsigned long address, int write_access); |
33 | int hugetlb_reserve_pages(struct inode *inode, long from, long to); | 34 | int hugetlb_reserve_pages(struct inode *inode, long from, long to, |
35 | struct vm_area_struct *vma); | ||
34 | void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed); | 36 | void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed); |
35 | 37 | ||
36 | extern unsigned long max_huge_pages; | 38 | extern unsigned long max_huge_pages; |
@@ -58,6 +60,11 @@ static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) | |||
58 | { | 60 | { |
59 | return 0; | 61 | return 0; |
60 | } | 62 | } |
63 | |||
64 | static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma) | ||
65 | { | ||
66 | } | ||
67 | |||
61 | static inline unsigned long hugetlb_total_pages(void) | 68 | static inline unsigned long hugetlb_total_pages(void) |
62 | { | 69 | { |
63 | return 0; | 70 | return 0; |