How to allocate huge pages in Linux kernel

Viewed 1771

I am studying transparent huge page (THP) in Linux.

I am trying to call __get_free_pages(GFP_KERNEL|__GFP_COMP, mysize) to ask kernel to allocate 2MB huge pages for me.

So I want to know:

  1. If kernel really allocate huge page for me?
  2. How can I check the kernel page table for that allocated page to make sure it is huge page.
1 Answers

The documentation on kernel memory allocation is in the source at Documentation/core-api/memory-allocation.rst

A number of APIs in include/linux/vmalloc.h take vm_flags of which VM_HUGETLB can be one of those flags.

Not a complete answer however I'm hoping its in the right direction.

Related