Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 108248
b: refs/heads/master
c: 57303d8
h: refs/heads/master
v: v3
  • Loading branch information
Andy Whitcroft authored and Linus Torvalds committed Aug 12, 2008
1 parent 002f2d6 commit dcaea87
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ff1a4a7b14ae146142b1c93a001304caf662ae13
refs/heads/master: 57303d80175e10056bf51206f9961d586f02f967
44 changes: 35 additions & 9 deletions trunk/mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,15 @@ static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
lock_page(page);
}

/*
* If we are going to COW a private mapping later, we examine the
* pending reservations for this page now. This will ensure that
* any allocations necessary to record that reservation occur outside
* the spinlock.
*/
if (write_access && !(vma->vm_flags & VM_SHARED))
vma_needs_reservation(h, vma, address);

spin_lock(&mm->page_table_lock);
size = i_size_read(mapping->host) >> huge_page_shift(h);
if (idx >= size)
Expand Down Expand Up @@ -1978,6 +1987,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
pte_t *ptep;
pte_t entry;
int ret;
struct page *pagecache_page = NULL;
static DEFINE_MUTEX(hugetlb_instantiation_mutex);
struct hstate *h = hstate_vma(vma);

Expand All @@ -2000,19 +2010,35 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,

ret = 0;

/*
* If we are going to COW the mapping later, we examine the pending
* reservations for this page now. This will ensure that any
* allocations necessary to record that reservation occur outside the
* spinlock. For private mappings, we also lookup the pagecache
* page now as it is used to determine if a reservation has been
* consumed.
*/
if (write_access && !pte_write(entry)) {
vma_needs_reservation(h, vma, address);

if (!(vma->vm_flags & VM_SHARED))
pagecache_page = hugetlbfs_pagecache_page(h,
vma, address);
}

spin_lock(&mm->page_table_lock);
/* Check for a racing update before calling hugetlb_cow */
if (likely(pte_same(entry, huge_ptep_get(ptep))))
if (write_access && !pte_write(entry)) {
struct page *page;
page = hugetlbfs_pagecache_page(h, vma, address);
ret = hugetlb_cow(mm, vma, address, ptep, entry, page);
if (page) {
unlock_page(page);
put_page(page);
}
}
if (write_access && !pte_write(entry))
ret = hugetlb_cow(mm, vma, address, ptep, entry,
pagecache_page);
spin_unlock(&mm->page_table_lock);

if (pagecache_page) {
unlock_page(pagecache_page);
put_page(pagecache_page);
}

mutex_unlock(&hugetlb_instantiation_mutex);

return ret;
Expand Down

0 comments on commit dcaea87

Please sign in to comment.