Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 16307
b: refs/heads/master
c: 6bda666
h: refs/heads/master
i:
  16305: ee6f964
  16303: 0d51423
v: v3
  • Loading branch information
Christoph Lameter authored and Linus Torvalds committed Jan 6, 2006
1 parent 3d0f7e5 commit 0a1aee2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 43 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: 21abb1478a87e26f5fa71dbcb7cf4264272c2248
refs/heads/master: 6bda666a03f063968833760c5bb5c13062ab9291
66 changes: 24 additions & 42 deletions trunk/mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,43 +368,6 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
flush_tlb_range(vma, start, end);
}

static struct page *find_or_alloc_huge_page(struct vm_area_struct *vma,
unsigned long addr, struct address_space *mapping,
unsigned long idx, int shared)
{
struct page *page;
int err;

retry:
page = find_lock_page(mapping, idx);
if (page)
goto out;

if (hugetlb_get_quota(mapping))
goto out;
page = alloc_huge_page(vma, addr);
if (!page) {
hugetlb_put_quota(mapping);
goto out;
}

if (shared) {
err = add_to_page_cache(page, mapping, idx, GFP_KERNEL);
if (err) {
put_page(page);
hugetlb_put_quota(mapping);
if (err == -EEXIST)
goto retry;
page = NULL;
}
} else {
/* Caller expects a locked page */
lock_page(page);
}
out:
return page;
}

static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long address, pte_t *ptep, pte_t pte)
{
Expand Down Expand Up @@ -471,12 +434,31 @@ int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
* Use page lock to guard against racing truncation
* before we get page_table_lock.
*/
page = find_or_alloc_huge_page(vma, address, mapping, idx,
vma->vm_flags & VM_SHARED);
if (!page)
goto out;
retry:
page = find_lock_page(mapping, idx);
if (!page) {
if (hugetlb_get_quota(mapping))
goto out;
page = alloc_huge_page(vma, address);
if (!page) {
hugetlb_put_quota(mapping);
goto out;
}

BUG_ON(!PageLocked(page));
if (vma->vm_flags & VM_SHARED) {
int err;

err = add_to_page_cache(page, mapping, idx, GFP_KERNEL);
if (err) {
put_page(page);
hugetlb_put_quota(mapping);
if (err == -EEXIST)
goto retry;
goto out;
}
} else
lock_page(page);
}

spin_lock(&mm->page_table_lock);
size = i_size_read(mapping->host) >> HPAGE_SHIFT;
Expand Down

0 comments on commit 0a1aee2

Please sign in to comment.