Skip to content

Commit

Permalink
UCP/CORE: Fix memory cache lookup retrun value handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrygx committed Dec 1, 2021
1 parent 301cd84 commit 2e90f60
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/ucp/core/ucp_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,24 +497,23 @@ ucp_memory_detect_internal(ucp_context_h context, const void *address,
}

status = ucs_memtype_cache_lookup(address, length, mem_info);
if (status != UCS_ERR_NO_ELEM) {
if (ucs_likely(status != UCS_OK)) {
ucs_assert(status == UCS_ERR_NO_ELEM);
goto out_host_mem;
}

if ((mem_info->type != UCS_MEMORY_TYPE_UNKNOWN) &&
((mem_info->sys_dev != UCS_SYS_DEVICE_ID_UNKNOWN))) {
return;
}

/* Fall thru to slow-path memory type and system device detection by UCT
* memory domains. In any case, the memory type cache is not expected to
* return HOST memory type.
*/
ucs_assert(mem_info->type != UCS_MEMORY_TYPE_HOST);
if (ucs_likely(status == UCS_ERR_NO_ELEM)) {
goto out_host_mem;
}

ucs_assert(status == UCS_OK);

if ((mem_info->type != UCS_MEMORY_TYPE_UNKNOWN) &&
(mem_info->sys_dev != UCS_SYS_DEVICE_ID_UNKNOWN)) {
return;
}

/* Fall thru to slow-path memory type and system device detection by UCT
* memory domains. In any case, the memory type cache is not expected to
* return HOST memory type.
*/
ucs_assert(mem_info->type != UCS_MEMORY_TYPE_HOST);

ucp_memory_detect_slowpath(context, address, length, mem_info);
return;

Expand Down

0 comments on commit 2e90f60

Please sign in to comment.