diff options
| author | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2018-10-23 14:11:35 +0000 |
|---|---|---|
| committer | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2018-10-23 14:11:35 +0000 |
| commit | 0c885e274ad6db01a88f71bc3c382d640b2dc1e5 (patch) | |
| tree | 9e3ccc81e7993762aad62f464e207f5930b49f91 | |
| parent | bff19560ee234a58064ae6bc4645d29d9e02e5a5 (diff) | |
Notes
| -rw-r--r-- | contrib/jemalloc/src/pages.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/contrib/jemalloc/src/pages.c b/contrib/jemalloc/src/pages.c index 8acebd1b818b..96836f75cb4c 100644 --- a/contrib/jemalloc/src/pages.c +++ b/contrib/jemalloc/src/pages.c @@ -180,6 +180,31 @@ pages_map(void *addr, size_t size, size_t alignment, bool *commit) { assert(alignment >= PAGE); assert(ALIGNMENT_ADDR2BASE(addr, alignment) == addr); +#if defined(__FreeBSD__) && defined(MAP_EXCL) + /* + * FreeBSD has mechanisms both to mmap at specific address without + * touching existing mappings, and to mmap with specific alignment. + */ + { + int prot = *commit ? PAGES_PROT_COMMIT : PAGES_PROT_DECOMMIT; + int flags = mmap_flags; + + if (addr != NULL) { + flags |= MAP_FIXED | MAP_EXCL; + } else { + unsigned alignment_bits = ffs_zu(alignment); + assert(alignment_bits > 1); + flags |= MAP_ALIGNED(alignment_bits - 1); + } + + void *ret = mmap(addr, size, prot, flags, -1, 0); + if (ret == MAP_FAILED) { + ret = NULL; + } + + return ret; + } +#endif /* * Ideally, there would be a way to specify alignment to mmap() (like * NetBSD has), but in the absence of such a feature, we have to work |
