1
1
openmpi/opal/mca/rcache/grdma/rcache_grdma.h
Nathan Hjelm ab8ed177f5 rcache: fix deadlock in multi-threaded environments
This commit fixes several bugs in the registration cache code:

 - Fix a programming error in the grdma invalidation function that can
   cause an infinite loop if more than 100 registrations are
   associated with a munmapped region. This happens because the
   mca_rcache_base_vma_find_all function returns the same 100
   registrations on each call. This has been fixed by adding an
   iterate function to the vma tree interface.

 - Always obtain the vma lock when needed. This is required because
   there may be other threads in the system even if
   opal_using_threads() is false. Additionally, since it is safe to do
   so (the vma lock is recursive) the vma interface has been made
   thread safe.

 - Avoid calling free() while holding a lock. This avoids race
   conditions with locks held outside the Open MPI code.

Fixes open-mpi/ompi#1654.

Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
2016-05-17 09:02:40 -06:00

83 строки
2.4 KiB
C

/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* 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
* reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*/
#ifndef MCA_RCACHE_GRDMA_H
#define MCA_RCACHE_GRDMA_H
#include "opal_config.h"
#include "opal/class/opal_list.h"
#include "opal/mca/event/event.h"
#include "opal/mca/rcache/rcache.h"
#if HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
BEGIN_C_DECLS
struct mca_rcache_grdma_cache_t {
opal_list_item_t super;
char *cache_name;
opal_list_t lru_list;
opal_lifo_t gc_lifo;
mca_rcache_base_vma_module_t *vma_module;
};
typedef struct mca_rcache_grdma_cache_t mca_rcache_grdma_cache_t;
OBJ_CLASS_DECLARATION(mca_rcache_grdma_cache_t);
struct mca_rcache_grdma_component_t {
mca_rcache_base_component_t super;
opal_list_t caches;
char *rcache_name;
bool print_stats;
int leave_pinned;
};
typedef struct mca_rcache_grdma_component_t mca_rcache_grdma_component_t;
OPAL_DECLSPEC extern mca_rcache_grdma_component_t mca_rcache_grdma_component;
struct mca_rcache_grdma_module_t;
struct mca_rcache_grdma_module_t {
mca_rcache_base_module_t super;
struct mca_rcache_base_resources_t resources;
mca_rcache_grdma_cache_t *cache;
opal_free_list_t reg_list;
uint32_t stat_cache_hit;
uint32_t stat_cache_miss;
uint32_t stat_evicted;
uint32_t stat_cache_found;
uint32_t stat_cache_notfound;
};
typedef struct mca_rcache_grdma_module_t mca_rcache_grdma_module_t;
/*
* Initializes the rcache module.
*/
void mca_rcache_grdma_module_init(mca_rcache_grdma_module_t *rcache, mca_rcache_grdma_cache_t *cache);
END_C_DECLS
#endif