RFR: 8315923: pretouch_memory by atomic-add-0 fragments huge pages unexpectedly [v21]

Liming Liu duke at openjdk.org
Thu Jan 11 05:26:29 UTC 2024


On Thu, 28 Dec 2023 09:26:19 GMT, Liming Liu <duke at openjdk.org> wrote:

>> As described at [JDK-8315923](https://bugs.openjdk.org/browse/JDK-8315923), this patch uses madvise with MADV_POPULATE_WRITE to pretouch memory when supported (since kernel 5.14).
>> 
>> Ran the newly added jtreg test on 64c Neoverse-N1 machines with kernel 4.18, 5.13 and 6.1, and observed that transparent huge pages formed right after pretouch on kernel 6.1. Recorded the time spent on the test in *seconds* with `VERBOSE=time` as the table below, and got that the patch takes improvements when the system call is supported, while does not hurt if not supported:
>> 
>> <table>
>>   <tr>
>>     <th>Kernel</th>
>>     <th colspan="2"><tt>-XX:-TransparentHugePages</tt></th>
>>     <th colspan="2"><tt>-XX:+TransparentHugePages</tt></th>
>>   </tr>
>>   <tr><td></td><td>Unpatched</td><td>Patched</td><td>Unpatched</td><td>Patched</td></tr>
>>   <tr><td>4.18</td><td>11.30</td><td>11.30</td><td>0.25</td><td>0.25</td></tr>
>>   <tr><td>5.13</td><td>0.22</td><td>0.22</td><td>3.42</td><td>3.42</td></tr>
>>   <tr><td>6.1</td><td>0.27</td><td>0.33</td><td>3.54</td><td>0.33</td></tr>
>> </table>
>
> Liming Liu has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Use pthread instead

Let me restrict the discussion to the case that uses THP on Linux 5.14 or above, as the patch actually does not make changes in other cases.

Personally, I don't see the correctness issue about concurrently using and madvising memory, and added a gtest case to cover it. The uses of pretouch do not have to be together with -Xmx = -Xms. Just mutators currently wait pretouch to be finished, and it takes time. This patch actually makes pretouch faster. The shredding issue can also be mitigated for the expanded memory after making using and pretouching concurrent, as 2MB huge pages have a good chance of being integral if them are not accessed by mutators yet, while pretouching via atomic-add makes all of the expanded memory shredded.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15781#issuecomment-1886263866


More information about the hotspot-runtime-dev mailing list