Skip to content

Commit

Permalink
UCS/RCACHE: Remove lru_track/untrack functions
Browse files Browse the repository at this point in the history
  • Loading branch information
yosefe committed Oct 22, 2020
1 parent ad470d1 commit 5284d61
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/ucs/memory/rcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,26 +228,6 @@ ucs_rcache_region_lru_remove(ucs_rcache_t *rcache, ucs_rcache_region_t *region)
region->lru_flag = 0;
}

/* Lock must be held in write mode */
static inline void
ucs_rcache_region_lru_track(ucs_rcache_t *rcache, ucs_rcache_region_t *region)
{
++rcache->num_regions;
rcache->total_size += region->super.end - region->super.start;
}

/* Lock must be held in write mode */
static inline void
ucs_rcache_region_lru_untrack(ucs_rcache_t *rcache, ucs_rcache_region_t *region)
{
--rcache->num_regions;
rcache->total_size -= region->super.end - region->super.start;

ucs_spin_lock(&rcache->lru.lock);
ucs_rcache_region_lru_remove(rcache, region);
ucs_spin_unlock(&rcache->lru.lock);
}

static void ucs_rcache_region_lru_get(ucs_rcache_t *rcache,
ucs_rcache_region_t *region)
{
Expand Down Expand Up @@ -282,7 +262,13 @@ static void ucs_mem_region_destroy_internal(ucs_rcache_t *rcache,
}
}

ucs_rcache_region_lru_untrack(rcache, region);
ucs_spin_lock(&rcache->lru.lock);
ucs_rcache_region_lru_remove(rcache, region);
ucs_spin_unlock(&rcache->lru.lock);

--rcache->num_regions;
rcache->total_size -= region->super.end - region->super.start;

ucs_free(region);
}

Expand Down Expand Up @@ -650,7 +636,9 @@ ucs_rcache_create_region(ucs_rcache_t *rcache, void *address, size_t length,
region->lru_flag = 0;
region->refcount = 1;
region->status = UCS_INPROGRESS;
ucs_rcache_region_lru_track(rcache, region);

++rcache->num_regions;
rcache->total_size += region->super.end - region->super.start;

region->status = status =
UCS_PROFILE_NAMED_CALL("mem_reg", rcache->params.ops->mem_reg,
Expand Down

0 comments on commit 5284d61

Please sign in to comment.