Skip to content

Commit 3b3fafa

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents 767fa3d + 928c422 commit 3b3fafa

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Zend/zend_alloc.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,7 @@ typedef struct _zend_mm_free_slot zend_mm_free_slot;
191191
typedef struct _zend_mm_chunk zend_mm_chunk;
192192
typedef struct _zend_mm_huge_list zend_mm_huge_list;
193193

194-
#ifdef MAP_HUGETLB
195194
int zend_mm_use_huge_pages = 0;
196-
#endif
197195

198196
/*
199197
* Memory is retrived from OS by chunks of fixed size 2MB.
@@ -714,7 +712,9 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
714712
return NULL;
715713
} else if (ZEND_MM_ALIGNED_OFFSET(ptr, alignment) == 0) {
716714
#ifdef MADV_HUGEPAGE
717-
madvise(ptr, size, MADV_HUGEPAGE);
715+
if (zend_mm_use_huge_pages) {
716+
madvise(ptr, size, MADV_HUGEPAGE);
717+
}
718718
#endif
719719
return ptr;
720720
} else {
@@ -745,7 +745,9 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
745745
zend_mm_munmap((char*)ptr + size, alignment - REAL_PAGE_SIZE);
746746
}
747747
# ifdef MADV_HUGEPAGE
748-
madvise(ptr, size, MADV_HUGEPAGE);
748+
if (zend_mm_use_huge_pages) {
749+
madvise(ptr, size, MADV_HUGEPAGE);
750+
}
749751
# endif
750752
#endif
751753
return ptr;
@@ -2668,9 +2670,7 @@ ZEND_API void shutdown_memory_manager(int silent, int full_shutdown)
26682670

26692671
static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
26702672
{
2671-
#if ZEND_MM_CUSTOM || MAP_HUGETLB
26722673
char *tmp;
2673-
#endif
26742674

26752675
#if ZEND_MM_CUSTOM
26762676
tmp = getenv("USE_ZEND_ALLOC");
@@ -2684,12 +2684,11 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
26842684
return;
26852685
}
26862686
#endif
2687-
#ifdef MAP_HUGETLB
2687+
26882688
tmp = getenv("USE_ZEND_ALLOC_HUGE_PAGES");
26892689
if (tmp && zend_atoi(tmp, 0)) {
26902690
zend_mm_use_huge_pages = 1;
26912691
}
2692-
#endif
26932692
ZEND_TSRMLS_CACHE_UPDATE();
26942693
alloc_globals->mm_heap = zend_mm_init();
26952694
}

0 commit comments

Comments
 (0)