Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

rcache: fix deadlock in multi-threaded environments #1171

Merged
merged 1 commit into from
May 24, 2016
Merged
Show file tree
Hide file tree
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
32 changes: 16 additions & 16 deletions opal/mca/btl/vader/btl_vader_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* All rights reserved.
* Copyright (c) 2006-2007 Voltaire. All rights reserved.
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2010-2015 Los Alamos National Security, LLC. All rights
* Copyright (c) 2010-2016 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science
Expand Down Expand Up @@ -528,6 +528,17 @@ static void mca_btl_vader_endpoint_constructor (mca_btl_vader_endpoint_t *ep)
ep->fifo = NULL;
}

#if OPAL_BTL_VADER_HAVE_XPMEM
static int mca_btl_vader_endpoint_rcache_cleanup (mca_mpool_base_registration_t *reg, void *ctx)
{
struct mca_rcache_base_module_t *rcache = (struct mca_rcache_base_module_t *) ctx;
/* otherwise dereg will fail on assert */
reg->ref_count = 0;
(void) rcache->rcache_delete (rcache, reg);
return OPAL_SUCCESS;
}
#endif

static void mca_btl_vader_endpoint_destructor (mca_btl_vader_endpoint_t *ep)
{
OBJ_DESTRUCT(&ep->pending_frags);
Expand All @@ -537,21 +548,10 @@ static void mca_btl_vader_endpoint_destructor (mca_btl_vader_endpoint_t *ep)
if (MCA_BTL_VADER_XPMEM == mca_btl_vader_component.single_copy_mechanism) {
if (ep->segment_data.xpmem.rcache) {
/* clean out the registration cache */
const int nregs = 100;
mca_mpool_base_registration_t *regs[nregs];
int reg_cnt;

do {
reg_cnt = ep->segment_data.xpmem.rcache->rcache_find_all(ep->segment_data.xpmem.rcache, 0, (size_t)-1,
regs, nregs);

for (int i = 0 ; i < reg_cnt ; ++i) {
/* otherwise dereg will fail on assert */
regs[i]->ref_count = 0;
OBJ_RELEASE(regs[i]);
}
} while (reg_cnt == nregs);

(void) ep->segment_data.xpmem.rcache->rcache_iterate (ep->segment_data.xpmem.rcache,
NULL, (size_t) -1,
mca_btl_vader_endpoint_rcache_cleanup,
(void *) ep->segment_data.xpmem.rcache);
ep->segment_data.xpmem.rcache = NULL;
}

Expand Down
5 changes: 3 additions & 2 deletions opal/mca/mpool/grdma/mpool_grdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006 Voltaire. All rights reserved.
* Copyright (c) 2011-2015 Los Alamos National Security, LLC. All rights
* Copyright (c) 2011-2016 Los Alamos National Security, LLC. All rights
* reserved.
*
* $COPYRIGHT$
Expand All @@ -28,6 +28,7 @@

#include "opal_config.h"
#include "opal/class/opal_list.h"
#include "opal/class/opal_lifo.h"
#include "opal/mca/event/event.h"
#include "opal/mca/mpool/mpool.h"
#if HAVE_SYS_MMAN_H
Expand All @@ -42,7 +43,7 @@ struct mca_mpool_grdma_pool_t {
opal_list_item_t super;
char *pool_name;
opal_list_t lru_list;
opal_list_t gc_list;
opal_lifo_t gc_lifo;
struct mca_rcache_base_module_t *rcache;
};
typedef struct mca_mpool_grdma_pool_t mca_mpool_grdma_pool_t;
Expand Down
Loading