JDK-8272807 : Permit use of memory concurrent with pretouch
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 18
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-08-22
  • Updated: 2024-08-13
  • Resolved: 2022-02-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 b10Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
os::pretouch_memory is called under various circumstances, to ensure the OS has actually mapped physical memory to the associated committed virtual memory range. It is implemented using a store to each page in the range. A load won't do, because some OS's initially map a write-protected shared zero page.

Because pretouching involves writes, it must be done before any use of the memory. That can stall useful work that could be using some pages while the complete range gets touched.

An alternative to a simple store is an atomic add of zero to a location in the page.  Performance testing suggests there isn't any noticeable difference between using ordinary stores and (relaxed) atomic add of zero to touch pages on either x64 or aarch64.  The page allocation swamps the cost of the atomic operation.


Comments
Changeset: 072e7b4d Author: Kim Barrett <kbarrett@openjdk.org> Date: 2022-02-09 06:53:09 +0000 URL: https://git.openjdk.java.net/jdk/commit/072e7b4da0449ab7c1ab1ba0cfbb3db233823e7c
09-02-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/7343 Date: 2022-02-04 10:47:18 +0000
04-02-2022

Use of volatile prevents the compiler from eliding the operation.
23-08-2021

I have to wonder, depending exactly on how this is expressed, whether a compiler/assembler might not just elide an addition of zero? Or even whether hardware might elide any associated store?
23-08-2021