Skip to content

Commit

Permalink
hugetlb: factor out prep_new_huge_page
Browse files Browse the repository at this point in the history
Needed to avoid code duplication in follow up patches.

Acked-by: Adam Litke <[email protected]>
Acked-by: Nishanth Aravamudan <[email protected]>
Signed-off-by: Andi Kleen <[email protected]>
Signed-off-by: Nick Piggin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Andi Kleen authored and torvalds committed Jul 24, 2008
1 parent ff7ea79 commit b7ba30c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,16 @@ static int adjust_pool_surplus(int delta)
return ret;
}

static void prep_new_huge_page(struct page *page, int nid)
{
set_compound_page_dtor(page, free_huge_page);
spin_lock(&hugetlb_lock);
nr_huge_pages++;
nr_huge_pages_node[nid]++;
spin_unlock(&hugetlb_lock);
put_page(page); /* free it into the hugepage allocator */
}

static struct page *alloc_fresh_huge_page_node(int nid)
{
struct page *page;
Expand All @@ -526,12 +536,7 @@ static struct page *alloc_fresh_huge_page_node(int nid)
__free_pages(page, HUGETLB_PAGE_ORDER);
return NULL;
}
set_compound_page_dtor(page, free_huge_page);
spin_lock(&hugetlb_lock);
nr_huge_pages++;
nr_huge_pages_node[nid]++;
spin_unlock(&hugetlb_lock);
put_page(page); /* free it into the hugepage allocator */
prep_new_huge_page(page, nid);
}

return page;
Expand Down

0 comments on commit b7ba30c

Please sign in to comment.