RFR: 8352251: Implement JEP 518: JFR Cooperative Sampling [v23]
Markus Grönlund
mgronlun at openjdk.org
Thu May 15 22:05:56 UTC 2025
On Thu, 15 May 2025 22:02:01 GMT, Markus Grönlund <mgronlun at openjdk.org> wrote:
>> src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp line 1171:
>>
>>> 1169: // For asynchronous profiling to work correctly, we must remove the
>>> 1170: // activation frame _before_ we test the method return safepoint poll.
>>> 1171: // This is equivalent to how it is done for compiled frames.
>>
>> We also have the compiled native frame case where there is no poll after removing the frame. Aren’t we missing handling that case?
>
> Some subtleties are involved in SharedRuntime::generate_native_wrapper(). There are a few things to keep in mind there. First, the adapter is not part of the JIT code itself, it will not resolve to the nmethod, it will resolve to an AdapterStub. This is for the case where we take the CPU context directly. Some other aspects involved here are that the thread transitions to both thread in native and thread in native trans - during that time, the thread is ineligible for a Java sample. But, as is the case now, the thread transitions back to thread in Java, and there is still a valid ljf - so a sample could happen here, taking the ljf. Therefore, a poll needs to occur before issuing the return, or the reset ljf must happen before we return to Java, which is what I think I did for sampling accuracy. I will need to dig into that branch to find out.
Excellent observation, Patricio, thank you for pointing this out.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24296#discussion_r2092020111
More information about the hotspot-jfr-dev
mailing list