summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-12-17 17:46:48 +0100
committerAnatol Belski <ab@php.net>2014-12-17 17:46:48 +0100
commite8acb9ff267e7605b7eb29c04ea1f5c6e5db38b8 (patch)
treef725503ad53511144ee9db93c1fc10a06f5aa67d
parente1fcb9ea66384269e5afa22769bb95cf2eb08306 (diff)
parent79354ba6d0d6a1a4596f9ac66ee9bc3a34ed972b (diff)
downloadphp-git-e8acb9ff267e7605b7eb29c04ea1f5c6e5db38b8.tar.gz
Merge remote-tracking branch 'origin/master' into native-tls
* origin/master: fix integral constant overflow warning Use HUGE PAGES for opcahce SHM, if available.
-rw-r--r--Zend/zend_compile.h2
-rw-r--r--ext/opcache/shared_alloc_mmap.c16
2 files changed, 17 insertions, 1 deletions
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index d01be0eb72..9b0bfda273 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -433,7 +433,7 @@ struct _zend_execute_data {
(call)->This.u2.num_args
#define ZEND_CALL_FRAME_SLOT \
- ((ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval)) - 1) / ZEND_MM_ALIGNED_SIZE(sizeof(zval)))
+ ((int)((ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval)) - 1) / ZEND_MM_ALIGNED_SIZE(sizeof(zval))))
#define ZEND_CALL_VAR(call, n) \
((zval*)(((char*)(call)) + ((int)(n))))
diff --git a/ext/opcache/shared_alloc_mmap.c b/ext/opcache/shared_alloc_mmap.c
index d995e20f12..5744fc8167 100644
--- a/ext/opcache/shared_alloc_mmap.c
+++ b/ext/opcache/shared_alloc_mmap.c
@@ -46,6 +46,22 @@ static int create_segments(size_t requested_size, zend_shared_segment ***shared_
shared_segment = (zend_shared_segment *)((char *)(*shared_segments_p) + sizeof(void *));
(*shared_segments_p)[0] = shared_segment;
+#ifdef MAP_HUGETLB
+ /* Try to allocate huge pages first to reduce dTLB misses.
+ * OS has to be configured properly
+ * (e.g. https://wiki.debian.org/Hugepages#Enabling_HugeTlbPage)
+ * You may verify huge page usage with the following command:
+ * `grep "Huge" /proc/meminfo`
+ */
+ shared_segment->p = mmap(0, requested_size, PROT_READ | PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS|MAP_HUGETLB, -1, 0);
+ if (shared_segment->p != MAP_FAILED) {
+ shared_segment->pos = 0;
+ shared_segment->size = requested_size;
+
+ return ALLOC_SUCCESS;
+ }
+#endif
+
shared_segment->p = mmap(0, requested_size, PROT_READ | PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
if (shared_segment->p == MAP_FAILED) {
*error_in = "mmap";