From 92f52cc96807b16e44eff99eab5e91a761570a17 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 13 Dec 2017 11:19:39 -0800 Subject: [PATCH] util/mr_cache: Rename retired flag to cached The retired flag inversely indicates if a region is actively being cached. Make this association more explicit by renaming and inverting the flag. Signed-off-by: Sean Hefty --- include/ofi_mr.h | 2 +- prov/util/src/util_mr_cache.c | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/ofi_mr.h b/include/ofi_mr.h index ee403bcd293..a6f8786213b 100644 --- a/include/ofi_mr.h +++ b/include/ofi_mr.h @@ -154,7 +154,7 @@ int ofi_mr_map_verify(struct ofi_mr_map *map, uintptr_t *io_addr, struct ofi_mr_entry { struct iovec iov; uint64_t access; /* TODO */ - unsigned int retired:1; + unsigned int cached:1; unsigned int subscribed:1; int use_cnt; struct dlist_entry lru_entry; diff --git a/prov/util/src/util_mr_cache.c b/prov/util/src/util_mr_cache.c index 8c861689904..e3256564837 100644 --- a/prov/util/src/util_mr_cache.c +++ b/prov/util/src/util_mr_cache.c @@ -77,14 +77,16 @@ util_mr_cache_process_events(struct ofi_mr_cache *cache) while ((subscription = ofi_monitor_get_event(&cache->nq))) { entry = container_of(subscription, struct ofi_mr_entry, subscription); - if (entry->use_cnt == 0) { - dlist_remove(&entry->lru_entry); - util_mr_free_entry(cache, entry); - } else if (!entry->retired) { + if (entry->cached) { iter = rbtFind(cache->mr_tree, &entry->iov); assert(iter); rbtErase(cache->mr_tree, iter); - entry->retired = 1; + entry->cached = 0; + } + + if (entry->use_cnt == 0) { + dlist_remove(&entry->lru_entry); + util_mr_free_entry(cache, entry); } } } @@ -112,10 +114,10 @@ void ofi_mr_cache_delete(struct ofi_mr_cache *cache, struct ofi_mr_entry *entry) util_mr_cache_process_events(cache); if (--entry->use_cnt == 0) { - if (entry->retired) { - util_mr_free_entry(cache, entry); - } else { + if (entry->cached) { dlist_insert_tail(&entry->lru_entry, &cache->lru_list); + } else { + util_mr_free_entry(cache, entry); } } } @@ -144,7 +146,7 @@ util_mr_cache_create(struct ofi_mr_cache *cache, const struct iovec *iov, } if (++cache->cached_cnt > cache->size) { - (*entry)->retired = 1; + (*entry)->cached = 0; } else { ret = ofi_monitor_subscribe(&cache->nq, iov->iov_base, iov->iov_len, &(*entry)->subscription); @@ -184,7 +186,7 @@ util_mr_cache_merge(struct ofi_mr_cache *cache, const struct fi_mr_attr *attr, rbtErase(cache->mr_tree, iter); if (old_entry->use_cnt) { - old_entry->retired = 1; + old_entry->cached = 0; } else { dlist_remove(&old_entry->lru_entry); util_mr_free_entry(cache, old_entry);