@@ -190,9 +190,7 @@ typedef struct _zend_mm_free_slot zend_mm_free_slot;
190
190
typedef struct _zend_mm_chunk zend_mm_chunk ;
191
191
typedef struct _zend_mm_huge_list zend_mm_huge_list ;
192
192
193
- #ifdef MAP_HUGETLB
194
193
int zend_mm_use_huge_pages = 0 ;
195
- #endif
196
194
197
195
/*
198
196
* 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)
709
707
return NULL ;
710
708
} else if (ZEND_MM_ALIGNED_OFFSET (ptr , alignment ) == 0 ) {
711
709
#ifdef MADV_HUGEPAGE
712
- madvise (ptr , size , MADV_HUGEPAGE );
710
+ if (zend_mm_use_huge_pages ) {
711
+ madvise (ptr , size , MADV_HUGEPAGE );
712
+ }
713
713
#endif
714
714
return ptr ;
715
715
} else {
@@ -740,7 +740,9 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
740
740
zend_mm_munmap ((char * )ptr + size , alignment - REAL_PAGE_SIZE );
741
741
}
742
742
# ifdef MADV_HUGEPAGE
743
- madvise (ptr , size , MADV_HUGEPAGE );
743
+ if (zend_mm_use_huge_pages ) {
744
+ madvise (ptr , size , MADV_HUGEPAGE );
745
+ }
744
746
# endif
745
747
#endif
746
748
return ptr ;
@@ -2702,9 +2704,7 @@ ZEND_API void shutdown_memory_manager(int silent, int full_shutdown)
2702
2704
2703
2705
static void alloc_globals_ctor (zend_alloc_globals * alloc_globals )
2704
2706
{
2705
- #if ZEND_MM_CUSTOM || MAP_HUGETLB
2706
2707
char * tmp ;
2707
- #endif
2708
2708
2709
2709
#if ZEND_MM_CUSTOM
2710
2710
tmp = getenv ("USE_ZEND_ALLOC" );
@@ -2718,12 +2718,11 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
2718
2718
return ;
2719
2719
}
2720
2720
#endif
2721
- #ifdef MAP_HUGETLB
2721
+
2722
2722
tmp = getenv ("USE_ZEND_ALLOC_HUGE_PAGES" );
2723
2723
if (tmp && zend_atoi (tmp , 0 )) {
2724
2724
zend_mm_use_huge_pages = 1 ;
2725
2725
}
2726
- #endif
2727
2726
ZEND_TSRMLS_CACHE_UPDATE ();
2728
2727
alloc_globals -> mm_heap = zend_mm_init ();
2729
2728
}
0 commit comments