Skip to content

Commit

Permalink
have proprocessor choose correct mmap args
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Neely committed May 9, 2014
1 parent f41cde3 commit deb8940
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions util/arena.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ char* Arena::AllocateAligned(size_t bytes, size_t huge_page_tlb_size,
((bytes - 1U) / huge_page_tlb_size + 1U) * huge_page_tlb_size;
assert(reserved_size >= bytes);

#ifdef MAP_HUGETLB
void* addr = mmap(nullptr, reserved_size, (PROT_READ | PROT_WRITE),
(MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB), 0, 0);
#else
void* addr = mmap(nullptr, reserved_size, (PROT_READ | PROT_WRITE),
(MAP_PRIVATE | MAP_ANONYMOUS), 0, 0);

// only supported in kernel's 2.6.34 and above
// void* addr = mmap(nullptr, reserved_size, (PROT_READ | PROT_WRITE),
// (MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB), 0, 0);
#endif

if (addr == MAP_FAILED) {
Warn(logger, "AllocateAligned fail to allocate huge TLB pages: %s",
Expand Down

0 comments on commit deb8940

Please sign in to comment.