最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

linux - Universal method to get the page size of memory allocated by mmap(normal or hugepage)? - Stack Overflow

programmeradmin2浏览0评论

My program is using mmap to allocate memory. Depending on the env running my app, sometimes I want HugePage, or normal memory if there's no HugePage configured.

I want a convenient/universal method to get the page size of the memory returned by mmap, regardless if I passed MAP_HUGETLB arg to it.

I tried gethugepagesize()/gethugepagesizes(), but I can't link it against libhugetlbfs. After a lot of searching, I found that linking against this lib is very very complicated, while what I want is merely to know wether or not I'm using a huge page. It is NOT worth adding many changes into my CMake file.

Furthermore, gethugepagesize()/gethugepagesizes() is NOT a universal method. If I haven't used MAP_HUGETLB, I have to call getpagesize() once again.

Is there a universal method, can get the page size of the memory returned by mmap?

Thanks!

发布评论

评论列表(0)

  1. 暂无评论