@@ -2078,15 +2078,36 @@ auto& mmContainer = getMMContainer(tid, pid, cid);
20782078 XDCHECK (res == ReleaseRes::kReleased );
20792079 } else {
20802080 // we failed to allocate a new item, this item is no longer moving
2081- auto ref = unmarkMovingAndWakeUpWaiters (* candidate, {} );
2081+ auto ref = candidate-> unmarkMoving ( );
20822082 if (UNLIKELY (ref == 0 )) {
2083+ wakeUpWaiters (*candidate,{});
20832084 const auto res =
20842085 releaseBackToAllocator (*candidate,
20852086 RemoveContext::kNormal , false );
20862087 XDCHECK (res == ReleaseRes::kReleased );
2088+ } else if (candidate->isAccessible ()) {
2089+ // case where we failed to allocate in lower tier
2090+ // item is still present in accessContainer
2091+ // item is no longer moving - acquire and
2092+ // wake up waiters with this handle
2093+ auto hdl = acquire (candidate);
2094+ insertInMMContainer (*hdl);
2095+ wakeUpWaiters (*candidate,std::move (hdl));
2096+ } else if (!candidate->isAccessible ()) {
2097+ // case where we failed to replace in access
2098+ // container due to another thread calling insertOrReplace
2099+ // unmark moving and return null handle
2100+ wakeUpWaiters (*candidate,{});
2101+ if (UNLIKELY (ref == 0 )) {
2102+ const auto res =
2103+ releaseBackToAllocator (*candidate, RemoveContext::kNormal ,
2104+ false );
2105+ XDCHECK (res == ReleaseRes::kReleased );
2106+ }
2107+ } else {
2108+ XDCHECK (false );
20872109 }
20882110 }
2089-
20902111 }
20912112 return promotions;
20922113 }
0 commit comments