Skip to content

zend alloc USE_ZEND_ALLOC_HUGE_PAGES option support on solaris based … #7789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2021
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
20 changes: 14 additions & 6 deletions Zend/zend_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,18 +662,28 @@ static zend_always_inline int zend_mm_bitset_is_free_range(zend_mm_bitset *bitse
/* Chunks */
/**********/

static zend_always_inline void zend_mm_hugepage(void* ptr, size_t size)
{
#if defined(MADV_HUGEPAGE)
(void)madvise(ptr, size, MADV_HUGEPAGE);
#elif defined(HAVE_MEMCNTL)
struct memcntl_mha m = {.mha_cmd = MHA_MAPSIZE_VA, .mha_pagesize = ZEND_MM_CHUNK_SIZE, .mha_flags = 0};
(void)memcntl(ptr, size, MC_HAT_ADVISE, (char *)&m, 0, 0);
#else
zend_error_noreturn(E_WARNING, "huge_pages: thp unsupported on this platform");
#endif
}

static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
{
void *ptr = zend_mm_mmap(size);

if (ptr == NULL) {
return NULL;
} else if (ZEND_MM_ALIGNED_OFFSET(ptr, alignment) == 0) {
#ifdef MADV_HUGEPAGE
if (zend_mm_use_huge_pages) {
madvise(ptr, size, MADV_HUGEPAGE);
zend_mm_hugepage(ptr, size);
}
#endif
return ptr;
} else {
size_t offset;
Expand Down Expand Up @@ -702,11 +712,9 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
if (alignment > REAL_PAGE_SIZE) {
zend_mm_munmap((char*)ptr + size, alignment - REAL_PAGE_SIZE);
}
# ifdef MADV_HUGEPAGE
if (zend_mm_use_huge_pages) {
madvise(ptr, size, MADV_HUGEPAGE);
zend_mm_hugepage(ptr, size);
}
# endif
#endif
return ptr;
}
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ inet_ntop \
inet_pton \
localtime_r \
lchown \
memcntl \
memmove \
mkstemp \
mmap \
Expand Down