Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 73696
b: refs/heads/master
c: 348ea20
h: refs/heads/master
v: v3
  • Loading branch information
Adam Litke authored and Linus Torvalds committed Nov 15, 2007
1 parent 816f3df commit 32e94f9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 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: 6c55be8b962f1bdc592d579e81fc27b11ea53dfc
refs/heads/master: 348ea204cc23cda35faf962414b674c57da647d7
46 changes: 27 additions & 19 deletions trunk/mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,35 +353,43 @@ void return_unused_surplus_pages(unsigned long unused_resv_pages)
}
}

static struct page *alloc_huge_page(struct vm_area_struct *vma,
unsigned long addr)

static struct page *alloc_huge_page_shared(struct vm_area_struct *vma,
unsigned long addr)
{
struct page *page = NULL;
int use_reserved_page = vma->vm_flags & VM_MAYSHARE;
struct page *page;

spin_lock(&hugetlb_lock);
if (!use_reserved_page && (free_huge_pages <= resv_huge_pages))
goto fail;

page = dequeue_huge_page(vma, addr);
if (!page)
goto fail;

spin_unlock(&hugetlb_lock);
set_page_refcounted(page);
return page;
}

fail:
spin_unlock(&hugetlb_lock);
static struct page *alloc_huge_page_private(struct vm_area_struct *vma,
unsigned long addr)
{
struct page *page = NULL;

/*
* Private mappings do not use reserved huge pages so the allocation
* may have failed due to an undersized hugetlb pool. Try to grab a
* surplus huge page from the buddy allocator.
*/
if (!use_reserved_page)
spin_lock(&hugetlb_lock);
if (free_huge_pages > resv_huge_pages)
page = dequeue_huge_page(vma, addr);
spin_unlock(&hugetlb_lock);
if (!page)
page = alloc_buddy_huge_page(vma, addr);
return page;
}

static struct page *alloc_huge_page(struct vm_area_struct *vma,
unsigned long addr)
{
struct page *page;

if (vma->vm_flags & VM_MAYSHARE)
page = alloc_huge_page_shared(vma, addr);
else
page = alloc_huge_page_private(vma, addr);
if (page)
set_page_refcounted(page);
return page;
}

Expand Down

0 comments on commit 32e94f9

Please sign in to comment.