1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ 2 /* 3 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana 4 * University Research and Technology 5 * Corporation. All rights reserved. 6 * Copyright (c) 2004-2007 The University of Tennessee and The University 7 * of Tennessee Research Foundation. All rights 8 * reserved. 9 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 10 * University of Stuttgart. All rights reserved. 11 * Copyright (c) 2004-2005 The Regents of the University of California. 12 * All rights reserved. 13 * 14 * Copyright (c) 2006 Voltaire. All rights reserved. 15 * Copyright (c) 2009 IBM Corporation. All rights reserved. 16 * Copyright (c) 2015-2017 Los Alamos National Security, LLC. All rights 17 * reserved. 18 * 19 * $COPYRIGHT$ 20 * 21 * Additional copyrights may follow 22 * 23 * $HEADER$ 24 */ 25 26 /** 27 * @file 28 * Registration cache VMA lookup 29 */ 30 31 #ifndef MCA_RCACHE_BASE_VMA_H 32 #define MCA_RCACHE_BASE_VMA_H 33 34 #include "opal_config.h" 35 #include "opal/class/opal_list.h" 36 #include "opal/class/opal_rb_tree.h" 37 #include "opal/class/opal_lifo.h" 38 39 BEGIN_C_DECLS 40 41 struct mca_rcache_base_registration_t; 42 43 struct mca_rcache_base_vma_module_t { 44 opal_object_t super; 45 opal_rb_tree_t rb_tree; 46 opal_list_t vma_list; 47 opal_lifo_t vma_gc_lifo; 48 size_t reg_cur_cache_size; 49 opal_mutex_t vma_lock; 50 }; 51 typedef struct mca_rcache_base_vma_module_t mca_rcache_base_vma_module_t; 52 53 OBJ_CLASS_DECLARATION(mca_rcache_base_vma_module_t); 54 55 mca_rcache_base_vma_module_t *mca_rcache_base_vma_module_alloc (void); 56 57 int mca_rcache_base_vma_find (mca_rcache_base_vma_module_t *vma_module, void *addr, 58 size_t size, struct mca_rcache_base_registration_t **reg); 59 60 int mca_rcache_base_vma_find_all (mca_rcache_base_vma_module_t *vma_module, void *addr, 61 size_t size, struct mca_rcache_base_registration_t **regs, 62 int reg_cnt); 63 64 int mca_rcache_base_vma_insert (mca_rcache_base_vma_module_t *vma_module, 65 struct mca_rcache_base_registration_t *registration, 66 size_t limit); 67 68 int mca_rcache_base_vma_delete (mca_rcache_base_vma_module_t *vma_module, 69 struct mca_rcache_base_registration_t *registration); 70 71 void mca_rcache_base_vma_dump_range (mca_rcache_base_vma_module_t *vma_module, 72 unsigned char *base, size_t size, char *msg); 73 74 /** 75 * Iterate over registrations in the specified range. 76 * 77 * @param[in] vma_module vma tree 78 * @param[in] base base address of region 79 * @param[in] size size of region 80 * @param[in] callback_fn function to call for each matching registration handle 81 * @param[in] ctx callback context 82 * 83 * The callback will be made with the vma lock held. This is a recursive lock so 84 * it is still safe to call any vma functions on this vma_module. Keep in mind it 85 * is only safe to call mca_rcache_base_vma_delete() on the supplied registration 86 * from the callback. The iteration will terminate if the callback returns anything 87 * other than OPAL_SUCCESS. 88 */ 89 int mca_rcache_base_vma_iterate (mca_rcache_base_vma_module_t *vma_module, 90 unsigned char *base, size_t size, 91 int (*callback_fn) (struct mca_rcache_base_registration_t *, void *), 92 void *ctx); 93 94 END_C_DECLS 95 96 #endif /* MCA_RCACHE_BASE_VMA_H */ 97