Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
/* See PERFORMANCE.md for notes on huge page sizes.
* If your system uses a non-default value for huge
* page sizes you will need to adjust that here */
#if __linux__ && MAP_HUGETLB && HUGE_PAGES
#if (__linux__ && MAP_HUGETLB) || (__APPLE__ && VM_FLAGS_SUPERPAGE_SIZE_2MB) && HUGE_PAGES
#define HUGE_PAGE_SZ 2097152
#endif

Expand Down
1 change: 1 addition & 0 deletions include/iso_alloc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#define ENVIRON environ
#elif __APPLE__
#include <libkern/OSByteOrder.h>
#include <mach/vm_statistics.h>
#define bswap_32(x) OSSwapInt32(x)
#define bswap_64(x) OSSwapInt64(x)
#define ENVIRON NULL
Expand Down
11 changes: 10 additions & 1 deletion src/iso_alloc_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ INTERNAL_HIDDEN void *mmap_pages(size_t size, bool populate, const char *name, i
size = ROUND_UP_PAGE(size);

int32_t flags = (MAP_PRIVATE | MAP_ANONYMOUS);
int fd = -1;

#if __linux__
#if PRE_POPULATE_PAGES
Expand All @@ -51,9 +52,17 @@ INTERNAL_HIDDEN void *mmap_pages(size_t size, bool populate, const char *name, i
flags |= MAP_HUGETLB;
}
#endif
#elif __APPLE__
#if VM_FLAGS_SUPERPAGE_SIZE_2MB && HUGE_PAGES
/* If we are allocating pages for a user zone
* we are going to use the 2 MB superpage flag */
if(size == ZONE_USER_SIZE || size == (ZONE_USER_SIZE / 2)) {
fd = VM_FLAGS_SUPERPAGE_SIZE_2MB;
}
#endif
#endif

p = mmap(p, size, prot, flags, -1, 0);
p = mmap(p, size, prot, flags, fd, 0);

if(p == MAP_FAILED) {
LOG_AND_ABORT("Failed to mmap rw pages");
Expand Down