Move ompi_pointer_array initialization and destruction outside of the memory
callback, note that ompi_pointer_array_remove_all does not call free. This needs to go to the release branch This commit was SVN r8944.
Этот коммит содержится в:
родитель
600f664db2
Коммит
1c71ab73d1
@ -28,6 +28,7 @@
|
||||
#include "mpool_base_mem_cb.h"
|
||||
|
||||
extern int mca_mpool_base_use_mem_hooks;
|
||||
extern ompi_pointer_array_t mca_mpool_base_mem_cb_array;
|
||||
|
||||
int mca_mpool_base_close(void)
|
||||
{
|
||||
@ -62,6 +63,7 @@ int mca_mpool_base_close(void)
|
||||
if(mca_mpool_base_use_mem_hooks &&
|
||||
0 != (OPAL_MEMORY_FREE_SUPPORT & opal_mem_hooks_support_level())) {
|
||||
opal_mem_hooks_unregister_release(mca_mpool_base_mem_cb);
|
||||
OBJ_DESTRUCT(&mca_mpool_base_mem_cb_array);
|
||||
}
|
||||
/* All done */
|
||||
|
||||
|
@ -34,6 +34,7 @@ extern int mca_mpool_base_disable_sbrk;
|
||||
|
||||
|
||||
extern int mca_mpool_base_use_mem_hooks;
|
||||
extern ompi_pointer_array_t mca_mpool_base_mem_cb_array;
|
||||
|
||||
mca_mpool_base_component_t* mca_mpool_base_component_lookup(const char* name)
|
||||
{
|
||||
@ -91,7 +92,8 @@ mca_mpool_base_module_t* mca_mpool_base_module_create(
|
||||
if(opal_list_get_size(&mca_mpool_base_modules) == 1) {
|
||||
if(mca_mpool_base_use_mem_hooks &&
|
||||
0 != (OPAL_MEMORY_FREE_SUPPORT & opal_mem_hooks_support_level())) {
|
||||
opal_mem_hooks_register_release(mca_mpool_base_mem_cb, NULL);
|
||||
opal_mem_hooks_register_release(mca_mpool_base_mem_cb, NULL);
|
||||
OBJ_CONSTRUCT(&mca_mpool_base_mem_cb_array, ompi_pointer_array_t);
|
||||
}
|
||||
|
||||
#ifdef HAVE_MALLOC_H
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
extern uint32_t mca_mpool_base_page_size;
|
||||
extern uint32_t mca_mpool_base_page_size_log;
|
||||
ompi_pointer_array_t mca_mpool_base_mem_cb_array;
|
||||
|
||||
/*
|
||||
* memory hook callback, called when memory is free'd out from under us
|
||||
@ -34,7 +35,6 @@ void mca_mpool_base_mem_cb(void* base, size_t size, void* cbdata,
|
||||
bool from_alloc)
|
||||
{
|
||||
uint32_t i, cnt;
|
||||
ompi_pointer_array_t regs;
|
||||
mca_mpool_base_registration_t* reg;
|
||||
mca_mpool_base_selected_module_t* current;
|
||||
int rc;
|
||||
@ -47,7 +47,6 @@ void mca_mpool_base_mem_cb(void* base, size_t size, void* cbdata,
|
||||
|
||||
base_addr = down_align_addr( base, mca_mpool_base_page_size_log);
|
||||
bound_addr = up_align_addr((void*) ((unsigned long) base + size - 1), mca_mpool_base_page_size_log);
|
||||
OBJ_CONSTRUCT(®s, ompi_pointer_array_t);
|
||||
for(item = opal_list_get_first(&mca_mpool_base_modules);
|
||||
item != opal_list_get_end(&mca_mpool_base_modules);
|
||||
item = opal_list_get_next(item)) {
|
||||
@ -59,14 +58,14 @@ void mca_mpool_base_mem_cb(void* base, size_t size, void* cbdata,
|
||||
current->mpool_module,
|
||||
base_addr,
|
||||
size,
|
||||
®s,
|
||||
&mca_mpool_base_mem_cb_array,
|
||||
&cnt
|
||||
);
|
||||
if(OMPI_SUCCESS != rc) {
|
||||
continue;
|
||||
}
|
||||
for(i = 0; i < cnt; i++) {
|
||||
reg = (mca_mpool_base_registration_t*)ompi_pointer_array_get_item(®s, i);
|
||||
reg = (mca_mpool_base_registration_t*)ompi_pointer_array_get_item(&mca_mpool_base_mem_cb_array, i);
|
||||
#if !defined(NDEBUG)
|
||||
if(reg->flags & MCA_MPOOL_FLAGS_CACHE) {
|
||||
assert(reg->ref_count <= 3);
|
||||
@ -78,10 +77,10 @@ void mca_mpool_base_mem_cb(void* base, size_t size, void* cbdata,
|
||||
#endif
|
||||
current->mpool_module->mpool_deregister(current->mpool_module, reg);
|
||||
}
|
||||
ompi_pointer_array_remove_all(®s);
|
||||
ompi_pointer_array_remove_all(&mca_mpool_base_mem_cb_array);
|
||||
}
|
||||
}
|
||||
OBJ_DESTRUCT(®s);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user