Skip to content

Commit 8b8152b

Browse files
committed
Zend,fibers: Ensure fiber stack is not backed by THP.
Ending with fiber stack mapped in hugepages will affect performance badly. Until < Linux 6.8-rc2 MAP_STACK was a noop, now it implies no THP, older releases need MAP_GROWSDOWN to signal it is a stack like segment and therefore no THP.
1 parent f359c0b commit 8b8152b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Zend/zend_fibers.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
# define MAP_STACK 0
5757
# endif
5858

59+
#if !defined(MAP_GROWSDOWN)
60+
#define MAP_GROWSDOWN 0
61+
#endif
62+
5963
# ifndef MAP_FAILED
6064
# define MAP_FAILED ((void * ) -1)
6165
# endif
@@ -237,7 +241,7 @@ static zend_fiber_stack *zend_fiber_stack_allocate(size_t size)
237241
}
238242
# endif
239243
#else
240-
pointer = mmap(NULL, alloc_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
244+
pointer = mmap(NULL, alloc_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK | MAP_GROWSDOWN, -1, 0);
241245

242246
if (pointer == MAP_FAILED) {
243247
zend_throw_exception_ex(NULL, 0, "Fiber stack allocate failed: mmap failed: %s (%d)", strerror(errno), errno);

0 commit comments

Comments
 (0)