RFR: 8351661: NMT: VMATree should support separate call-stacks for reserve and commit operations [v2]

Johan Sjölen jsjolen at openjdk.org
Tue Mar 18 10:08:09 UTC 2025


On Tue, 18 Mar 2025 09:16:38 GMT, Afshin Zafari <azafari at openjdk.org> wrote:

> The cases and their result:
> 
> ```
> // (address, size, callstack) arguments
> 
> // x == invalid stack == not-filled
> 
> # Case 1
> tree.reserve(0, 100, s1);
> tree.commit(25, 25 , s2);
>     0       25         50         100
> --------  --------  --------  --------
> in   out  in   out  in   out  in   out 
> x    s1   s1   s2   s2   x    s1   x
> x    x    x    x    x    x     x   x
> 
> commit is not at start of the region.
> 
> # Case 2
> tree.reserve(0, 100, s1);
> tree.reserve(10, 10, s2);
>     0       10         20         100
> --------  --------  --------  --------
> in   out  in   out  in   out  in   out 
> x    s1   s1   s2   s2   x    s1   x
> x    x    x    x    x    x     x   x
> 
> # Case 3
> tree.commit(0, 100, s1);
>     0       100  
> --------  --------
> in   out  in   out
> x    s1   s1   x 
> x    x    x    x  
> 
> it is not acceptable to commit a region without reserving it.
> 
> # Case 4
> tree.commit(0, 100, s1);
> tree.reserve(0, 100, s2);
>     0       100  
> --------  --------
> in   out  in   out
> x    s2   s2   x 
> x    s1   s1   x  
> ```

Let's go backwards:

# Case 4

This should only have the reserved stack s2, not the committed stack s1. Reserving after committing is the same as uncommitting. In fact, that is how we define `uncommit`.

# Case 3
Committing without reserving is fine, and we must support it. This should be interpreted as reserving implicitly.

# Case 2

Oops, here I interpreted what I wrote incorrectly. Your results seem correct.

# Case 1

Aha, so here the inner region actually ignores the outer reserved region. That doesn't seem right, how are you supposed to know what the reserved call stack is?

Consider this:


tree.reserve(0, 100, s1);
tree.commit(50, 25, s2);
tree.commit(51, 5, s3);
tree.reserve(0, 50, s4);
tree.reserve(56, 100 - 56, s4);
produce_report();


How is the reporter supposed to know what the reserved stack is of the innermost region `[51, 56)`? It can't,because we've lost that information.

We need a better definition of what is supposed to happen in these cases.

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

PR Comment: https://git.openjdk.org/jdk/pull/24028#issuecomment-2732497643


More information about the hotspot-runtime-dev mailing list