RFR: 8297718: Make NMT free:ing protocol more granular [v2]

Thomas Stuefe stuefe at openjdk.org
Wed Dec 7 11:10:16 UTC 2022


On Thu, 1 Dec 2022 13:59:25 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> This PR avoids the double registration of a failed `os::realloc` in NMT by doing the NMT free protocol steps inline (asserting block integrity, marking of MallocHeader, and registrering results to statistics). This is done by creating a new struct `FreePackage` which includes all of the necessary data for registrering results.
>> 
>> I also did some light refactoring which I think makes the protocol clearer, these are done piece wise as separate commits for the reviewers' convenience.
>
> Johan Sjölen has updated the pull request incrementally with 10 additional commits since the last revision:
> 
>  - Add test that asserts block integrity after revival
>  - Make MallocHeader NONCOPYABLE
>  - Rest of it
>  - Adjust comments
>  - Put back comment, suitably rewritten
>  - Note reversibility of mark_block_as_dead
>  - Rename record_free_block to record_free
>  - Rename record_free to deaccount
>  - Move FreePackage into MallocHeader and rename
>  - Rename as revive, delete copy ctr

Good.

src/hotspot/share/runtime/os.cpp line 726:

> 724: 
> 725:     // the real realloc
> 726:     ALLOW_C_FUNCTION(::realloc, void* const new_outer_ptr = ::realloc((void*)header, new_outer_size);)

The cast is not necessary.

src/hotspot/share/services/memTracker.hpp line 109:

> 107:     // Never turned on
> 108:     assert(memblock != NULL, "caller should handle NULL");
> 109:     if(!enabled()) {

space?

src/hotspot/share/services/memTracker.hpp line 115:

> 113:   }
> 114:   static inline void deaccount(MallocHeader::FreeInfo free_info) {
> 115:     assert(enabled(), "NMT must be enabled");

breaks protocol for MemTracker (checks enabled) but I think this is here okay. To get a free_info in the first place, we must have had NMT enabled.

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

Marked as reviewed by stuefe (Reviewer).

PR: https://git.openjdk.org/jdk/pull/11390


More information about the hotspot-runtime-dev mailing list