Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 12th, 2012  |  syntax: None  |  size: 0.98 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/deps/jemalloc/src/chunk_mmap.c b/deps/jemalloc/src/chunk_mmap.c
  2. index 164e86e..c2ce465 100644
  3. --- a/deps/jemalloc/src/chunk_mmap.c
  4. +++ b/deps/jemalloc/src/chunk_mmap.c
  5. @@ -48,9 +48,25 @@ pages_map(void *addr, size_t size, bool noreserve)
  6.         if (noreserve)
  7.                 flags |= MAP_NORESERVE;
  8.  #endif
  9. +
  10. +#ifdef MAP_HUGETLB
  11. +       flags |= MAP_HUGETLB;
  12. +#endif
  13.         ret = mmap(addr, size, PROT_READ | PROT_WRITE, flags, -1, 0);
  14.         assert(ret != NULL);
  15.  
  16. +#ifdef MAP_HUGETLB
  17. +       /*
  18. +        * Retry on ENOMEM when we tried to map using huge pages.
  19. +        * This strategy is far from optimal, needs way more heuristics...
  20. +        */
  21. +       if (ret == MAP_FAILED && errno == ENOMEM) {
  22. +               flags &= ~MAP_HUGETLB;
  23. +               ret = mmap(addr, size, PROT_READ | PROT_WRITE, flags, -1, 0);
  24. +               assert(ret != NULL);
  25. +       }
  26. +#endif
  27. +
  28.         if (ret == MAP_FAILED)
  29.                 ret = NULL;
  30.         else if (addr != NULL && ret != addr) {