Use a local variable to set the alignment for this particular allocation
instead of changing mmap_flags which makes the change permanent. This was enforcing large alignments for allocations that did not need it causing fragmentation. Reported by Andreas Gustafsson.
This commit is contained in:
parent
6d4aa33753
commit
5832ef6589
@ -155,6 +155,7 @@ os_pages_map(void *addr, size_t size, size_t alignment, bool *commit) {
|
||||
* of existing mappings, and we only want to create new mappings.
|
||||
*/
|
||||
{
|
||||
int flags = mmap_flags;
|
||||
#ifdef __NetBSD__
|
||||
/*
|
||||
* On NetBSD PAGE for a platform is defined to the
|
||||
@ -164,12 +165,12 @@ os_pages_map(void *addr, size_t size, size_t alignment, bool *commit) {
|
||||
*/
|
||||
if (alignment > os_page || PAGE > os_page) {
|
||||
unsigned int a = ilog2(MAX(alignment, PAGE));
|
||||
mmap_flags |= MAP_ALIGNED(a);
|
||||
flags |= MAP_ALIGNED(a);
|
||||
}
|
||||
#endif
|
||||
int prot = *commit ? PAGES_PROT_COMMIT : PAGES_PROT_DECOMMIT;
|
||||
|
||||
ret = mmap(addr, size, prot, mmap_flags, PAGES_FD_TAG, 0);
|
||||
ret = mmap(addr, size, prot, flags, PAGES_FD_TAG, 0);
|
||||
}
|
||||
assert(ret != NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user