RFR: 8255414: Ensure OS functions always report to NMT

David Holmes dholmes at openjdk.org
Mon Mar 6 23:20:13 UTC 2023


On Thu, 2 Mar 2023 14:05:14 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

> Hi,
> 
> This PR attempts to enforce the convention that:
> 
> 1. Public `os` functions report to NMT
> 2. `pd_` prefixed functions do not report to NMT
> 3. Public `os` functions call into `pd_`-prefixed functions to do the actual work.
> 
> This is a convention that has been only partially enforced, leading to some difficulties. For example, it's easy for double-accounting to NMT can occur if it's not clear what the `pd_`-prefixed functions do and do not do.

I don't like to see NMT being a reason to define special "rules" for how to string together shared and pd code.

AFAICS if you do the accounting at the top-level (as currently done for os::reserve_memory) then this PR trying to solve the problem that:

os -> pd -> os

does double accounting. So you are changing it to:

os -> pd -> pd

but in general to me that risks under-accounting.  So there is no general rule to apply here, each case has to be examined to see if it would double-account (and if so change it), or under-account (and if so change it).

A general rule that platform specific code always calls the os::xxx version of a method is a generally good rule to have (and we have made a lot of changes in the past few years to have the pd code call back to the potentially shared os code). To do otherwise requires detailed knowledge of what the os version does and that it is okay to by-pass it; but if the os version is later changed then it might become wrong to bypass it.

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

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


More information about the hotspot-runtime-dev mailing list