Skip to content

Commit a9d4579

Browse files
committed
Merge branch 'PHP-7.4'
2 parents e517cff + 709b8aa commit a9d4579

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
@@ -190,9 +190,7 @@ typedef struct _zend_mm_free_slot zend_mm_free_slot;
190190
typedef struct _zend_mm_chunk zend_mm_chunk;
191191
typedef struct _zend_mm_huge_list zend_mm_huge_list;
192192

193-
#ifdef MAP_HUGETLB
194193
int zend_mm_use_huge_pages = 0;
195-
#endif
196194

197195
/*
198196
* Memory is retrieved from OS by chunks of fixed size 2MB.
@@ -709,7 +707,9 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
709707
return NULL;
710708
} else if (ZEND_MM_ALIGNED_OFFSET(ptr, alignment) == 0) {
711709
#ifdef MADV_HUGEPAGE
712-
madvise(ptr, size, MADV_HUGEPAGE);
710+
if (zend_mm_use_huge_pages) {
711+
madvise(ptr, size, MADV_HUGEPAGE);
712+
}
713713
#endif
714714
return ptr;
715715
} else {
@@ -740,7 +740,9 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
740740
zend_mm_munmap((char*)ptr + size, alignment - REAL_PAGE_SIZE);
741741
}
742742
# ifdef MADV_HUGEPAGE
743-
madvise(ptr, size, MADV_HUGEPAGE);
743+
if (zend_mm_use_huge_pages) {
744+
madvise(ptr, size, MADV_HUGEPAGE);
745+
}
744746
# endif
745747
#endif
746748
return ptr;
@@ -2702,9 +2704,7 @@ ZEND_API void shutdown_memory_manager(int silent, int full_shutdown)
27022704

27032705
static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
27042706
{
2705-
#if ZEND_MM_CUSTOM || MAP_HUGETLB
27062707
char *tmp;
2707-
#endif
27082708

27092709
#if ZEND_MM_CUSTOM
27102710
tmp = getenv("USE_ZEND_ALLOC");
@@ -2718,12 +2718,11 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
27182718
return;
27192719
}
27202720
#endif
2721-
#ifdef MAP_HUGETLB
2721+
27222722
tmp = getenv("USE_ZEND_ALLOC_HUGE_PAGES");
27232723
if (tmp && zend_atoi(tmp, 0)) {
27242724
zend_mm_use_huge_pages = 1;
27252725
}
2726-
#endif
27272726
ZEND_TSRMLS_CACHE_UPDATE();
27282727
alloc_globals->mm_heap = zend_mm_init();
27292728
}

0 commit comments

Comments
 (0)