RFR: 8268773: Improvements related to: Failed to start thread - pthread_create failed (EAGAIN)

David Holmes david.holmes at oracle.com
Thu Jul 15 12:44:39 UTC 2021


On 15/07/2021 9:33 pm, Thomas Stuefe wrote:
> On Thu, 15 Jul 2021 07:18:05 GMT, David Holmes <dholmes at openjdk.org> wrote:
> 
>> Take 2.
>>
>> Summary of changes:
>>
>> 1. If the low-level thread creation fails with EAGAIN we retry three times
>>
>> This is unlikely to be that helpful as the chances the needed resources have been freed since the previous attempt, are very low. But it doesn't hurt (it just delays reporting an error).
>>
>> 2. If the low-level thread creation fails we print a warning which now includes the thread name. And for symmetry we also report the name when creation is successful.
>>
>> For regular JavaThreads (and some system threads) the name is not set/available at the time of this logging so it reports "unknown thread" at this level.
>>
>> 3. For application Java threads JVM_StartThread now also produces a logging statement, if the native thread creation failed, that can show the actual name. Hence we will see e.g.:
>>
>> [1.068s][warning][os,thread] Failed to start thread "Unknown thread" - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
>> [1.068s][warning][os,thread] Failed to start the native thread for java.lang.Thread "Thread-3581"
>>
>> I didn't include a new logging statement for successful thread creation, just to show the name, as it seemed unnecessary. But that could be added if requested.
>>
>> 4. I had to adjust the notion of `is_protected_JavaThread` to account for a newly created but unstarted JavaThread.
>>
>> 5. One test of Java thread logging needed adjusting to account for the name now appearing.
>>
>> Testing:
>>    - manual checking via thread exhaustion test
>>    - tiers 1-3
>>
>> Thanks,
>> David
> 
> This looks good.

Thanks for the review Thomas!

David
-----

> -------------
> 
> Marked as reviewed by stuefe (Reviewer).
> 
> PR: https://git.openjdk.java.net/jdk/pull/4788
> 


More information about the hotspot-runtime-dev mailing list