Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 22487
b: refs/heads/master
c: 3935baa
h: refs/heads/master
i:
  22485: ff70801
  22483: 51e1d24
  22479: 52afa3e
v: v3
  • Loading branch information
David Gibson authored and Linus Torvalds committed Mar 22, 2006
1 parent c832bf0 commit 499fe09
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 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: 79ac6ba40eb8d70f0d204e98ae9b63280ad1018c
refs/heads/master: 3935baa9bcda3ccaee4f7849f5157d316e34412e
25 changes: 18 additions & 7 deletions trunk/mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/pagemap.h>
#include <linux/mempolicy.h>
#include <linux/cpuset.h>
#include <linux/mutex.h>

#include <asm/page.h>
#include <asm/pgtable.h>
Expand All @@ -26,6 +27,10 @@ unsigned long max_huge_pages;
static struct list_head hugepage_freelists[MAX_NUMNODES];
static unsigned int nr_huge_pages_node[MAX_NUMNODES];
static unsigned int free_huge_pages_node[MAX_NUMNODES];
/*
* Protects updates to hugepage_freelists, nr_huge_pages, and free_huge_pages
*/
static DEFINE_SPINLOCK(hugetlb_lock);

static void clear_huge_page(struct page *page, unsigned long addr)
{
Expand All @@ -50,11 +55,6 @@ static void copy_huge_page(struct page *dst, struct page *src,
}
}

/*
* Protects updates to hugepage_freelists, nr_huge_pages, and free_huge_pages
*/
static DEFINE_SPINLOCK(hugetlb_lock);

static void enqueue_huge_page(struct page *page)
{
int nid = page_to_nid(page);
Expand Down Expand Up @@ -508,14 +508,24 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
pte_t *ptep;
pte_t entry;
int ret;
static DEFINE_MUTEX(hugetlb_instantiation_mutex);

ptep = huge_pte_alloc(mm, address);
if (!ptep)
return VM_FAULT_OOM;

/*
* Serialize hugepage allocation and instantiation, so that we don't
* get spurious allocation failures if two CPUs race to instantiate
* the same page in the page cache.
*/
mutex_lock(&hugetlb_instantiation_mutex);
entry = *ptep;
if (pte_none(entry))
return hugetlb_no_page(mm, vma, address, ptep, write_access);
if (pte_none(entry)) {
ret = hugetlb_no_page(mm, vma, address, ptep, write_access);
mutex_unlock(&hugetlb_instantiation_mutex);
return ret;
}

ret = VM_FAULT_MINOR;

Expand All @@ -525,6 +535,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
if (write_access && !pte_write(entry))
ret = hugetlb_cow(mm, vma, address, ptep, entry);
spin_unlock(&mm->page_table_lock);
mutex_unlock(&hugetlb_instantiation_mutex);

return ret;
}
Expand Down

0 comments on commit 499fe09

Please sign in to comment.