@@ -2108,15 +2108,36 @@ auto& mmContainer = getMMContainer(tid, pid, cid);
21082108 XDCHECK (res == ReleaseRes::kReleased );
21092109 } else {
21102110 // we failed to allocate a new item, this item is no longer moving
2111- auto ref = unmarkMovingAndWakeUpWaiters (* candidate, {} );
2111+ auto ref = candidate-> unmarkMoving ( );
21122112 if (UNLIKELY (ref == 0 )) {
2113+ wakeUpWaiters (*candidate,{});
21132114 const auto res =
21142115 releaseBackToAllocator (*candidate,
21152116 RemoveContext::kNormal , false );
21162117 XDCHECK (res == ReleaseRes::kReleased );
2118+ } else if (candidate->isAccessible ()) {
2119+ // case where we failed to allocate in lower tier
2120+ // item is still present in accessContainer
2121+ // item is no longer moving - acquire and
2122+ // wake up waiters with this handle
2123+ auto hdl = acquire (candidate);
2124+ insertInMMContainer (*hdl);
2125+ wakeUpWaiters (*candidate,std::move (hdl));
2126+ } else if (!candidate->isAccessible ()) {
2127+ // case where we failed to replace in access
2128+ // container due to another thread calling insertOrReplace
2129+ // unmark moving and return null handle
2130+ wakeUpWaiters (*candidate,{});
2131+ if (UNLIKELY (ref == 0 )) {
2132+ const auto res =
2133+ releaseBackToAllocator (*candidate, RemoveContext::kNormal ,
2134+ false );
2135+ XDCHECK (res == ReleaseRes::kReleased );
2136+ }
2137+ } else {
2138+ XDCHECK (false );
21172139 }
21182140 }
2119-
21202141 }
21212142 return promotions;
21222143 }
0 commit comments