Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRIU: Blocking identity operations in single thread mode #14584

Open
tajila opened this issue Feb 23, 2022 · 1 comment
Open

CRIU: Blocking identity operations in single thread mode #14584

tajila opened this issue Feb 23, 2022 · 1 comment
Assignees
Labels
beta Used to track items that will be included in a feature beta release comp:vm criu Used to track CRIU snapshot related work

Comments

@tajila
Copy link
Contributor

tajila commented Feb 23, 2022

When running in single thread mode certain operations may cause a deadlock. The following are the cases where deadlocks may occur.

  1. Contended monitor enters
  • If the JVM attempts to acquire a lock that is held by another application thread, this would cause a deadlock since in this mode only a single application thread can be active.
  • In this mode the JVM will throw an exception for any contended monitor acquisition, either by bytecode (monitorEnter) or by JNI (MonitorEnter) or java.util.concurrent.locks.Locks.
  • In this mode we will also throw for Thread.join()
  1. Terminal operations
  • Some operations force the thread to block and require another thread to enable resumption. Given that only single thread can be run at a time this would cause a deadlock
  • An internal list of known methods that exhibit this behaviour will be created. Examples are sun.misc.Unsafe.park(), java.lang.Thread.suspend.
  • Upon entry to these methods the JVM will throw an exception
  1. Potentially terminal operations
  • Some operations that rely on external resources (sockets, file handles, etc.) may exhibit terminally blocking behaviour if there is a failure in the external system. These cases are addressed by the use of the timeout thread.
  • Launch timeout thread that will interupt Java hooks if it exceeds a certain threshold
  1. Notify
  • Notify potentially transfers control from from the calling thread to the another that is waiting on it. Under normal circumstances it would be acceptable to send notify() and release the lock, then attempt to re-acquire it at another time. However, in single thread mode this will trigger a deadlock.
  • The JVM will delay all notify operations until the end of the single thread phase
  1. Temporary blocking operations
  • Some operations will block temporarily
  • Thread.onSpinWait(), yield(), this should be a no-op in single thread mode
@tajila tajila added comp:vm criu Used to track CRIU snapshot related work beta Used to track items that will be included in a feature beta release labels Feb 23, 2022
@tajila
Copy link
Contributor Author

tajila commented Feb 23, 2022

@JasonFengJ9 in the short term we can focus on contended monitor enters.

tajila added a commit to tajila/openj9 that referenced this issue Mar 18, 2022
This PR delays notify/notifyAll operations by intercepting the
Object.notify* INLs and saving the instances and operations to a queue.
These instances must be saved as global JNI refs as we cannot save them
in localref storage and disallowing a GC is not feasible. At the end of
the single thread phase all the operations will be executed by the
checkpointing thread.

See eclipse-openj9#14584

Handles case 4) Notify

Signed-off-by: Tobi Ajila <atobia@ca.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Used to track items that will be included in a feature beta release comp:vm criu Used to track CRIU snapshot related work
Projects
None yet
Development

No branches or pull requests

2 participants