@@ -1596,12 +1596,13 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
1596
1596
typename NvmCacheT::PutToken token;
1597
1597
Item* toRecycle = nullptr ;
1598
1598
Item* candidate = nullptr ;
1599
+ bool isExpired = false ;
1599
1600
auto & mmContainer = getMMContainer (tid, pid, cid);
1600
1601
bool lastTier = tid+1 >= getNumTiers ();
1601
1602
1602
1603
mmContainer.withEvictionIterator ([this , tid, pid, cid, &candidate, &toRecycle,
1603
1604
&searchTries, &mmContainer, &lastTier,
1604
- &token](auto && itr) {
1605
+ &isExpired, & token](auto && itr) {
1605
1606
if (!itr) {
1606
1607
++searchTries;
1607
1608
(*stats_.evictionAttempts )[tid][pid][cid].inc ();
@@ -1634,7 +1635,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
1634
1635
continue ;
1635
1636
}
1636
1637
1637
- auto marked = lastTier ? candidate_->markForEviction () : candidate_->markMoving (true );
1638
+ auto marked = ( lastTier || candidate_-> isExpired ()) ? candidate_->markForEviction () : candidate_->markMoving (true );
1638
1639
if (!marked) {
1639
1640
if (candidate_->hasChainedItem ()) {
1640
1641
stats_.evictFailParentAC .inc ();
@@ -1651,6 +1652,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
1651
1652
// since we won't be moving the item to the next tier
1652
1653
toRecycle = toRecycle_;
1653
1654
candidate = candidate_;
1655
+ isExpired = candidate_->isExpired ();
1654
1656
token = std::move (token_);
1655
1657
1656
1658
// Check if parent changed for chained items - if yes, we cannot
@@ -1673,7 +1675,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
1673
1675
XDCHECK (candidate);
1674
1676
XDCHECK (candidate->isMoving () || candidate->isMarkedForEviction ());
1675
1677
1676
- auto evictedToNext = lastTier ? nullptr
1678
+ auto evictedToNext = ( lastTier || isExpired) ? nullptr
1677
1679
: tryEvictToNextMemoryTier (*candidate, false );
1678
1680
if (!evictedToNext) {
1679
1681
// if insertOrReplace was called during move
@@ -1699,7 +1701,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
1699
1701
// as exclusive since we will not be moving the item to the next tier
1700
1702
// but rather just evicting all together, no need to
1701
1703
// markForEvictionWhenMoving
1702
- auto ret = lastTier ? true : candidate->markForEvictionWhenMoving ();
1704
+ auto ret = ( lastTier || isExpired) ? true : candidate->markForEvictionWhenMoving ();
1703
1705
XDCHECK (ret);
1704
1706
1705
1707
unlinkItemForEviction (*candidate);
@@ -1824,11 +1826,6 @@ CacheAllocator<CacheTrait>::tryEvictToNextMemoryTier(
1824
1826
XDCHECK (item.isMoving ());
1825
1827
XDCHECK (item.getRefCount () == 0 );
1826
1828
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
- }
1832
1829
1833
1830
TierId nextTier = tid; // TODO - calculate this based on some admission policy
1834
1831
while (++nextTier < getNumTiers ()) { // try to evict down to the next memory tiers
0 commit comments