RFR: 8234930: Use MAP_JIT when allocating pages for code cache on macOS [v2]

Anton Kozlov akozlov at openjdk.java.net
Tue Oct 6 15:27:09 UTC 2020


On Tue, 29 Sep 2020 07:12:35 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

>> @tstuefe My patch to remove MAP_FIXED from the memory reservation path should make it possible to revert all the
>> os::reserve_memory changes in this patch.
>
>> @tstuefe My patch to remove MAP_FIXED from the memory reservation path should make it possible to revert all the
>> os::reserve_memory changes in this patch.
> 
> FWIW, I now understand that the motivation for the changes in os::reserve_memory is *not* that *it* uses MAP_FIXED.
> Instead the change there is done so that os::commit_memory doesn't have to mix mmap + MAP_FIXED + MAP_JIT. This is also
> the reason why os::uncommit_memory needs to be changed as well. So, ignore my comment above.

Hi @tstuefe,

Recent refactors interfered with the previous version of the patch, I found it is a bit simpler to start from scratch.
https://github.com/openjdk/jdk/pull/294/commits/f8664ca7dcc1cfdfb9a1f032035f2cde77048649 is a minimal patch that allows
MAP_JIT. I cannot see any way to simplify the interface now. Please tell me if I miss something. Also, `VirtualSpace`
now choose from `reserve_memory_with_fd` and anything that is used for reserve with exec.

What I found in the AIX implementation, the commit/uncommit are for memory previously reserved
https://github.com/openjdk/jdk/blob/master/src/hotspot/os/aix/os_aix.cpp#L2227. If we attribute reserved region with
exec, then uncommit can query bookkeeping info and get the type of memory.

>From options of internal bookkeeping info or an asking the system for the mmap flags, I prefer the first one. It is
faster and we can bookkeep only minimal info, like a list of executable regions. That should reduce the amount of data
and make a check for the type in commit/uncommit faster.

After looking around, it does look like every place where commit with exec is used, we know enough to use
reserve/uncommit with exec. Taking this to the extreme, I still think a specialized set of reserve/commit/uncommit for
executable regions would look natural. For example, commit with exec is used in less than five places. I'll do a little
research there.

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

PR: https://git.openjdk.java.net/jdk/pull/294


More information about the shenandoah-dev mailing list