RFR: 8338929: Make Metaspace::deallocate space-aware

Coleen Phillimore coleenp at openjdk.org
Mon Aug 26 12:30:06 UTC 2024


On Sat, 24 Aug 2024 07:18:09 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> For ucoming Lilliput changes, as well as to simplify [JDK-8338526](https://bugs.openjdk.org/browse/JDK-8338526), we should make Metaspace::deallocate space-aware (as in, instead of having to tell it where the pointed-to block resides, it should know it on its own). 
> 
> As of now, callers need to tell the function of the deallocated block is in class space or in non-class metaspace. That is unnecessary and won't work for TinyCP. The deallocation function can do this better on itself by doing a range check on the class space range.

Thank you for doing this and I agree in principle but now I'm confused about these spaces.

src/hotspot/share/memory/metaspace.hpp line 123:

> 121:     return is_in_shared_metaspace(ptr) || // in cds
> 122:            is_in_class_space(ptr) ||      // in class space
> 123:            is_in_nonclass_metaspace(ptr); // in one of the non-class regions?

So the shared_metaspace region, which is the memory for CDS is *not* in class_space?  I suppose for deallocate this doesn't matter since this memory is never deallocated.

src/hotspot/share/memory/metaspace.hpp line 134:

> 132:   // Returns true if pointer points into one of the metaspace regions, or
> 133:   // into the class space.
> 134:   static bool is_in_shared_metaspace(const void* ptr);

This comment doesn't make sense to me.  Isn't this just pointing to the CDS region, which includes class and non-class data?  But is this in the range of class space?

src/hotspot/share/memory/metaspace.hpp line 140:

> 138: 
> 139:   // Returns true if ptr points into class space, false if it doesn't or if
> 140:   // there is no class space.

Add a comment that the class space is one contiguous allocated region, which is why this pointer compare is correct, unlike the non-class metaspace.

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

PR Review: https://git.openjdk.org/jdk/pull/20701#pullrequestreview-2260549387
PR Review Comment: https://git.openjdk.org/jdk/pull/20701#discussion_r1731164326
PR Review Comment: https://git.openjdk.org/jdk/pull/20701#discussion_r1731166268
PR Review Comment: https://git.openjdk.org/jdk/pull/20701#discussion_r1731167473


More information about the hotspot-runtime-dev mailing list