@@ -1243,14 +1243,14 @@ bool CacheAllocator<CacheTrait>::moveChainedItem(ChainedItem& oldItem,
1243
1243
template <typename CacheTrait>
1244
1244
void CacheAllocator<CacheTrait>::unlinkItemForEviction(Item& it) {
1245
1245
XDCHECK (it.isMarkedForEviction ());
1246
- XDCHECK ( it.getRefCount () == 0 );
1246
+ XDCHECK_EQ ( 0 , it.getRefCount ());
1247
1247
accessContainer_->remove (it);
1248
1248
removeFromMMContainer (it);
1249
1249
1250
1250
// Since we managed to mark the item for eviction we must be the only
1251
1251
// owner of the item.
1252
1252
const auto ref = it.unmarkForEviction ();
1253
- XDCHECK (ref == 0u );
1253
+ XDCHECK_EQ ( 0 , ref );
1254
1254
}
1255
1255
1256
1256
template <typename CacheTrait>
@@ -1289,43 +1289,50 @@ CacheAllocator<CacheTrait>::findEviction(PoolId pid, ClassId cid) {
1289
1289
: toRecycle_;
1290
1290
1291
1291
const bool evictToNvmCache = shouldWriteToNvmCache (*candidate_);
1292
- if (evictToNvmCache)
1293
- token = nvmCache_->createPutToken (candidate_->getKey ());
1292
+ auto token_ = evictToNvmCache
1293
+ ? nvmCache_->createPutToken (candidate_->getKey ())
1294
+ : typename NvmCacheT::PutToken{};
1294
1295
1295
- if (evictToNvmCache && !token .isValid ()) {
1296
+ if (evictToNvmCache && !token_ .isValid ()) {
1296
1297
stats_.evictFailConcurrentFill .inc ();
1297
- } else if (candidate_->markForEviction ()) {
1298
- XDCHECK (candidate_->isMarkedForEviction ());
1299
- // markForEviction to make sure no other thead is evicting the item
1300
- // nor holding a handle to that item
1301
- toRecycle = toRecycle_;
1302
- candidate = candidate_;
1303
-
1304
- // Check if parent changed for chained items - if yes, we cannot
1305
- // remove the child from the mmContainer as we will not be evicting
1306
- // it. We could abort right here, but we need to cleanup in case
1307
- // unmarkForEviction() returns 0 - so just go through normal path.
1308
- if (!toRecycle_->isChainedItem () ||
1309
- &toRecycle->asChainedItem ().getParentItem (compressor_) ==
1310
- candidate)
1311
- mmContainer.remove (itr);
1312
- return ;
1313
- } else {
1298
+ ++itr;
1299
+ continue ;
1300
+ }
1301
+
1302
+ auto markedForEviction = candidate_->markForEviction ();
1303
+ if (!markedForEviction) {
1314
1304
if (candidate_->hasChainedItem ()) {
1315
1305
stats_.evictFailParentAC .inc ();
1316
1306
} else {
1317
1307
stats_.evictFailAC .inc ();
1318
1308
}
1309
+ ++itr;
1310
+ continue ;
1319
1311
}
1320
1312
1321
- ++itr;
1322
- XDCHECK (toRecycle == nullptr );
1323
- XDCHECK (candidate == nullptr );
1313
+ XDCHECK (candidate_->isMarkedForEviction ());
1314
+ // markForEviction to make sure no other thead is evicting the item
1315
+ // nor holding a handle to that item
1316
+ toRecycle = toRecycle_;
1317
+ candidate = candidate_;
1318
+ token = std::move (token_);
1319
+
1320
+ // Check if parent changed for chained items - if yes, we cannot
1321
+ // remove the child from the mmContainer as we will not be evicting
1322
+ // it. We could abort right here, but we need to cleanup in case
1323
+ // unmarkForEviction() returns 0 - so just go through normal path.
1324
+ if (!toRecycle_->isChainedItem () ||
1325
+ &toRecycle->asChainedItem ().getParentItem (compressor_) ==
1326
+ candidate) {
1327
+ mmContainer.remove (itr);
1328
+ }
1329
+ return ;
1324
1330
}
1325
1331
});
1326
1332
1327
- if (!toRecycle)
1333
+ if (!toRecycle) {
1328
1334
continue ;
1335
+ }
1329
1336
1330
1337
XDCHECK (toRecycle);
1331
1338
XDCHECK (candidate);
0 commit comments