From f41cde310570214b0427c6867e27300d98eaebec Mon Sep 17 00:00:00 2001 From: dallas marlow Date: Thu, 8 May 2014 11:45:44 -0400 Subject: [PATCH 1/4] remove anon mmap allocation flag `MAP_HUGETLB` --- util/arena.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/util/arena.cc b/util/arena.cc index 094266a73a..96738f8b51 100644 --- a/util/arena.cc +++ b/util/arena.cc @@ -83,8 +83,14 @@ char* Arena::AllocateAligned(size_t bytes, size_t huge_page_tlb_size, size_t reserved_size = ((bytes - 1U) / huge_page_tlb_size + 1U) * huge_page_tlb_size; assert(reserved_size >= bytes); + void* addr = mmap(nullptr, reserved_size, (PROT_READ | PROT_WRITE), - (MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB), 0, 0); + (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); + if (addr == MAP_FAILED) { Warn(logger, "AllocateAligned fail to allocate huge TLB pages: %s", strerror(errno)); From deb89401fd0c3e59167c01182ba1fcfa23adc3f6 Mon Sep 17 00:00:00 2001 From: Tyler Neely Date: Fri, 9 May 2014 14:49:25 -0400 Subject: [PATCH 2/4] have proprocessor choose correct mmap args --- util/arena.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/util/arena.cc b/util/arena.cc index 96738f8b51..1284c8b352 100644 --- a/util/arena.cc +++ b/util/arena.cc @@ -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", From 030db3d17e0f906c4a6bc04473b2247290d98c14 Mon Sep 17 00:00:00 2001 From: Dallas Marlow Date: Fri, 9 May 2014 18:58:39 -0400 Subject: [PATCH 3/4] testing --- util/arena.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/util/arena.cc b/util/arena.cc index 1284c8b352..bb142874fd 100644 --- a/util/arena.cc +++ b/util/arena.cc @@ -76,7 +76,7 @@ char* Arena::AllocateAligned(size_t bytes, size_t huge_page_tlb_size, assert((kAlignUnit & (kAlignUnit - 1)) == 0); // Pointer size should be a power of 2 -#ifdef OS_LINUX +#ifdef MAP_HUGETLB if (huge_page_tlb_size > 0 && bytes > 0) { // Allocate from a huge page TBL table. assert(logger != nullptr); // logger need to be passed in. @@ -84,13 +84,8 @@ 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); -#endif if (addr == MAP_FAILED) { Warn(logger, "AllocateAligned fail to allocate huge TLB pages: %s", From 557fbc9b3b5cee9bd53b4dcb481187cd71fbeefa Mon Sep 17 00:00:00 2001 From: Dallas Marlow Date: Sun, 11 May 2014 10:22:28 -0400 Subject: [PATCH 4/4] arena spacing --- util/arena.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/arena.cc b/util/arena.cc index bb142874fd..1775addcd0 100644 --- a/util/arena.cc +++ b/util/arena.cc @@ -83,9 +83,8 @@ char* Arena::AllocateAligned(size_t bytes, size_t huge_page_tlb_size, size_t reserved_size = ((bytes - 1U) / huge_page_tlb_size + 1U) * huge_page_tlb_size; assert(reserved_size >= bytes); - void* addr = mmap(nullptr, reserved_size, (PROT_READ | PROT_WRITE), - (MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB), 0, 0); + (MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB), 0, 0); if (addr == MAP_FAILED) { Warn(logger, "AllocateAligned fail to allocate huge TLB pages: %s",