RFR: 8221785: Let possibly_parallel_threads_do cover the same threads as threads_do
Coleen Phillimore
coleenp at openjdk.org
Thu Jan 26 14:05:19 UTC 2023
On Wed, 25 Jan 2023 15:26:50 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:
> Hi all,
>
> can I have reviews for this change that makes `Threads::possibly_parallel_threads_do` iterate over the same set of threads as `threads_do` to have parity? I.e. over all java and non-java threads.
>
> Originally this CR has been created to make a new method that keeps iterating only over java threads and the VM thread, but it's a bit weird to have both variants as the overhead of the extra threads is negligible and otherwise just confusing.
>
> So I made `Threads::possibly_parallel_threads_do` iterate over all threads; all uses support that afaict, also all uses correctly change the claim token (mostly in the enclosing `StrongRootsScope`).
>
> This allows some minimally better hiding of the token mechanism.
>
> One other reason for not doing this in the first place (as in [JDK-8221102](https://bugs.openjdk.org/browse/JDK-8221102), or as discussed [here](https://mail.openjdk.org/pipermail/hotspot-dev/2019-April/037541.html)) has been the fear that there would be a problem with threads being created during iteration and the (common) call to 'Threads::assert_all_threads_claimed`. However all calls so far are during a safepoint, and none seem to create new threads. I suggest to defer looking at this problem when it is important.
>
> Moreover I need that functionality is required for (JDK-8211104)[https://bugs.openjdk.org/browse/JDK-8211104]. :)
>
> Testing: tier1-4, gha
>
> Thanks,
> Thomas
Thank you for picking this up.
src/hotspot/share/runtime/threads.cpp line 267:
> 265: if (current->claim_threads_do(is_par, claim_token)) {
> 266: tc->do_thread(current);
> 267: }
If I understand correctly, if this is only OK in a safepoint, can you add the safepoint assert here?
-------------
Marked as reviewed by coleenp (Reviewer).
PR: https://git.openjdk.org/jdk/pull/12201
More information about the shenandoah-dev
mailing list