Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 343299
b: refs/heads/master
c: 4a6c129
h: refs/heads/master
i:
  343297: 72527b4
  343295: 2603108
v: v3
  • Loading branch information
Kirill A. Shutemov authored and Linus Torvalds committed Dec 13, 2012
1 parent af8bbbc commit 3c1cb77
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3f7dfe24b84c0ad698c461fc9c4ba3544bbfcebf
refs/heads/master: 4a6c1297268c917e9c50701906ba2f7e06812299
30 changes: 30 additions & 0 deletions trunk/mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static unsigned int khugepaged_scan_sleep_millisecs __read_mostly = 10000;
/* during fragmentation poll the hugepage allocator once every minute */
static unsigned int khugepaged_alloc_sleep_millisecs __read_mostly = 60000;
static struct task_struct *khugepaged_thread __read_mostly;
static unsigned long huge_zero_pfn __read_mostly;
static DEFINE_MUTEX(khugepaged_mutex);
static DEFINE_SPINLOCK(khugepaged_mm_lock);
static DECLARE_WAIT_QUEUE_HEAD(khugepaged_wait);
Expand Down Expand Up @@ -159,6 +160,29 @@ static int start_khugepaged(void)
return err;
}

static int __init init_huge_zero_page(void)
{
struct page *hpage;

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

huge_zero_pfn = page_to_pfn(hpage);
return 0;
}

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

static inline bool is_huge_zero_pmd(pmd_t pmd)
{
return is_huge_zero_pfn(pmd_pfn(pmd));
}

#ifdef CONFIG_SYSFS

static ssize_t double_flag_show(struct kobject *kobj,
Expand Down Expand Up @@ -540,6 +564,10 @@ 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 @@ -562,6 +590,8 @@ 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

0 comments on commit 3c1cb77

Please sign in to comment.