@@ -1417,12 +1417,13 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
14171417 typename NvmCacheT::PutToken token;
14181418 Item* toRecycle = nullptr;
14191419 Item* candidate = nullptr;
1420+ bool isExpired = false;
14201421 auto& mmContainer = getMMContainer(tid, pid, cid);
14211422 bool lastTier = tid+1 >= getNumTiers();
14221423
14231424 mmContainer.withEvictionIterator([this, tid, pid, cid, &candidate, &toRecycle,
14241425 &searchTries, &mmContainer, &lastTier,
1425- &token](auto&& itr) {
1426+ &isExpired, & token](auto&& itr) {
14261427 if (!itr) {
14271428 ++searchTries;
14281429 (*stats_.evictionAttempts)[tid][pid][cid].inc();
@@ -1455,7 +1456,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
14551456 continue;
14561457 }
14571458
1458- auto marked = lastTier ? candidate_->markForEviction() : candidate_->markMoving();
1459+ auto marked = ( lastTier || candidate_->isExpired()) ? candidate_->markForEviction() : candidate_->markMoving();
14591460 if (!marked) {
14601461 if (candidate_->hasChainedItem()) {
14611462 stats_.evictFailParentAC.inc();
@@ -1472,6 +1473,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
14721473 // since we won't be moving the item to the next tier
14731474 toRecycle = toRecycle_;
14741475 candidate = candidate_;
1476+ isExpired = candidate_->isExpired();
14751477 token = std::move(token_);
14761478
14771479 // Check if parent changed for chained items - if yes, we cannot
@@ -1494,7 +1496,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
14941496 XDCHECK(candidate);
14951497 XDCHECK(candidate->isMoving() || candidate->isMarkedForEviction());
14961498
1497- auto evictedToNext = lastTier ? nullptr
1499+ auto evictedToNext = ( lastTier || isExpired) ? nullptr
14981500 : tryEvictToNextMemoryTier(*candidate, false);
14991501 if (!evictedToNext) {
15001502 //if insertOrReplace was called during move
@@ -1520,7 +1522,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
15201522 // as exclusive since we will not be moving the item to the next tier
15211523 // but rather just evicting all together, no need to
15221524 // markForEvictionWhenMoving
1523- auto ret = lastTier ? true : candidate->markForEvictionWhenMoving();
1525+ auto ret = ( lastTier || isExpired) ? true : candidate->markForEvictionWhenMoving();
15241526 XDCHECK(ret);
15251527
15261528 unlinkItemForEviction(*candidate);
@@ -1645,11 +1647,6 @@ CacheAllocator<CacheTrait>::tryEvictToNextMemoryTier(
16451647 XDCHECK(item.isMoving());
16461648 XDCHECK(item.getRefCount() == 0);
16471649 if(item.hasChainedItem()) return WriteHandle{}; // TODO: We do not support ChainedItem yet
1648- if(item.isExpired()) {
1649- accessContainer_->remove(item);
1650- item.unmarkMoving();
1651- return acquire(&item);
1652- }
16531650
16541651 TierId nextTier = tid; // TODO - calculate this based on some admission policy
16551652 while (++nextTier < getNumTiers()) { // try to evict down to the next memory tiers
0 commit comments