RFR: 8342818: Implement JEP 509: JFR CPU-Time Profiling [v5]

Johannes Bechberger jbechberger at openjdk.org
Mon May 26 08:33:12 UTC 2025


On Mon, 26 May 2025 08:18:19 GMT, Markus Grönlund <mgronlun at openjdk.org> wrote:

>> 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).

Yes, but it might be an indeterminate time between entering and exiting the native thread state. So I need to walk them in between. Your sampler implementation also walks threads in native state.

>> 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.

Ok, then I need my check. The check ensures that I only walk stacks that have the same top Java frame as the current frame (which is by design related to a stack trace in native). I don't want to walk non-native thread state stack traces here.

This is implemented to ensure that we also sample threads while they are in a long native period.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25302#discussion_r2106829651
PR Review Comment: https://git.openjdk.org/jdk/pull/25302#discussion_r2106825442


More information about the hotspot-jfr-dev mailing list