@@ -1603,13 +1603,15 @@ CacheAllocator<CacheTrait>::findEviction(TierId tid, PoolId pid, ClassId cid) {
1603
1603
? &toRecycle_->asChainedItem ().getParentItem (compressor_)
1604
1604
: toRecycle_;
1605
1605
1606
- if (lastTier) {
1607
- // if it's last tier, the item will be evicted
1608
- // need to create put token before marking it exclusive
1609
- token = createPutToken (*candidate_);
1610
- }
1606
+ // if it's last tier, the item will be evicted
1607
+ // need to create put token before marking it exclusive
1608
+ const bool evictToNvmCache = lastTier && shouldWriteToNvmCache (*candidate_);
1609
+
1610
+ auto token_ = evictToNvmCache
1611
+ ? nvmCache_->createPutToken (candidate_->getKey ())
1612
+ : typename NvmCacheT::PutToken{};
1611
1613
1612
- if (lastTier && shouldWriteToNvmCache (*candidate_) && !token .isValid ()) {
1614
+ if (evictToNvmCache && !token_ .isValid ()) {
1613
1615
stats_.evictFailConcurrentFill .inc ();
1614
1616
} else if ( (lastTier && candidate_->markForEviction ()) ||
1615
1617
(!lastTier && candidate_->markMoving (true )) ) {
@@ -1619,22 +1621,24 @@ CacheAllocator<CacheTrait>::findEviction(TierId tid, PoolId pid, ClassId cid) {
1619
1621
// since we won't be moving the item to the next tier
1620
1622
toRecycle = toRecycle_;
1621
1623
candidate = candidate_;
1624
+ token = std::move (token_);
1622
1625
1623
1626
// Check if parent changed for chained items - if yes, we cannot
1624
1627
// remove the child from the mmContainer as we will not be evicting
1625
1628
// it. We could abort right here, but we need to cleanup in case
1626
1629
// unmarkForEviction() returns 0 - so just go through normal path.
1627
1630
if (!toRecycle_->isChainedItem () ||
1628
1631
&toRecycle->asChainedItem ().getParentItem (compressor_) ==
1629
- candidate)
1632
+ candidate) {
1630
1633
mmContainer.remove (itr);
1634
+ }
1631
1635
return ;
1632
- }
1633
-
1634
- if (candidate_->hasChainedItem ()) {
1635
- stats_.evictFailParentAC .inc ();
1636
1636
} else {
1637
- stats_.evictFailAC .inc ();
1637
+ if (candidate_->hasChainedItem ()) {
1638
+ stats_.evictFailParentAC .inc ();
1639
+ } else {
1640
+ stats_.evictFailAC .inc ();
1641
+ }
1638
1642
}
1639
1643
1640
1644
++itr;
@@ -1643,8 +1647,9 @@ CacheAllocator<CacheTrait>::findEviction(TierId tid, PoolId pid, ClassId cid) {
1643
1647
}
1644
1648
});
1645
1649
1646
- if (!toRecycle)
1650
+ if (!toRecycle) {
1647
1651
continue ;
1652
+ }
1648
1653
1649
1654
XDCHECK (toRecycle);
1650
1655
XDCHECK (candidate);
0 commit comments