Remove SOE avoidance in Mutex
diff --git a/common/kotlinx-coroutines-core-common/src/sync/Mutex.kt b/common/kotlinx-coroutines-core-common/src/sync/Mutex.kt
index e2f61c9..18b4229 100644
--- a/common/kotlinx-coroutines-core-common/src/sync/Mutex.kt
+++ b/common/kotlinx-coroutines-core-common/src/sync/Mutex.kt
@@ -119,8 +119,6 @@
 private val SELECT_SUCCESS = Symbol("SELECT_SUCCESS")
 private val LOCKED = Symbol("LOCKED")
 private val UNLOCKED = Symbol("UNLOCKED")
-private val RESUME_QUIESCENT = Symbol("RESUME_QUIESCENT")
-private val RESUME_ACTIVE = Symbol("RESUME_ACTIVE")
 
 private val EmptyLocked = Empty(LOCKED)
 private val EmptyUnlocked = Empty(UNLOCKED)
@@ -136,9 +134,6 @@
     // shared objects while we have no waiters
     private val _state = atomic<Any?>(if (locked) EmptyLocked else EmptyUnlocked)
 
-    // resumeNext is: RESUME_QUIESCENT | RESUME_ACTIVE | ResumeReq
-    private val _resumeNext = atomic<Any>(RESUME_QUIESCENT)
-
     public override val isLocked: Boolean get() {
         _state.loop { state ->
             when (state) {
@@ -332,16 +327,8 @@
                     } else {
                         val token = (waiter as LockWaiter).tryResumeLockWaiter()
                         if (token != null) {
-                            // successfully resumed waiter that now is holding the lock
-                            // we must immediately transfer ownership to the next waiter, because this coroutine
-                            // might try to lock it again after unlock returns do to StackOverflow avoidance code
-                            // and its attempts to take a lock must be queued.
                             state.owner = waiter.owner ?: LOCKED
-                            // StackOverflow avoidance code
-                            if (startResumeNext(waiter, token)) {
-                                waiter.completeResumeLockWaiter(token)
-                                finishResumeNext()
-                            }
+                            waiter.completeResumeLockWaiter(token)
                             return
                         }
                     }
@@ -351,43 +338,6 @@
         }
     }
 
-    private class ResumeReq(
-        @JvmField val waiter: LockWaiter,
-        @JvmField val token: Any
-    )
-
-    private fun startResumeNext(waiter: LockWaiter, token: Any): Boolean {
-        _resumeNext.loop { resumeNext ->
-            when {
-                resumeNext === RESUME_QUIESCENT -> {
-                    // this is never concurrent, because only one thread is holding mutex and trying to resume
-                    // next waiter, so no need to CAS here
-                    _resumeNext.value = RESUME_ACTIVE
-                    return true
-                }
-                resumeNext === RESUME_ACTIVE ->
-                    if (_resumeNext.compareAndSet(resumeNext, ResumeReq(waiter, token))) return false
-                else -> error("Cannot happen")
-            }
-        }
-    }
-
-    private fun finishResumeNext() {
-        // also a resumption loop to fulfill requests of inner resume invokes
-        _resumeNext.loop { resumeNext ->
-            when {
-                resumeNext === RESUME_ACTIVE ->
-                    if (_resumeNext.compareAndSet(resumeNext, RESUME_QUIESCENT)) return
-                resumeNext is ResumeReq -> {
-                    // this is never concurrently, only one thread is finishing, so no need to CAS here
-                    _resumeNext.value = RESUME_ACTIVE
-                    resumeNext.waiter.completeResumeLockWaiter(resumeNext.token)
-                }
-                else -> error("Cannot happen")
-            }
-        }
-    }
-
     override fun toString(): String {
         _state.loop { state ->
             when (state) {