I've got this error while running a PHP command-line script on a freshly installed server:

PHP Warning: Zend OPcache huge_code_pages: madvise(HUGEPAGE) failed: Invalid argument

The server is running CentOS 7.3, with PHP 7.1.4 from the remi repository.

According to this thread on remi forum, and this thread on plesk.com, the solution is to disable huge_code_pages in php-opcache.ini:


However, Remi said that this problem should only occur on CentOS 6, not CentOS 7.

Before I disable huge_code_pages for good, is there a solution to make it work?

  • Check if the kernel was compiled with CONFIG_TRANSPARENT_HUGEPAGE. The config file should be in /boot/config-$(uname -r) (at least according to folks on Serverfault; I don't have a CentOS 7.3 system to check). – derobert May 5 '17 at 16:06
  • There is no config file matching my exact kernel version, for some reason. However, all config files present (different minor versions) have CONFIG_TRANSPARENT_HUGEPAGE=y. – Benjamin May 5 '17 at 18:19
  • Are you sure you kernel came from CentOS 7.3 (and isn't, e.g., something you built yourself)? Odd it doesn't include a config file. – derobert May 5 '17 at 18:31
  • Actually I'm using the OVH kernel, and it may be the cause of my issues. I've just asked a question on unix.stackexchange to know what the OVH kernel brings that the default kernel doesn't, to maybe revert back to the default kernel! – Benjamin May 5 '17 at 18:41
  • ftp.ovh.net/made-in-ovh/bzImage/latest-production has config files, and they show (in the few I checked) # CONFIG_TRANSPARENT_HUGEPAGE is not set ... so that's definitely your problem. I'll add an answer... – derobert May 5 '17 at 18:45

The kernel from OVH you're using, according to an OVH config file, does not set CONFIG_TRANSPARENT_HUGEPAGE=y. Your kernel thus doesn't support transparent huge pages, and thus madvise(HUGEPAGE) fails with an invalid argument error.

If you want to use transparent huge pages, you'll need to use a kernel which supports them—either by switching to the CentOS 7.3 kernel or by building your own based on the OVH one.

I suggest benchmarking to see if transparent huge pages bring any performance benefit under your workload.

As a side note, you need to make sure your kernels get upgraded—updates often contain important security fixes. Not installing them (and rebooting) will often leave your system subject to local (and sometimes even remote) root exploit.

  • Thank you for investigating this. I could very well get away with it by disabling opcache.huge_code_pages, as I have yet to see if it makes a relevant difference. However, I'm now more concerned indeed about the auto-update feature missing with the OVH kernel! – Benjamin May 5 '17 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.