On Thu, 22 Oct 2026 19:41:58 GMT, Roman Kennke <[email protected]> wrote:

>> Implements the native profiler hook for unbiased stack-traces, as described 
>> in [JEP draft: Native Profiler Hook for Unbiased Stack Traces 
>> (Experimental)](https://openjdk.org/jeps/8380294).
>> 
>> New JVMTI extension function: `RequestStackTrace(jvmtiEnv*, jthread*, void* 
>> ucontext, jlong user_data)` - async-signal-safe request for a stack trace. 
>> For the current thread, `ucontext` may be `nullptr` or the signal-handler 
>> `ucontext`. For another thread, the thread must be suspended for the 
>> duration of the call and `ucontext` must be captured during that suspension; 
>> otherwise the VM may crash. Returns `JVMTI_ERROR_NONE`, 
>> `JVMTI_ERROR_INVALID_THREAD`, or `JVMTI_ERROR_NOT_AVAILABLE`. Requests may 
>> be silently dropped (queue full, wrong thread state, rate-limited).
>> 
>> New experimental JFR event `StackTraceRequest` with fields `stackTrace`, 
>> `eventThread`, `userData`, `failed`, `biased`. Enabled in `profile.jfc`, not 
>> in `default.jfc` (the rate is controlled by the external agent, so 
>> default-on would expose users to unbounded overhead).
>> 
>> The machinery gets enabled/disabled whenever the event `StackTraceRequest` 
>> gets enabled/disabled.
>> 
>> Refactoring: The stack-walker request machinery from JEP 509 (CPU-time 
>> profiler) is generalized into a callback-based API 
>> (`JfrStackWalkerCallback`) used by both the CPU-time profiler and the new 
>> JVMTI hook. Shared pieces: the per-thread signal-safe request queue, the 
>> enqueue/dequeue lock state machine, and the native stack-walker thread that 
>> processes requests for in-native threads. Two callback implementations 
>> remain: one for CPUTimeSample/empty/lost events, one for StackTraceRequest.
>> 
>> Non-goals (per the JEP): Native frames are not reported; this is a follow-up.
>> 
>> Platform support: Linux and MacOS, or more generally POSIX. Windows support 
>> can be a follow-up, if ucontext is interpreted as WPA context.
>> 
>> Testing:
>> 
>> Several tests have been added that verify the new functionality.
>> 
>>  - [x] jdk_jfr
>>  - [x] serviceability/jvmti
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Roman Kennke has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Fix init/teardown ordering

src/hotspot/share/jfr/periodic/sampling/jfrStackWalker.inline.hpp line 39:

> 37: void JfrStackWalker::check_and_process_requests(JavaThread* jt) {
> 38:   JfrStackWalkerThreadLocal& tl = jt->stackwalker_thread_local();
> 39:   // Protect agains re-entrant calls. This can happen when we are

typo: Protect against

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31059#discussion_r4353958795

Reply via email to