<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:等线;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@等线";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
mso-ligatures:none;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">>> Is this a downstream-only patch specific to the Oracle Linux kernel?<o:p></o:p></p>
<p class="MsoNormal">Yes, I think so. <o:p></o:p></p>
<p class="MsoNormal">At linux-uek repo [1], it says that the uek6/u2 branch is for kernel v5.4 on Oracle Linux 7 and 8. Looking into the header file, we could see the definitions of 22/23, the commit is [2]. At the same time, Linux mainline’s max mode number
was 21 and did not have 22/23. I have an attached PDF describing the diffs with various kernels, mainline vs uek, see [3].
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">By the way, uek kernel v5.15 used numbers 24/25 [4] for these two customized modes which would generate another conflict with mainline since 5.18-rc1 and 6.1 where the same numbers got used. I would suggest that uek kernel should put customized
modes into a separate range, e.g., 100+, to avoid conflict. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[1] <a href="https://github.com/oracle/linux-uek/">https://github.com/oracle/linux-uek/</a><o:p></o:p></p>
<p class="MsoNormal">[2] <a href="https://github.com/oracle/linux-uek/commit/a91ae4fa327d8957e2f806420b8b835269b85bd4">
https://github.com/oracle/linux-uek/commit/a91ae4fa327d8957e2f806420b8b835269b85bd4</a><o:p></o:p></p>
<p class="MsoNormal">mm: introduce MADV_DOEXEC<o:p></o:p></p>
<p class="MsoNormal">madvise MADV_DOEXEC preserves a memory range across exec. Initially<o:p></o:p></p>
<p class="MsoNormal">only supported for non-executable, non-stack, anonymous memory.<o:p></o:p></p>
<p class="MsoNormal">MADV_DOEXEC is single-use and after exec madvise must done again to<o:p></o:p></p>
<p class="MsoNormal">preserve memory for a subsequent exec.<o:p></o:p></p>
<p class="MsoNormal">MADV_DONTEXEC reverts the effect of a previous MADV_DOEXEC call and<o:p></o:p></p>
<p class="MsoNormal">undoes the preservation of the range.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">#define MADV_DOEXEC 22 /* do inherit across exec */<o:p></o:p></p>
<p class="MsoNormal">#define MADV_DONTEXEC 23 /* don't inherit across exec */<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[3] <a href="https://bugs.openjdk.org/secure/attachment/108337/madvise_return_values.pdf">
https://bugs.openjdk.org/secure/attachment/108337/madvise_return_values.pdf</a>, at
<a href="https://bugs.openjdk.org/browse/JDK-8324776">https://bugs.openjdk.org/browse/JDK-8324776</a><o:p></o:p></p>
<p class="MsoNormal">[4] <a href="https://github.com/oracle/linux-uek/commit/4693c5d9d799eb4803c5afc781cc60e2b645e398">
https://github.com/oracle/linux-uek/commit/4693c5d9d799eb4803c5afc781cc60e2b645e398</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards, Patrick<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Thomas Stüfe <thomas.stuefe@gmail.com> <br>
<b>Sent:</b> Thursday, February 22, 2024 0:56<br>
<b>To:</b> Patrick Zhang OS <patrick@os.amperecomputing.com><br>
<b>Cc:</b> hotspot-dev developers <hotspot-dev@openjdk.java.net>; hotspot-gc-dev@openjdk.java.net<br>
<b>Subject:</b> Re: Question: 8324776: How to safely tell if MADV_POPULATE_WRITE is supported<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Hi,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I am trying to understand this better.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">MADV_POPULATE_READ and MADV_POPULATE_WRITE were added to mainline with<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">```<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> commit 4ca9b3859dac14bbef0c27d00667bb5b10917adb<br>
Author: David Hildenbrand <<a href="mailto:david@redhat.com">david@redhat.com</a>><br>
Date: Wed Jun 30 18:52:28 2021 -0700<br>
mm/madvise: introduce MADV_POPULATE_(READ|WRITE) to prefault page tables <o:p>
</o:p></p>
</div>
<div>
<p class="MsoNormal">```<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">and they used 22/23 as numerical identifier:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">```<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">+#define MADV_POPULATE_READ 22 /* populate (prefault) page tables readable */<br>
+#define MADV_POPULATE_WRITE 23 /* populate (prefault) page tables writable */<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">```<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">But I don't see a patch in mainline for MADV_DOEXEC. I do see a very lengthy RFR thread that seemed to end in patent disputes (?):<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://lore.kernel.org/all/1595869887-23307-1-git-send-email-anthony.yznaga@oracle.com/T/#u">https://lore.kernel.org/all/1595869887-23307-1-git-send-email-anthony.yznaga@oracle.com/T/#u</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Is this a downstream-only patch specific to the Oracle Linux kernel?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Cheers, Thomas<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, Feb 21, 2024 at 4:25 PM Patrick Zhang OS <<a href="mailto:patrick@os.amperecomputing.com">patrick@os.amperecomputing.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hi,
<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I have a question regarding the regression reported by [1] which was caused by the commit [2].<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">The root cause can be briefly described as: MADV_POPULATE_WRITE has been supported since Linux 5.14. It is suggested to call madvise(0, 0, advice) to tell if this madvise mode is
valid, which “will return zero iff advice is supported by the kernel and can be relied on to probe for support” [3]. However Oracle UEKR6 5.4.17 has a duplicate definition of the number 23: MADV_DONTEXEC [4]. As a result, the test passes on Linux 5.4 mainline,
while fails on UEK 5.4.17, because madvise(0, 0, 23) gives different return values. See details at [5].<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">It is a dilemma that how to fix so inside JVM. Thanks for any advice.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[1]
<a href="https://bugs.openjdk.org/browse/JDK-8324776" target="_blank">https://bugs.openjdk.org/browse/JDK-8324776</a> runtime/os/TestTransparentHugePageUsage.java fails with The usage of THP is not enough<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[2]
<a href="https://bugs.openjdk.org/browse/JDK-8315923" target="_blank">https://bugs.openjdk.org/browse/JDK-8315923</a> pretouch_memory by atomic-add-0 fragments huge pages unexpectedly<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[3]
<a href="https://www.man7.org/linux/man-pages/man2/madvise.2.html" target="_blank">
https://www.man7.org/linux/man-pages/man2/madvise.2.html</a><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[4]
<a href="https://yum.oracle.com/repo/OracleLinux/OL8/developer/UEKR6/aarch64/getPackageSource/kernel-uek-5.4.17-2136.327.2.el8uek.src.rpm" target="_blank">
https://yum.oracle.com/repo/OracleLinux/OL8/developer/UEKR6/aarch64/getPackageSource/kernel-uek-5.4.17-2136.327.2.el8uek.src.rpm</a>, linux-5.4.17/include/uapi/asm-generic/mman-common.h#L75<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[5]
<a href="https://bugs.openjdk.org/browse/JDK-8324776?focusedId=14651275&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14651275" target="_blank">
https://bugs.openjdk.org/browse/JDK-8324776?focusedId=14651275&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14651275</a>.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Regards<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Patrick<o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</body>
</html>