RFR: 8337217: Port VirtualMemoryTracker to use VMATree
Johan Sjölen
jsjolen at openjdk.org
Fri Nov 8 10:51:53 UTC 2024
On Mon, 14 Oct 2024 13:22:54 GMT, Afshin Zafari <azafari at openjdk.org> wrote:
> > Yes, but this code is incorrect. So we should have a test detecting this, but we do not, and so this is under-tested.
>
> This code finds committed regions within a Stack region if they are not accounted by NMT so far, IIUC. By running this incorrect code, we may get some extra committed size in NMT reports. This is hard in NMT tests to catch. How can we expect a NMT test to measure X bytes of committed stack and not Y bytes? We need to know exactly the X and/or Y to test this code.
I think it's actually the opposite: None of the committed regions will survive after this function.
This is one of those times when having the ability to create new instances of NMT makes things very nice for testing.
You simply do something like this (pseudo-code):
```c++
void test_it() {
VMT vmt;
size_t sz = 4096 * 16;
void* mem = os::reserve_memory(sz, mtThreadStack);
os::commit_memory(mem + 4096*2, 4096);
vmt.reserve(mem, sz, mtThreadStack);
vmt.walk_thread_stacks();
EXPECT_EQ(4096, sum_committed_of(vmt, mtThreadStack));
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20425#issuecomment-2412008724
More information about the core-libs-dev
mailing list