Skip to content

rcache/base: do not free memory with the vma lock held #3013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2017
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
2 changes: 1 addition & 1 deletion opal/mca/rcache/base/rcache_base_vma.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct mca_rcache_base_vma_module_t {
opal_object_t super;
opal_rb_tree_t rb_tree;
opal_list_t vma_list;
opal_list_t vma_gc_list;
opal_lifo_t vma_gc_lifo;
size_t reg_cur_cache_size;
opal_mutex_t vma_lock;
};
Expand Down
16 changes: 8 additions & 8 deletions opal/mca/rcache/base/rcache_base_vma_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ int mca_rcache_base_vma_tree_init (mca_rcache_base_vma_module_t *vma_module)
{
OBJ_CONSTRUCT(&vma_module->rb_tree, opal_rb_tree_t);
OBJ_CONSTRUCT(&vma_module->vma_list, opal_list_t);
OBJ_CONSTRUCT(&vma_module->vma_gc_list, opal_list_t);
OBJ_CONSTRUCT(&vma_module->vma_gc_lifo, opal_lifo_t);
vma_module->reg_cur_cache_size = 0;
return opal_rb_tree_init (&vma_module->rb_tree, mca_rcache_base_vma_tree_node_compare);
}
Expand All @@ -250,7 +250,7 @@ void mca_rcache_base_vma_tree_finalize (mca_rcache_base_vma_module_t *vma_module
{
opal_rb_tree_init(&vma_module->rb_tree, mca_rcache_base_vma_tree_node_compare);
OBJ_DESTRUCT(&vma_module->vma_list);
OBJ_DESTRUCT(&vma_module->vma_gc_list);
OBJ_DESTRUCT(&vma_module->vma_gc_lifo);
OBJ_DESTRUCT(&vma_module->rb_tree);
}

Expand Down Expand Up @@ -423,7 +423,7 @@ static void mca_rcache_base_vma_cleanup (mca_rcache_base_vma_module_t *vma_modul
{
opal_list_item_t *item;

while (NULL != (item = opal_list_remove_first (&vma_module->vma_gc_list))) {
while (NULL != (item = opal_lifo_pop_atomic (&vma_module->vma_gc_lifo))) {
OBJ_RELEASE(item);
}
}
Expand All @@ -434,10 +434,10 @@ int mca_rcache_base_vma_tree_insert (mca_rcache_base_vma_module_t *vma_module,
mca_rcache_base_vma_item_t *i;
uintptr_t begin = (uintptr_t)reg->base, end = (uintptr_t)reg->bound;

opal_mutex_lock (&vma_module->vma_lock);

mca_rcache_base_vma_cleanup (vma_module);

opal_mutex_lock (&vma_module->vma_lock);

i = (mca_rcache_base_vma_item_t *) opal_rb_tree_find_with (&vma_module->rb_tree,
(void *) begin, mca_rcache_base_vma_tree_node_compare_closest);

Expand Down Expand Up @@ -570,7 +570,7 @@ int mca_rcache_base_vma_tree_delete (mca_rcache_base_vma_module_t *vma_module,
mca_rcache_base_vma_update_byte_count (vma_module,
vma->start - vma->end - 1);
opal_list_remove_item (&vma_module->vma_list, &vma->super);
opal_list_append (&vma_module->vma_gc_list, &vma->super);
opal_lifo_push_atomic (&vma_module->vma_gc_lifo, &vma->super);
vma = next;
} else {
int merged;
Expand All @@ -588,7 +588,7 @@ int mca_rcache_base_vma_tree_delete (mca_rcache_base_vma_module_t *vma_module,
prev->end = vma->end;
opal_list_remove_item(&vma_module->vma_list, &vma->super);
opal_rb_tree_delete(&vma_module->rb_tree, vma);
opal_list_append (&vma_module->vma_gc_list, &vma->super);
opal_lifo_push_atomic (&vma_module->vma_gc_lifo, &vma->super);
vma = prev;
merged = 1;
}
Expand All @@ -602,7 +602,7 @@ int mca_rcache_base_vma_tree_delete (mca_rcache_base_vma_module_t *vma_module,
vma->end = next->end;
opal_list_remove_item(&vma_module->vma_list, &next->super);
opal_rb_tree_delete(&vma_module->rb_tree, next);
opal_list_append (&vma_module->vma_gc_list, &next->super);
opal_lifo_push_atomic (&vma_module->vma_gc_lifo, &next->super);
merged = 1;
}
} while (merged);
Expand Down