[ZGC] [aarch64] Unable to allocate heap for certain Linux kernel configurations

Christoph Göttschkes christoph.goettschkes at microdoc.com
Fri Aug 28 10:37:56 UTC 2020


Hi Stefan,

On 2020-08-28 11:38, Christoph Göttschkes wrote:
> Maybe there could be a mechanism which tries to allocate memory beyond 
> certain addresses to try and detect the number of bits available? On my 
> machine, for instance, the ZGC implementation tries to allocate memory 
> with different starting addresses, but always gets an address back which 
> is way smaller (because of the kernel limitations). Maybe, the ZGC 
> implementation could store this information (the number of bits in 
> addresses returned by mmap) and use this information to try and make 
> another loop, which tries to allocate the heap with a reduced number of 
> bits used for the addresses. This could also be a HotSpot option, to 
> speed things up during startup if one knows that the machine uses a 
> "weird" configuration.

I made a small prototype implementation of the idea I had, which 
introduces a new HotSpot option, which re-adjusts itself if allocation 
fails, due to not enough address bits available:

https://cr.openjdk.java.net/~cgo/8252500/prototype-webrev.00/

This isn't finished by any means. It is only implemented for aarch64 and 
even compilation might fail for other platforms.

On the two test devices I have, it works as expected. The one which has 
4 pagetable levels, the allocation succeeds right in the beginning. On 
the one with only 3 pagetable levels, the implementation first tries to 
allocate memory with too high addresses and then re-adjusts the 
available address bits and tries again. Configuring ZAddressBits low 
enough makes the allocation succeed right in the beginning.

Maybe the patch is generic enough to fix your problems as well?

-- Christoph



More information about the hotspot-gc-dev mailing list