com php-src: Added ability to disable huge pages in Zend Memeory Manager through the environment variable USE_ZEND_ALLOC_HUGE_PA GES=0.:
Zend/zend_alloc.c
| From: | Anatol Belski | Date: | Wed, 23 Mar 2016 11:23:03 +0000 |
| Subject: | com php-src: Added ability to disable huge pages in Zend Memeory Manager through the environment variable USE_ZEND_ALLOC_HUGE_PA GES=0.: Zend/zend_alloc.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91469@lists.php.net to get a copy of this message | ||
Commit: 75dd4a7a502c271cd2e69fe46b085614beb771b2
Author: Dmitry Stogov <dmitry@zend.com> Thu, 17 Mar 2016 22:43:42 +0300
Committer: Anatol Belski <ab@php.net> Wed, 23 Mar 2016 12:23:03 +0100
Parents: ffe82dd775c2fc4b76e2339f893d2fd1d27bf916
Branches: PHP-7.0.5
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=75dd4a7a502c271cd2e69fe46b085614beb771b2
Log:
Added ability to disable huge pages in Zend Memeory Manager through the environment variable
USE_ZEND_ALLOC_HUGE_PAGES=0.
Changed paths:
M Zend/zend_alloc.c
Diff:
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 6f0542e..4cf1178 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -200,6 +200,10 @@ typedef struct _zend_mm_huge_list zend_mm_huge_list;
# define PTR_FMT "0x%0.8lx"
#endif
+#ifdef MAP_HUGETLB
+int zend_mm_use_huge_pages = 1;
+#endif
+
/*
* Memory is retrived from OS by chunks of fixed size 2MB.
* Inside chunk it's managed by pages of fixed size 4096B.
@@ -462,7 +466,7 @@ static void *zend_mm_mmap(size_t size)
void *ptr;
#ifdef MAP_HUGETLB
- if (size == ZEND_MM_CHUNK_SIZE) {
+ if (zend_mm_use_huge_pages && size == ZEND_MM_CHUNK_SIZE) {
ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_HUGETLB, -1, 0);
if (ptr != MAP_FAILED) {
return ptr;
@@ -2648,6 +2652,12 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
return;
}
#endif
+#ifdef MAP_HUGETLB
+ tmp = getenv("USE_ZEND_ALLOC_HUGE_PAGES");
+ if (tmp && !zend_atoi(tmp, 0)) {
+ zend_mm_use_huge_pages = 0;
+ }
+#endif
ZEND_TSRMLS_CACHE_UPDATE();
alloc_globals->mm_heap = zend_mm_init();
}