Skip to content

Fix opcache.huge_code_pages #19379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

arnaud-lb
Copy link
Member

@arnaud-lb arnaud-lb commented Aug 5, 2025

Building opcache into the main binary breaks opcache.huge_code_pages, as we were relying on the fact that accel_remap_huge_pages() is not in the same mapping as the main text segment.

This is a possible fix, using mremap() to replace the text segment "without downtime".

A similar approach is used in https://chromium.googlesource.com/chromium/src/+/66.0.3359.158/chromeos/hugepage_text/hugepage_text.cc#120 and https://github.com/facebook/hhvm/blob/37915e288b70a47219e17956ca7cc019e031a582/hphp/runtime/base/program-functions.cpp#L866.

A possible alternative would be to exclude accel_remap_huge_pages() from the [start,start+size] range. We can do that by forcing the function into a separate segment, aligned to 2MiB, so it won't overlap with .text. This approach is used in https://github.com/intel/iodlr/blob/676bb7dec378d561e4d900fbdaed6ce8dbe449a1/large_page-c/large_page.c#L260.

Edit: FreeBSD does not have mremap() :( I will try the intel approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant