14
14
* Copyright (c) 2006 Voltaire. All rights reserved.
15
15
* Copyright (c) 2007 Mellanox Technologies. All rights reserved.
16
16
* Copyright (c) 2010 IBM Corporation. All rights reserved.
17
- * Copyright (c) 2011-2016 Los Alamos National Security, LLC. All rights
17
+ * Copyright (c) 2011-2017 Los Alamos National Security, LLC. All rights
18
18
* reserved.
19
19
* Copyright (c) 2013 NVIDIA Corporation. All rights reserved.
20
20
* Copyright (c) 2016 Research Organization for Information Science
@@ -422,20 +422,29 @@ static int mca_rcache_grdma_deregister (mca_rcache_base_module_t *rcache,
422
422
return rc ;
423
423
}
424
424
425
+ struct gc_add_args_t {
426
+ void * base ;
427
+ size_t size ;
428
+ };
429
+ typedef struct gc_add_args_t gc_add_args_t ;
430
+
425
431
static int gc_add (mca_rcache_base_registration_t * grdma_reg , void * ctx )
426
432
{
427
433
mca_rcache_grdma_module_t * rcache_grdma = (mca_rcache_grdma_module_t * ) grdma_reg -> rcache ;
428
-
429
- /* unused */
430
- (void ) ctx ;
434
+ gc_add_args_t * args = (gc_add_args_t * ) ctx ;
431
435
432
436
if (grdma_reg -> flags & MCA_RCACHE_FLAGS_INVALID ) {
433
437
/* nothing more to do */
434
438
return OPAL_SUCCESS ;
435
439
}
436
440
437
- if (grdma_reg -> ref_count ) {
438
- /* attempted to remove an active registration */
441
+ if (grdma_reg -> ref_count && grdma_reg -> base == args -> base ) {
442
+ /* attempted to remove an active registration. to handle cases where part of
443
+ * an active registration has been unmapped we check if the bases match. this
444
+ * *hopefully* will suppress erroneously emitted errors. if we can't suppress
445
+ * the erroneous error in all cases then this check and return should be removed
446
+ * entirely. we are not required to give an error for a user freeing a buffer
447
+ * that is in-use by MPI. Its just a nice to have. */
439
448
return OPAL_ERROR ;
440
449
}
441
450
@@ -457,7 +466,8 @@ static int mca_rcache_grdma_invalidate_range (mca_rcache_base_module_t *rcache,
457
466
void * base , size_t size )
458
467
{
459
468
mca_rcache_grdma_module_t * rcache_grdma = (mca_rcache_grdma_module_t * ) rcache ;
460
- return mca_rcache_base_vma_iterate (rcache_grdma -> cache -> vma_module , base , size , gc_add , NULL );
469
+ gc_add_args_t args = {.base = base , .size = size };
470
+ return mca_rcache_base_vma_iterate (rcache_grdma -> cache -> vma_module , base , size , gc_add , & args );
461
471
}
462
472
463
473
/* Make sure this registration request is not stale. In other words, ensure
0 commit comments