RFR: 8300732: Whitebox functions for Metaspace test should use byte size

Thomas Stuefe stuefe at openjdk.org
Thu Jul 11 07:38:57 UTC 2024


On Thu, 4 Jul 2024 15:18:29 GMT, Sonia Zaldana Calles <szaldana at openjdk.org> wrote:

> Hi all, 
> 
> This PR addresses [8300732](https://bugs.openjdk.org/browse/JDK-8300732) switching Whitebox Metaspace test functions to use bytes as opposed to words. 
> 
> Testing: 
> - [x] `test/hotspot/jtreg/runtime/Metaspace` tests pass. 
> 
> Thanks, 
> Sonia

It looks cautiously okay. Small nits remain.

Please make sure the tests pass for both 64-bit and 32-bit (to test 32-build, simplest way is to build on a x64 linux as normal, but to specify --with-target-bits=32 when configuring).

src/hotspot/share/prims/whitebox.cpp line 1769:

> 1767: 
> 1768: WB_ENTRY(jlong, WB_AllocateFromMetaspaceTestArena(JNIEnv* env, jobject wb, jlong arena, jlong size))
> 1769:   if (size % BytesPerWord != 0) {

Just assert `is_aligned(size, BytesPerWord) `

test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestContext.java line 232:

> 230:         //
> 231:         long expectedMaxCommitted = usageMeasured;
> 232:         expectedMaxCommitted += Settings.ROOT_CHUNK_WORD_SIZE;

Needs scaling up by BytesPerWord now

test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocationMT1.java line 98:

> 96: 
> 97:         final long wordSize = Settings.WORD_SIZE;
> 98:         final long testAllocationCeiling = 1024 * 1024 * 8 * wordSize; // 8m words = 64M on 64bit

Here, and in other places where I hardcode expected memory values: don't scale by size, just hardcode now the real byte values. E.g. here, use 1024 * 1024 * 64. 

If possible, put a "KB" and "MB" define somewhere. Or even better, copy the "Unit" enum I added to TestTrimNative. Would be cool to have that somewhere central.

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

Changes requested by stuefe (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20039#pullrequestreview-2171122397
PR Review Comment: https://git.openjdk.org/jdk/pull/20039#discussion_r1673536814
PR Review Comment: https://git.openjdk.org/jdk/pull/20039#discussion_r1673538960
PR Review Comment: https://git.openjdk.org/jdk/pull/20039#discussion_r1673547131


More information about the hotspot-dev mailing list