@@ -191,9 +191,7 @@ typedef struct _zend_mm_free_slot zend_mm_free_slot;
191
191
typedef struct _zend_mm_chunk zend_mm_chunk ;
192
192
typedef struct _zend_mm_huge_list zend_mm_huge_list ;
193
193
194
- #ifdef MAP_HUGETLB
195
194
int zend_mm_use_huge_pages = 0 ;
196
- #endif
197
195
198
196
/*
199
197
* 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)
714
712
return NULL ;
715
713
} else if (ZEND_MM_ALIGNED_OFFSET (ptr , alignment ) == 0 ) {
716
714
#ifdef MADV_HUGEPAGE
717
- madvise (ptr , size , MADV_HUGEPAGE );
715
+ if (zend_mm_use_huge_pages ) {
716
+ madvise (ptr , size , MADV_HUGEPAGE );
717
+ }
718
718
#endif
719
719
return ptr ;
720
720
} else {
@@ -745,7 +745,9 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
745
745
zend_mm_munmap ((char * )ptr + size , alignment - REAL_PAGE_SIZE );
746
746
}
747
747
# ifdef MADV_HUGEPAGE
748
- madvise (ptr , size , MADV_HUGEPAGE );
748
+ if (zend_mm_use_huge_pages ) {
749
+ madvise (ptr , size , MADV_HUGEPAGE );
750
+ }
749
751
# endif
750
752
#endif
751
753
return ptr ;
@@ -2668,9 +2670,7 @@ ZEND_API void shutdown_memory_manager(int silent, int full_shutdown)
2668
2670
2669
2671
static void alloc_globals_ctor (zend_alloc_globals * alloc_globals )
2670
2672
{
2671
- #if ZEND_MM_CUSTOM || MAP_HUGETLB
2672
2673
char * tmp ;
2673
- #endif
2674
2674
2675
2675
#if ZEND_MM_CUSTOM
2676
2676
tmp = getenv ("USE_ZEND_ALLOC" );
@@ -2684,12 +2684,11 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
2684
2684
return ;
2685
2685
}
2686
2686
#endif
2687
- #ifdef MAP_HUGETLB
2687
+
2688
2688
tmp = getenv ("USE_ZEND_ALLOC_HUGE_PAGES" );
2689
2689
if (tmp && zend_atoi (tmp , 0 )) {
2690
2690
zend_mm_use_huge_pages = 1 ;
2691
2691
}
2692
- #endif
2693
2692
ZEND_TSRMLS_CACHE_UPDATE ();
2694
2693
alloc_globals -> mm_heap = zend_mm_init ();
2695
2694
}
0 commit comments