Skip to content

Commit

Permalink
prov/util: Allow providers to update cache MR IOV
Browse files Browse the repository at this point in the history
A provider may update the memory region that is added to accommodate
for instance alignment of the region to a larger page boundary. In such
cases, the MR cache info used to search the cache should use the updated
region.

This allows the provider to avoid walking /proc/pid/smaps if the
underlying kernel component may more efficiently determine the backing
page size.

Signed-off-by: Steve Welch <[email protected]>
Signed-off-by: Ian Ziemba <[email protected]>
  • Loading branch information
swelch authored and iziemba committed Oct 9, 2024
1 parent 765cc16 commit df5472b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 5 additions & 4 deletions include/ofi_mr.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,15 @@ bool ofi_mr_cache_flush(struct ofi_mr_cache *cache, bool flush_lru);
* a new ofi_mr_entry and assign it to entry.
*
* @param[in] cache The cache the entry belongs to
* @param[in] info Information about the mr entry to search
* @param[in out] info Information about the mr entry to search. Info IOV may
* be updated by providers to reflect region registered by
* the provider.
* @param[out] entry The registered entry corresponding to the
* region described in info.
* @returns On success, returns 0. On failure, returns a negative error code.
*/
int ofi_mr_cache_search(struct ofi_mr_cache *cache,
const struct ofi_mr_info *info,
struct ofi_mr_entry **entry);
int ofi_mr_cache_search(struct ofi_mr_cache *cache, struct ofi_mr_info *info,
struct ofi_mr_entry **entry);

/**
* Given an attr (with an iov range), if the iov range is already registered,
Expand Down
10 changes: 8 additions & 2 deletions prov/util/src/util_mr_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void ofi_mr_cache_delete(struct ofi_mr_cache *cache, struct ofi_mr_entry *entry)
* restart the entire operation.
*/
static int
util_mr_cache_create(struct ofi_mr_cache *cache, const struct ofi_mr_info *info,
util_mr_cache_create(struct ofi_mr_cache *cache, struct ofi_mr_info *info,
struct ofi_mr_entry **entry)
{
struct ofi_mr_entry *cur;
Expand All @@ -291,6 +291,12 @@ util_mr_cache_create(struct ofi_mr_cache *cache, const struct ofi_mr_info *info,
if (ret)
goto free;

/* Providers may have expanded the MR. Update MR info input
* accordingly.
*/
assert(ofi_iov_within(&(*info).iov, &(*entry)->info.iov));
*info = (*entry)->info;

pthread_mutex_lock(&mm_lock);
cur = ofi_mr_rbt_find(&cache->tree, info);
if (cur) {
Expand Down Expand Up @@ -329,7 +335,7 @@ util_mr_cache_create(struct ofi_mr_cache *cache, const struct ofi_mr_info *info,
return ret;
}

int ofi_mr_cache_search(struct ofi_mr_cache *cache, const struct ofi_mr_info *info,
int ofi_mr_cache_search(struct ofi_mr_cache *cache, struct ofi_mr_info *info,
struct ofi_mr_entry **entry)
{
struct ofi_mem_monitor *monitor;
Expand Down

0 comments on commit df5472b

Please sign in to comment.