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

David Holmes dholmes at openjdk.java.net
Thu Jul 15 07:35:28 UTC 2021


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

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

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

Changes: https://git.openjdk.java.net/jdk/pull/4788/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4788&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8268773
  Stats: 76 lines in 8 files changed: 46 ins; 0 del; 30 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4788.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4788/head:pull/4788

PR: https://git.openjdk.java.net/jdk/pull/4788


More information about the hotspot-runtime-dev mailing list