Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 343307
b: refs/heads/master
c: 78ca0e6
h: refs/heads/master
i:
  343305: cab6458
  343303: 8db2eb2
v: v3
  • Loading branch information
Kirill A. Shutemov authored and Linus Torvalds committed Dec 13, 2012
1 parent d7a86d9 commit f2993d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 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: 80371957f09814d25c38733d2d08de47f59a13c2
refs/heads/master: 78ca0e679203bbf74f8febd9725a1c8dd083d073
20 changes: 10 additions & 10 deletions trunk/mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,24 @@ static int start_khugepaged(void)
return err;
}

static int __init init_huge_zero_page(void)
static int init_huge_zero_pfn(void)
{
struct page *hpage;
unsigned long pfn;

hpage = alloc_pages((GFP_TRANSHUGE | __GFP_ZERO) & ~__GFP_MOVABLE,
HPAGE_PMD_ORDER);
if (!hpage)
return -ENOMEM;

huge_zero_pfn = page_to_pfn(hpage);
pfn = page_to_pfn(hpage);
if (cmpxchg(&huge_zero_pfn, 0, pfn))
__free_page(hpage);
return 0;
}

static inline bool is_huge_zero_pfn(unsigned long pfn)
{
return pfn == huge_zero_pfn;
return huge_zero_pfn && pfn == huge_zero_pfn;
}

static inline bool is_huge_zero_pmd(pmd_t pmd)
Expand Down Expand Up @@ -564,10 +566,6 @@ static int __init hugepage_init(void)
if (err)
return err;

err = init_huge_zero_page();
if (err)
goto out;

err = khugepaged_slab_init();
if (err)
goto out;
Expand All @@ -590,8 +588,6 @@ static int __init hugepage_init(void)

return 0;
out:
if (huge_zero_pfn)
__free_page(pfn_to_page(huge_zero_pfn));
hugepage_exit_sysfs(hugepage_kobj);
return err;
}
Expand Down Expand Up @@ -735,6 +731,10 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
return VM_FAULT_OOM;
if (!(flags & FAULT_FLAG_WRITE)) {
pgtable_t pgtable;
if (unlikely(!huge_zero_pfn && init_huge_zero_pfn())) {
count_vm_event(THP_FAULT_FALLBACK);
goto out;
}
pgtable = pte_alloc_one(mm, haddr);
if (unlikely(!pgtable))
return VM_FAULT_OOM;
Expand Down

0 comments on commit f2993d2

Please sign in to comment.