Skip to content

JIT buffer relocation fails with 64bit packing #11265

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
LoongT4o opened this issue May 18, 2023 · 0 comments
Closed

JIT buffer relocation fails with 64bit packing #11265

LoongT4o opened this issue May 18, 2023 · 0 comments

Comments

@LoongT4o
Copy link
Contributor

Description

JIT buffer relocation failed when WordPress workload is running with 64bit packing.

64bit packing places PHP and its libraries together at 64b memory space by using Ubuntu-native dynamic loader while executing php-fpm program, e.g. /lib64/ld-linux-x86-64.so.2 /usr/local/sbin/php-fpm
Here is the maps of php-fpm:

40000000-48000000 rw-s 00000000 00:0f 38927338  /anon_hugepage (deleted)
48000000-49400000 r-xs 08000000 00:0f 38927338  /anon_hugepage (deleted)
7ffff6dae000-7ffff6ea6000 r--p 00000000 08:02 11538447  /usr/local/sbin/php-fpm
7ffff6ea6000-7ffff6fae000 ---p 000f8000 08:02 11538447  /usr/local/sbin/php-fpm
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538447  /usr/local/sbin/php-fpm

We can see that the memory address distance between opcache/JIT buffer and PHP .text segment is greater than 4GB.
Actually, there is an available free segment between 49400000 and 7ffff6dae000 to place the JIT buffer to meet the 4GB distance requirement.

Patch #8890 's method is to traverse each free memory segment, and then verify whether the candidate at the beginning of the current segment meets the requirements (that is, from the end address of the last non-free memory segment). However, if the address range of the current free segment is large, the algorithm may fail to find candidates (the address of the second half of the current free segment may meet the 4GB requirement).

PHP Version

PHP 8.2

Operating System

Ubuntu22.04

LoongT4o added a commit to LoongT4o/php-src that referenced this issue May 18, 2023
Avoids missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue php#11265.

Signed-off-by: Long, Tao <[email protected]>
LoongT4o added a commit to LoongT4o/php-src that referenced this issue May 18, 2023
Avoids missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue php#11265.

Signed-off-by: Long, Tao <[email protected]>
LoongT4o added a commit to LoongT4o/php-src that referenced this issue May 22, 2023
Avoid missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue php#11265.

Signed-off-by: Long, Tao <[email protected]>
Signed-off-by: Wang, Xue <[email protected]>
LoongT4o added a commit to LoongT4o/php-src that referenced this issue May 23, 2023
Avoid missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue php#11265.

Signed-off-by: Long, Tao <[email protected]>
Signed-off-by: Wang, Xue <[email protected]>
LoongT4o added a commit to LoongT4o/php-src that referenced this issue May 23, 2023
Avoid missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue php#11265.

Signed-off-by: Long, Tao <[email protected]>
Signed-off-by: Wang, Xue <[email protected]>
LoongT4o added a commit to LoongT4o/php-src that referenced this issue May 23, 2023
Avoid missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue php#11265.

Signed-off-by: Long, Tao <[email protected]>
Signed-off-by: Wang, Xue <[email protected]>
LoongT4o added a commit to LoongT4o/php-src that referenced this issue May 23, 2023
Avoid missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue php#11265.

Signed-off-by: Long, Tao <[email protected]>
Signed-off-by: Dmitry Stogov <[email protected]>
dstogov pushed a commit that referenced this issue May 23, 2023
Avoid missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue #11265.

Signed-off-by: Long, Tao <[email protected]>
Signed-off-by: Dmitry Stogov <[email protected]>
arnaud-lb pushed a commit to arnaud-lb/php-src that referenced this issue Jul 3, 2024
Avoid missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue php#11265.

Signed-off-by: Long, Tao <[email protected]>
Signed-off-by: Dmitry Stogov <[email protected]>
arnaud-lb pushed a commit that referenced this issue Jul 22, 2024
Avoid missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue #11265.

Signed-off-by: Long, Tao <[email protected]>
Signed-off-by: Dmitry Stogov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants