RFR: 8312180: (bf) MappedMemoryUtils passes incorrect arguments to msync (aix)

Alan Bateman alanb at openjdk.org
Tue Jul 18 17:01:11 UTC 2023


On Tue, 18 Jul 2023 16:15:30 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>>> > what does Unsafe::pageSize return vs. sysconf(_SC_PAGESIZE)[?]
>>> 
>>> It boils down to [Dynamic Variable Page Sizes](https://www.ibm.com/docs/en/aix/7.2?topic=support-dynamic-variable-page-size), which is an AIX feature. The larger page size returned by Unsafe::pageSize is the system page size (by default 64 KiB). The page size required by msync (and returned by sysconf(_SC_PAGESIZE) is the fine-grained page size (by default 4 KiB).
>> 
>> A bit of background: At the start of the JVM port to AIX (before OpenJDK) we wanted to use 64 KB pages, but the "LargePage" semantics used by the JVM were too rigid and too badly abstracted to be usable. 
>> 
>> So we instead "fake" a system page size of 64 KB instead of 4 KB by, basically, letting `os::vm_page_size()` return 64 KB. This works surprisingly well in most cases due to some peculiarities of AIX memory management. The real 4 KB system page size is only observable in a select few corner cases, one of which is this msync coding.
>
>> A bit of background: At the start of the JVM port to AIX (before OpenJDK) we wanted to use 64 KB pages, but the "LargePage" semantics used by the JVM were too rigid and too badly abstracted to be usable.
>> 
>> So we instead "fake" a system page size of 64 KB instead of 4 KB by, basically, letting `os::vm_page_size()` return 64 KB. This works surprisingly well in most cases due to some peculiarities of AIX memory management. The real 4 KB system page size is only observable in a select few corner cases, one of which is this msync coding.
> 
> Does this mean that the injected value for Unsafe.PAGE_SIZE is 64k on AIX? Should it be changed to the real page size?

> @AlanBateman As a defense of our old coding: We did this long before OpenJDK existed, and at that time, there was no way to contribute code back to Sun. Today I may do things differently. But back then, we had to aim for a minimally invasive patch, and this lying-about-pagesize worked well. There may be hidden issues like this we have not discovered yet.

No problem, it's good to get the history and get this issue to the right place. I was initially concerned we were into a scenario where the page size configuration could change and thus impact the base address and offset for operations like load and force.

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

PR Comment: https://git.openjdk.org/jdk/pull/14904#issuecomment-1640604743


More information about the nio-dev mailing list