RFR: 8342818: Implement JEP 509: JFR CPU-Time Profiling [v5]
Markus Grönlund
mgronlun at openjdk.org
Mon May 26 08:24:36 UTC 2025
On Mon, 26 May 2025 06:32:03 GMT, Johannes Bechberger <jbechberger at openjdk.org> wrote:
>> src/hotspot/share/jfr/periodic/sampling/jfrCPUTimeThreadSampler.cpp line 200:
>>
>>> 198: void sample_thread(JfrSampleRequest& request, void* ucontext, JavaThread* jt, JfrThreadLocal* tl);
>>> 199:
>>> 200: // sample all marked threads out of safepoint
>>
>> What is meant by "out of safepoint"?
>
> Stack walking that occurs not at a safepoint, but during longer periods of a thread being in native. We can't walk the stack directly when we're in native, as we can't properly walk stacks in signal handlers. So we defer this to a separate thread.
A thread in native is still stackwalked at a safe location, a safepoint code position.
It's guaranteed by the last java frame (ljf).
>> src/hotspot/share/jfr/periodic/sampling/jfrCPUTimeThreadSampler.cpp line 373:
>>
>>> 371: }
>>> 372: }
>>> 373: assert(first_index == 0, "invariant");
>>
>> How is this possible?
>
> Because we have a safepoint before the thread goes into native (as far as I understand). I'll remove the code above, because it is therefore not needed.
There is no safepoint when a thread goes from Java to native.
It's done on the way back.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25302#discussion_r2106808431
PR Review Comment: https://git.openjdk.org/jdk/pull/25302#discussion_r2106814829
More information about the hotspot-jfr-dev
mailing list