RFR: 8329109: Threads::print_on() tries to print CPU time for terminated GC threads
Richard Reingruber
rrich at openjdk.org
Thu Mar 28 16:46:35 UTC 2024
On Thu, 28 Mar 2024 16:27:34 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:
> > WatcherThread, NativeHeapTrimmerThread can also be terminated.
>
> I see.
>
> I notice that `Thread::print_on` contains `if (osthread() != nullptr) {` to skip some threads. Is it possible to expand this condition to skip zombie ones? (Or set `_osthread` to nullptr when a thread enters zombie state.)
A very simple alternative could be to check `thread->osthread()->get_state()` in [fast_cpu_time](https://github.com/openjdk/jdk/blame/7ac2f914aadf7fb12b7258e54efae959e15d6721/src/hotspot/os/linux/os_linux.cpp#L5170) and just return -1 if the thread isn't `INITIALIZED` yet or already `ZOMBIE`.
> > (Btw: G1CollectedHeap::stop() doesn't stop G1CollectedHeap::_cm. Likely an oversight)
>
> `_cm` is not a thread; it's the data structure used by `_cm_thread`. Therefore, it shouldn't/can't be stopped.
It has `_concurrent_workers` but even though they seem to work concurrently to the mutator they are just `WorkerThread` and not `ConcurrentGCThread`. Only the latter type of thread can be stopped.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18518#issuecomment-2025662304
More information about the hotspot-gc-dev
mailing list