Hunk API, using FreeBSD super page for large requests.

This commit is contained in:
David Carlier 2020-02-08 20:55:50 +00:00
parent 32b4e6f4a8
commit 0c1afcdfc1
1 changed files with 14 additions and 1 deletions

View File

@ -58,9 +58,22 @@ Hunk_Begin(int maxsize)
/* plus 32 bytes for cacheline */
maxhunksize = maxsize + sizeof(size_t) + 32;
curhunksize = 0;
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
#if defined(MAP_ALIGNED_SUPER)
const size_t hgpagesize = 1UL<<21;
size_t page_size = sysconf(_SC_PAGESIZE);
/* Archs supported has 2MB for super pages size */
if (maxhunksize >= hgpagesize)
{
maxhunksize = (maxhunksize & ~(page_size-1)) + page_size;
flags |= MAP_ALIGNED_SUPER;
}
#endif
membase = mmap(0, maxhunksize, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
flags, -1, 0);
if ((membase == NULL) || (membase == (byte *)-1))
{