[php-src] Issue #11130: Systems that lack Transparent Huge Page support will display PHP errors w/ opcache.
| From: | monkburger | Date: | Mon, 24 Apr 2023 20:31:53 +0000 |
| Subject: | [php-src] Issue #11130: Systems that lack Transparent Huge Page support will display PHP errors w/ opcache. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244264@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11130
Author: monkburger
### Description
In this commit https://github.com/php/php-src/pull/10295/commits/ade74409da92f45fb6f46dd25ce2947dbe9d7a07
THP was added as a 'fallback' if HugePages were not avalabile, however madvise()
isn't checked for failures so if you copied opcache from a working server to one that does not
have Transparent Huge Pages, it will display an error, ie:
`[24-Apr-2023 15:01:27 UTC] PHP Warning: Zend OPcache huge_code_pages: madvise(HUGEPAGE) failed:
Invalid argument (22) in Unknown on line 0
`
```
1682 mmap(0x55f684400000, 2097152, PROT_READ\|PROT_WRITE\|PROT_EXEC,
MAP_PRIVATE\|MAP_FIXED\|MAP_ANONYMOUS, -1, 0) = 0x55f684400000
1682 madvise(0x55f684400000, 2097152, MADV_HUGEPAGE) = -1 EINVAL (Invalid argument)
```
Even though calls to MAP_HUGETLB fail on stock systems (PHP8.1 on Ubuntu 20/22, AlmaLinux, old
CL6/7), they never seem to throw a warning in PHP during startup. I suppose checking to see if
madvise() fails, it should warn the user that THP is probably not functioning correctly?
Reproduction steps;
- PHP 8.1 + opcache
- Any Linux machine with THP disabled by default (check for "CONFIG_TRANSPARENT_HUGEPAGE is not
set" in /boot/config* to confirm)
- Make sure hugepages is enabled in opcache.ini
### PHP Version
PHP 8.1
### Operating System
Ubuntu 22.04