Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rcache/grdma: try to prevent erroneous free error messages #4576

Merged
merged 1 commit into from
Dec 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions opal/mca/rcache/grdma/rcache_grdma_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Copyright (c) 2006 Voltaire. All rights reserved.
* Copyright (c) 2007 Mellanox Technologies. All rights reserved.
* Copyright (c) 2010 IBM Corporation. All rights reserved.
* Copyright (c) 2011-2016 Los Alamos National Security, LLC. All rights
* Copyright (c) 2011-2017 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2013 NVIDIA Corporation. All rights reserved.
* Copyright (c) 2016 Research Organization for Information Science
Expand Down Expand Up @@ -422,20 +422,29 @@ static int mca_rcache_grdma_deregister (mca_rcache_base_module_t *rcache,
return rc;
}

struct gc_add_args_t {
void *base;
size_t size;
};
typedef struct gc_add_args_t gc_add_args_t;

static int gc_add (mca_rcache_base_registration_t *grdma_reg, void *ctx)
{
mca_rcache_grdma_module_t *rcache_grdma = (mca_rcache_grdma_module_t *) grdma_reg->rcache;

/* unused */
(void) ctx;
gc_add_args_t *args = (gc_add_args_t *) ctx;

if (grdma_reg->flags & MCA_RCACHE_FLAGS_INVALID) {
/* nothing more to do */
return OPAL_SUCCESS;
}

if (grdma_reg->ref_count) {
/* attempted to remove an active registration */
if (grdma_reg->ref_count && grdma_reg->base == args->base) {
/* attempted to remove an active registration. to handle cases where part of
* an active registration has been unmapped we check if the bases match. this
* *hopefully* will suppress erroneously emitted errors. if we can't suppress
* the erroneous error in all cases then this check and return should be removed
* entirely. we are not required to give an error for a user freeing a buffer
* that is in-use by MPI. Its just a nice to have. */
return OPAL_ERROR;
}

Expand All @@ -457,7 +466,8 @@ static int mca_rcache_grdma_invalidate_range (mca_rcache_base_module_t *rcache,
void *base, size_t size)
{
mca_rcache_grdma_module_t *rcache_grdma = (mca_rcache_grdma_module_t *) rcache;
return mca_rcache_base_vma_iterate (rcache_grdma->cache->vma_module, base, size, gc_add, NULL);
gc_add_args_t args = {.base = base, .size = size};
return mca_rcache_base_vma_iterate (rcache_grdma->cache->vma_module, base, size, gc_add, &args);
}

/* Make sure this registration request is not stale. In other words, ensure
Expand Down