RFR: 8369469: Rdtsc: Remove potential races in Rdtsc::initialize [v3]
Axel Boldt-Christmas
aboldtch at openjdk.org
Mon Oct 13 08:11:44 UTC 2025
> The whole chain of Rdtsc uses static block scope variables which are guaranteed to be constructed only once (implements some sort of double checked locking).
> However the current implementation does not do this correctly in all places, where it does:
>
> static bool initialized = false;
> if (!initialized) {
> ...
> initialized = true;
> }
>
> It should do
>
> static bool initialized = initialize_impl(); // Do the logic inside a function call
>
> to guarantee that initialize is only called once.
>
> We have observed this from some GC threads if we start using Ticks to early.
>
> The suggested patch makes `Rdtsc::initialize` private an is only called from the `Rdtsc::enabled` which uses a static bock scoped variable to ensure the call once semantics. The property called from outside is now `Rdtsc::enabled`. Which is more true to what how it is used on all call sites.
Axel Boldt-Christmas has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
- Merge remote-tracking branch 'upstream_jdk/master' into JDK-8369469
- Fix typo
Co-authored-by: David Holmes <62092539+dholmes-ora at users.noreply.github.com>
- 8369469: Rdtsc: Remove potential races in Rdtsc::initialize
- 8369468: Rdtsc: Move getCPUIDBrandString_stub into VM_Version stub area
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/27712/files
- new: https://git.openjdk.org/jdk/pull/27712/files/d9524470..53db5867
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=27712&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=27712&range=01-02
Stats: 4447 lines in 119 files changed: 3167 ins; 903 del; 377 mod
Patch: https://git.openjdk.org/jdk/pull/27712.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/27712/head:pull/27712
PR: https://git.openjdk.org/jdk/pull/27712
More information about the hotspot-dev
mailing list