@@ -1600,11 +1600,12 @@ CacheAllocator<CacheTrait>::findEviction(TierId tid, PoolId pid, ClassId cid) {
16001600
16011601 Item* toRecycle = nullptr ;
16021602 Item* candidate = nullptr ;
1603+ bool isExpired = false ;
16031604 typename NvmCacheT::PutToken token;
16041605
16051606 mmContainer.withEvictionIterator ([this , tid, pid, cid, &candidate, &toRecycle,
16061607 &searchTries, &mmContainer, &lastTier,
1607- &token](auto && itr) {
1608+ &isExpired, & token](auto && itr) {
16081609 if (!itr) {
16091610 ++searchTries;
16101611 (*stats_.evictionAttempts )[tid][pid][cid].inc ();
@@ -1633,14 +1634,16 @@ CacheAllocator<CacheTrait>::findEviction(TierId tid, PoolId pid, ClassId cid) {
16331634
16341635 if (evictToNvmCache && !token_.isValid ()) {
16351636 stats_.evictFailConcurrentFill .inc ();
1636- } else if ( (lastTier && candidate_->markForEviction ()) ||
1637+ } else if ( ((lastTier || candidate_->isExpired ()) &&
1638+ candidate_->markForEviction ()) ||
16371639 (!lastTier && candidate_->markMoving (true )) ) {
16381640 XDCHECK (candidate_->isMoving () || candidate_->isMarkedForEviction ());
16391641 // markForEviction to make sure no other thead is evicting the item
16401642 // nor holding a handle to that item if this is last tier
16411643 // since we won't be moving the item to the next tier
16421644 toRecycle = toRecycle_;
16431645 candidate = candidate_;
1646+ isExpired = candidate_->isExpired ();
16441647 token = std::move (token_);
16451648
16461649 // Check if parent changed for chained items - if yes, we cannot
@@ -1674,7 +1677,7 @@ CacheAllocator<CacheTrait>::findEviction(TierId tid, PoolId pid, ClassId cid) {
16741677 XDCHECK (toRecycle);
16751678 XDCHECK (candidate);
16761679
1677- auto evictedToNext = lastTier ? nullptr
1680+ auto evictedToNext = ( lastTier || isExpired) ? nullptr
16781681 : tryEvictToNextMemoryTier (*candidate, false );
16791682 if (!evictedToNext) {
16801683 // if insertOrReplace was called during move
@@ -1700,7 +1703,7 @@ CacheAllocator<CacheTrait>::findEviction(TierId tid, PoolId pid, ClassId cid) {
17001703 // as exclusive since we will not be moving the item to the next tier
17011704 // but rather just evicting all together, no need to
17021705 // markForEvictionWhenMoving
1703- auto ret = lastTier ? true : candidate->markForEvictionWhenMoving ();
1706+ auto ret = ( lastTier || isExpired) ? true : candidate->markForEvictionWhenMoving ();
17041707 XDCHECK (ret);
17051708
17061709 unlinkItemForEviction (*candidate);
@@ -1807,11 +1810,6 @@ CacheAllocator<CacheTrait>::tryEvictToNextMemoryTier(
18071810 XDCHECK (item.isMoving ());
18081811 XDCHECK (item.getRefCount () == 0 );
18091812 if (item.hasChainedItem ()) return WriteHandle{}; // TODO: We do not support ChainedItem yet
1810- if (item.isExpired ()) {
1811- accessContainer_->remove (item);
1812- item.unmarkMoving ();
1813- return acquire (&item);
1814- }
18151813
18161814 TierId nextTier = tid; // TODO - calculate this based on some admission policy
18171815 while (++nextTier < getNumTiers ()) { // try to evict down to the next memory tiers
0 commit comments