Skip to content
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
3 changes: 2 additions & 1 deletion opal/mca/rcache/vma/rcache_vma.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* Copyright (c) 2006 Voltaire. All rights reserved.
* Copyright (c) 2009 IBM Corporation. All rights reserved.
* Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
* Copyright (c) 2015-2017 Los Alamos National Security, LLC. All rights
* reserved.
*
* $COPYRIGHT$
Expand All @@ -40,6 +40,7 @@ struct mca_rcache_vma_module_t {
mca_rcache_base_module_t base;
opal_rb_tree_t rb_tree;
opal_list_t vma_list;
opal_list_t vma_gc_list;
size_t reg_cur_cache_size;
};
typedef struct mca_rcache_vma_module_t mca_rcache_vma_module_t;
Expand Down
34 changes: 24 additions & 10 deletions opal/mca/rcache/vma/rcache_vma_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Copyright (c) 2009 IBM Corporation. All rights reserved.
* Copyright (c) 2013 NVIDIA Corporation. All rights reserved.
* Copyright (c) 2013 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
* Copyright (c) 2015-2017 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
Expand Down Expand Up @@ -265,6 +265,7 @@ int mca_rcache_vma_tree_init(mca_rcache_vma_module_t* rcache)
{
OBJ_CONSTRUCT(&rcache->rb_tree, opal_rb_tree_t);
OBJ_CONSTRUCT(&rcache->vma_list, opal_list_t);
OBJ_CONSTRUCT(&rcache->vma_gc_list, opal_list_t);
rcache->reg_cur_cache_size = 0;
return opal_rb_tree_init(&rcache->rb_tree,
mca_rcache_vma_tree_node_compare);
Expand All @@ -276,6 +277,23 @@ void mca_rcache_vma_tree_finalize(mca_rcache_vma_module_t* rcache)
mca_rcache_vma_tree_node_compare);
OBJ_DESTRUCT(&rcache->vma_list);
OBJ_DESTRUCT(&rcache->rb_tree);
OPAL_LIST_DESTRUCT(&rcache->vma_gc_list);
}

/**
* Clean the vma garbage collection list
*
* This function releases any deleted vma structures. It MUST be called
* with the VMA lock help and MAY NOT be called from a function that can
* be called by a memory hook.
*/
static void mca_rcache_vma_gc_clean (mca_rcache_vma_module_t* rcache)
{
opal_list_item_t *item;

while (NULL != (item = opal_list_remove_first (&rcache->vma_gc_list))) {
OBJ_RELEASE(item);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use OPAL_LIST_DESTRUCT here?

Or is it just to-MAY-to vs. to-MAH-to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would then need to OBJ_CONSTRUCT again. So its MAY to MAH.

}

mca_mpool_base_registration_t *mca_rcache_vma_tree_find(
Expand Down Expand Up @@ -455,6 +473,8 @@ int mca_rcache_vma_tree_insert(mca_rcache_vma_module_t* vma_rcache,

opal_mutex_lock (&vma_rcache->base.lock);

mca_rcache_vma_gc_clean (vma_rcache);

i = (mca_rcache_vma_t*)opal_rb_tree_find_with(&vma_rcache->rb_tree,
(void*)begin, mca_rcache_vma_tree_node_compare_closest);

Expand Down Expand Up @@ -553,7 +573,6 @@ int mca_rcache_vma_tree_insert(mca_rcache_vma_module_t* vma_rcache,
int mca_rcache_vma_tree_delete(mca_rcache_vma_module_t* vma_rcache,
mca_mpool_base_registration_t* reg)
{
opal_list_t deleted_vmas;
mca_rcache_vma_t *vma;

vma = (mca_rcache_vma_t*)opal_rb_tree_find_with(&vma_rcache->rb_tree, reg->base,
Expand All @@ -564,8 +583,6 @@ int mca_rcache_vma_tree_delete(mca_rcache_vma_module_t* vma_rcache,

opal_mutex_lock (&vma_rcache->base.lock);

OBJ_CONSTRUCT(&deleted_vmas, opal_list_t);

while(vma != (mca_rcache_vma_t*)opal_list_get_end(&vma_rcache->vma_list)
&& vma->start <= (uintptr_t)reg->bound) {
mca_rcache_vma_remove_reg(vma, reg);
Expand All @@ -576,7 +593,7 @@ int mca_rcache_vma_tree_delete(mca_rcache_vma_module_t* vma_rcache,
mca_rcache_vma_update_byte_count(vma_rcache,
vma->start - vma->end - 1);
opal_list_remove_item(&vma_rcache->vma_list, &vma->super);
opal_list_append(&deleted_vmas, &vma->super);
opal_list_append(&vma_rcache->vma_gc_list, &vma->super);
vma = next;
} else {
int merged;
Expand All @@ -593,7 +610,7 @@ int mca_rcache_vma_tree_delete(mca_rcache_vma_module_t* vma_rcache,
prev->end = vma->end;
opal_list_remove_item(&vma_rcache->vma_list, &vma->super);
opal_rb_tree_delete(&vma_rcache->rb_tree, vma);
opal_list_append(&deleted_vmas, &vma->super);
opal_list_append(&vma_rcache->vma_gc_list, &vma->super);
vma = prev;
merged = 1;
}
Expand All @@ -606,7 +623,7 @@ int mca_rcache_vma_tree_delete(mca_rcache_vma_module_t* vma_rcache,
vma->end = next->end;
opal_list_remove_item(&vma_rcache->vma_list, &next->super);
opal_rb_tree_delete(&vma_rcache->rb_tree, next);
opal_list_append(&deleted_vmas, &next->super);
opal_list_append(&vma_rcache->vma_gc_list, &next->super);
merged = 1;
}
} while(merged);
Expand All @@ -616,9 +633,6 @@ int mca_rcache_vma_tree_delete(mca_rcache_vma_module_t* vma_rcache,

opal_mutex_unlock (&vma_rcache->base.lock);

/* actually free vmas now that the lock has been dropped */
OPAL_LIST_DESTRUCT(&deleted_vmas);

return 0;
}

Expand Down