From: jocelyn dot fournier at softizy dot com
Operating system: Linux on Power
PHP version: 7.0.2
Package: opcache
Bug Type: Bug
Bug description:Fail to use huge page on power8 because of wrong page size
Description:
------------
Hi,
It seems huge page size is hardcoded in the php src code :
In ZendAccelerator.c for example, you have :
static void accel_move_code_to_huge_pages(void)
{
FILE *f;
long unsigned int huge_page_size = 2 * 1024 * 1024;
However on IBM Power8 on linux, the default page size is 64KB (
http://www.redbooks.ibm.com/redbooks/pdfs/sg248171.pdf
).
Hence when huge pages are enabled, php displays the following warning :
munmap() failed: [22] Invalid argument
strace output :
[...]
mmap(NULL, 2097152, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS|0x40000, -1, 0) = 0x3effff000000
madvise(0x3effff000000, 2097152, MADV_HUGEPAGE) = -1 EINVAL (Invalid
argument)
[...]
open("/usr/local/lib/php/extensions/no-debug-non-zts-20151012/apcu.so",
O_RDONLY|O_CLOEXEC) = 3
read(3,
"\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\25\0\1\0\0\0\0`\0\0\0\0\0\0"...,
832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=121864, ...}) = 0
mmap(NULL, 158952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)
= 0x3fff8e140000
mmap(0x3fff8e160000, 65536, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10000) = 0x3fff8e160000
close(3) = 0
[...]
munmap(0x3efff7000000, 134217728) = 0
close(3) = 0
munmap(0x3fff962c0000, 185272) = 0
munmap(0x3fff96240000, 82352) = 0
munmap(0x3fff96260000, 328760) = 0
munmap(0x3fff94210000, 33554432) = 0
munmap(0x3fff962f0000, 158952) = 0
brk(0x1001a8d0000) = 0x1001a8d0000
munmap(0x3fff96320000, 301576) = 0
munmap(0x3fff96210000, 196608) = 0
munmap(0x3effff000000, 2097152) = -1 EINVAL (Invalid argument)
write(2, "\nmunmap() failed: [22] Invalid a"..., 40
munmap() failed: [22] Invalid argument
) = 40
munmap(0x3fff96370000, 327680) = 0
exit_group(0) = ?
+++ exited with 0 +++
To fix the issue, the default page size should not be hardcoded, but
should depend on the platform.
Thanks and regards,
Jocelyn Fournier
Expected result:
----------------
No warning
Actual result:
--------------
munmap() failed: [22] Invalid argument
--
Edit bug report at https://bugs.php.net/bug.php?id=71355&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71355&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71355&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71355&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71355&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71355&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71355&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71355&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71355&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71355&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71355&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71355&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71355&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71355&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71355&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71355&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71355&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71355&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71355&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71355&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71355&r=mysqlcfg