Highload-fun / platform

33 stars 0 forks source link

Cannot use Huge Pages feature #20

Closed matsuoka-601 closed 1 year ago

matsuoka-601 commented 1 year ago

Hello.

This link says that Huge Pages feature is available, so I submitted the code below. But it returns Error: Exit with code 1: mmap. Any advice on how to use Huge Pages feature? Thanks in advance.

#include <iostream>
#include <sys/mman.h>

int main() {
    void* ptr = mmap(0, 10, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
    if (ptr == MAP_FAILED) {
        std::cerr << "mmap";
        exit(1);
    }
    return 0;
}
sergei-svistunov commented 1 year ago

Try to use the madvise function.

matsuoka-601 commented 1 year ago

That worked. Thank you!