Skip to content

Commit

Permalink
util/mr_cache: Rename retired flag to cached
Browse files Browse the repository at this point in the history
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 <sean.hefty@intel.com>
  • Loading branch information
shefty committed Dec 13, 2017
1 parent 983f020 commit 92f52cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/ofi_mr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 12 additions & 10 deletions prov/util/src/util_mr_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 92f52cc

Please sign in to comment.