Commit e4e12482 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼

memory: fix logic to activate hugepage allocator

parent 5a73d477
Subproject commit 275c193fa438ef08502ab4795985b312e2cece8f
Subproject commit 1d7b5661d173e2517df0a287b145724d61cf1e17
......@@ -52,30 +52,42 @@ int memory_mmap_init(int hugepages)
return -1;
if (hugepages > 0) {
hugepgsz = kernel_get_hugepage_size();
if (hugepgsz < 0)
return -1;
hugepgsz = kernel_get_hugepage_size();
if (hugepgsz < 0) {
warning("Failed to determine hugepage size.");
#if defined(__linux__) && defined(__x86_64__)
int pagecnt;
memory_default = &memory_mmap;
return 0;
}
pagecnt = kernel_get_nr_hugepages();
if (pagecnt < hugepages) {
if (getuid() == 0) {
kernel_set_nr_hugepages(hugepages);
debug(LOG_MEM | 2, "Increased number of reserved hugepages from %d to %d", pagecnt, hugepages);
#if defined(__linux__) && defined(__x86_64__)
int ret, pagecnt;
pagecnt = kernel_get_nr_hugepages();
if (pagecnt < hugepages) {
if (getuid() == 0) {
ret = kernel_set_nr_hugepages(hugepages);
if (ret) {
warning("Failed to increase number of reserved hugepages");
memory_default = &memory_mmap;
}
debug(LOG_MEM | 2, "Increased number of reserved hugepages from %d to %d", pagecnt, hugepages);
memory_default = &memory_mmap_hugetlb;
}
else {
warning("Failed to reserved hugepages. Please reserve manually by running as root:");
warning(" $ echo %d > /proc/sys/vm/nr_hugepages", hugepages);
}
}
warning("Failed to reserved hugepages. Please reserve manually by running as root:");
warning(" $ echo %d > /proc/sys/vm/nr_hugepages", hugepages);
memory_default = &memory_mmap;
}
}
else
memory_default = &memory_mmap_hugetlb;
#endif
memory_default = &memory_mmap_hugetlb;
}
else {
warning("Hugepage allocator disabled.");
memory_default = &memory_mmap;
warning("Hugepage allocator disabled.");
memory_default = &memory_mmap;
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment