简体   繁体   English

如何在 Linux 内核中分配大页面

[英]How to allocate huge pages in Linux kernel

I am studying transparent huge page (THP) in Linux.我正在研究 Linux 中的透明大页面 (THP)。

I am trying to call __get_free_pages(GFP_KERNEL|__GFP_COMP, mysize) to ask kernel to allocate 2MB huge pages for me.我正在尝试调用__get_free_pages(GFP_KERNEL|__GFP_COMP, mysize)来要求内核为我分配 2MB 大页面。

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.如何检查该分配页的内核页表以确保它是大页。

The documentation on kernel memory allocation is in the source at Documentation/core-api/memory-allocation.rst有关内核内存分配的文档位于 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. include/linux/vmalloc.h 中的许多 API 使用 vm_flags,其中 VM_HUGETLB 可以是这些标志之一。

Not a complete answer however I'm hoping its in the right direction.不是一个完整的答案,但我希望它朝着正确的方向发展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM