eclipse-omr / omr

Eclipse OMR™ Cross platform components for building reliable, high performance language runtimes
http://www.eclipse.org/omr
Other
949 stars 396 forks source link

An extension of Memory Allocation interface #3943

Open dmitripivkine opened 5 years ago

dmitripivkine commented 5 years ago

There is a suggestion to add two new parameters to J9PortVmemParams:

An Abstract Page size is any power of two value. The Abstract Page has no relation to virtual memory allocation layout (physical page size, allocation ranges etc).

An Offset in Abstract Page is any value smaller then Abstract Page size.

Leadind part of memory range from Abstract Page Start to allocation bottom address as well as trailing part from allocation top address to Abstract Page End should not be allocated.

If Abstract Page size parameter is specified:

Current allocation loop logic for allocation direction bottom up looks like:

    J9PortVmemParams.startAddress = roundUp(physicalPageSize, J9PortVmemParams.startAddress);
    J9PortVmemParams.endAddress = roundDown(physicalPageSize, J9PortVmemParams.endAddress);
        requestedSize = roundUp(physicalPageSize, requestedSize);

    tryAddress = J9PortVmemParams.startAddress;
    while (tryAddress < J9PortVmemParams.endAddress) {
        if (_TryToAllocate_(tryAddress, requestedSize)) {
            /* allocation succeeds */
            break;
        }
        tryAddress += physicalPageSize;
    }

So for case if Abstract Page size is larger then physical page size and allocation direction is bottom up an allocation cycle would be:

    J9PortVmemParams.startAddress = roundUp(AbstractPageSize, J9PortVmemParams.startAddress);
    J9PortVmemParams.endAddress = roundDown(AbstractPageSize, J9PortVmemParams.endAddress);
        requestedSize = roundUp(physicalPageSize, requestedSize);
    if (physicalPageSize < AbstractPageSize) {
        OffsetInAbstractPage = roundDown(physicalPageSize, OffsetInAbstractPage);
    }

    tryAddress = J9PortVmemParams.startAddress + OffsetInAbstractPage;
    while (tryAddress < J9PortVmemParams.endAddress) {
        if (_TryToAllocate_(tryAddress, requestedSize)) {
            /* allocation succeeds */
            break;
        }
        tryAddress += AbstractPageSize;
    }

Current virtual memory allocation mechanism is a partial case of proposed extension with Abstract Page size equal physical page size and Offset 0 (except ZOS where multiple allocation attempts logic is not implemented yet).

The first platform needs this implementation is ZOS to simplify memory allocation control for Guarded Storage (GS). The Abstract Page size in this case might be selected to be equal to desired GS size, The notion of Abstract Page size and Offset would be enough to get memory allocation properly. In case if ZOS supports memory allocation hints (see https://github.com/eclipse/omr/pull/3923) we can do multiple attempts of memory allocation to get desired memory geometry. Otherwise memory can be allocated at any place (considering other J9PortVmemParams values) however requestedSize should be increased by Abstract Page size to make proper alignment possible. zLinux might require implementation to support GS properly as well.

Another application area for this feature for example might be speeding mmap() style allocation for small pages.

New parameters can be ignored in other platforms until implemented.

github-actions[bot] commented 4 years ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment on the issue or it will be closed in 60 days.