RFR: 8328944: NMT reports "unknown" memory
Gerard Ziemski
gziemski at openjdk.org
Wed Nov 13 22:21:12 UTC 2024
On Fri, 1 Nov 2024 20:44:50 GMT, Gerard Ziemski <gziemski at openjdk.org> wrote:
> We use mtNone value in several functions default parameters, which may show up in NMT reports.
>
> We address this, by removing the default value and forcing, where possible, for the callers to declare NMT tag that reflects the usage.
>
> Eventually the goal would be not to use mtNone anywhere, but we are not there quite yet.
>
> TODO: update copyrights.
>
> Testing: undergoing MARCH5 tier1-5 ...
Thank you very much everyone for feedback, and especially Thomas for so much details.
I'm working through the feedback, but have some thoughts on the subject of tags that I would like to share.
Here is how I would love to see NMT tags used:
- An object starts its life with "mtNone" tag. I probably would prefer to call it "mtUnset" or "mtNull", but "mtNone" is OK too.
- When the type is known at the allocation time, then use the corresponding tag and we are done.
- When the type is NOT known at the allocation time, then we set the tag to a new tag named "mtAllocated", "mtUnknown" or "mtTransition" or something like that. Later, when we know exactly who owns such tagged memory object, we set it to its final value.
This way we avoid the overloaded meaning of "mtNone" we have right now - either unset or truly unknown, or developer unfamiliar with NMT to know (or just plain too lazy) to propgate the tag value down.
In this fix I'm not trying to fix all of it, I'm just trying to fix the particular case in the issue and further clean up the code a bit to make it one step closer towards the ultimate goal - making sure that we tag memory (if it's reasonable to figure it out).
Last general thought on the tag transition from one value to another (not to be addressed here, but later), which we currently allow. It would be nice to have a general NMT API that controls how the tag values are allowed to change (similar to VirtualMemoryTracker::add_reserved_region). So instead of "mtAllocated" (as proposed) or "mtNone" (as we currently have), we would use a union of the subset of the tags, where the final value can be only one out of the union value (suddenly there is a use case here for tags to be "real" logical flags)
- Currently we have: "mtNone" (which currently means both unset and unknown) allowed to be changed to any tag.
- Partial fix, that I could do in this change: "mtNone" allowed to be changed to final tag, or to "mtAllocated". "mtAllocated" is allowed to be changed to any tag (this addresses the duality of "mtNone")
- Ultimate fix (to be addressed in a followup): "mtNone" allowed to be changed to final tag, or to "mtAllocated" (if final tag could be anything), or to some union tag (if the final tag is expected to be one of a subset). Union tag can only be changed to one member of the uinion members.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21843#issuecomment-2474934177
More information about the shenandoah-dev
mailing list