I found alloc_pages() is called by alloc_fresh_huge_page_node() to allocate one huge page, just want to confirm if it allocates one physical huge page and also builds memory mapping?
static struct page *alloc_fresh_huge_page_node(struct hstate *h, int nid)
{
struct page *page;
if (h->order >= MAX_ORDER)
return NULL;
page = alloc_pages_exact_node(nid,
htlb_alloc_mask|__GFP_COMP|__GFP_THISNODE|
__GFP_REPEAT|__GFP_NOWARN,
huge_page_order(h));
if (page) {
if (arch_prepare_hugepage(page)) {
__free_pages(page, huge_page_order(h));
return NULL;
}
prep_new_huge_page(h, page, nid);
}
return page;
}
Alloc_pages() allocates whichever possible page size you use it for. 2MB is one option (typically when using PAE), the others being, on the 2.6 kernel, 4kb and 4MB.