@@ -1596,12 +1596,13 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
15961596 typename NvmCacheT::PutToken token;
15971597 Item* toRecycle = nullptr ;
15981598 Item* candidate = nullptr ;
1599+ bool isExpired = false ;
15991600 auto & mmContainer = getMMContainer (tid, pid, cid);
16001601 bool lastTier = tid+1 >= getNumTiers ();
16011602
16021603 mmContainer.withEvictionIterator ([this , tid, pid, cid, &candidate, &toRecycle,
16031604 &searchTries, &mmContainer, &lastTier,
1604- &token](auto && itr) {
1605+ &isExpired, & token](auto && itr) {
16051606 if (!itr) {
16061607 ++searchTries;
16071608 (*stats_.evictionAttempts )[tid][pid][cid].inc ();
@@ -1634,7 +1635,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
16341635 continue ;
16351636 }
16361637
1637- auto marked = lastTier ? candidate_->markForEviction () : candidate_->markMoving (true );
1638+ auto marked = ( lastTier || candidate_-> isExpired ()) ? candidate_->markForEviction () : candidate_->markMoving (true );
16381639 if (!marked) {
16391640 if (candidate_->hasChainedItem ()) {
16401641 stats_.evictFailParentAC .inc ();
@@ -1651,6 +1652,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
16511652 // since we won't be moving the item to the next tier
16521653 toRecycle = toRecycle_;
16531654 candidate = candidate_;
1655+ isExpired = candidate_->isExpired ();
16541656 token = std::move (token_);
16551657
16561658 // Check if parent changed for chained items - if yes, we cannot
@@ -1673,7 +1675,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
16731675 XDCHECK (candidate);
16741676 XDCHECK (candidate->isMoving () || candidate->isMarkedForEviction ());
16751677
1676- auto evictedToNext = lastTier ? nullptr
1678+ auto evictedToNext = ( lastTier || isExpired) ? nullptr
16771679 : tryEvictToNextMemoryTier (*candidate, false );
16781680 if (!evictedToNext) {
16791681 // if insertOrReplace was called during move
@@ -1699,7 +1701,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
16991701 // as exclusive since we will not be moving the item to the next tier
17001702 // but rather just evicting all together, no need to
17011703 // markForEvictionWhenMoving
1702- auto ret = lastTier ? true : candidate->markForEvictionWhenMoving ();
1704+ auto ret = ( lastTier || isExpired) ? true : candidate->markForEvictionWhenMoving ();
17031705 XDCHECK (ret);
17041706
17051707 unlinkItemForEviction (*candidate);
@@ -1824,11 +1826,6 @@ CacheAllocator<CacheTrait>::tryEvictToNextMemoryTier(
18241826 XDCHECK (item.isMoving ());
18251827 XDCHECK (item.getRefCount () == 0 );
18261828 if (item.hasChainedItem ()) return WriteHandle{}; // TODO: We do not support ChainedItem yet
1827- if (item.isExpired ()) {
1828- accessContainer_->remove (item);
1829- item.unmarkMoving ();
1830- return acquire (&item);
1831- }
18321829
18331830 TierId nextTier = tid; // TODO - calculate this based on some admission policy
18341831 while (++nextTier < getNumTiers ()) { // try to evict down to the next memory tiers
0 commit comments