int mca_rcache_vma_delete(struct mca_rcache_base_module_t* rcache, mca_mpool_base_registration_t* reg) { mca_rcache_vma_module_t *vma_rcache = (mca_rcache_vma_module_t*)rcache; /* Tell the memory manager that we no longer care about this region */ opal_memory->memoryc_deregister(reg->base, (uint64_t) (reg->bound - reg->base), (uint64_t) (uintptr_t) reg); return mca_rcache_vma_tree_delete(vma_rcache, reg); }
int mca_rcache_vma_tree_insert(mca_rcache_vma_module_t* vma_rcache, mca_mpool_base_registration_t* reg, size_t limit) { mca_rcache_vma_t *i; uintptr_t begin = (uintptr_t)reg->base, end = (uintptr_t)reg->bound; i = (mca_rcache_vma_t*)ompi_rb_tree_find_with(&vma_rcache->rb_tree, (void*)begin, mca_rcache_vma_tree_node_compare_closest); if(!i) i = (mca_rcache_vma_t*)opal_list_get_end(&vma_rcache->vma_list); while (begin <= end) { mca_rcache_vma_t *vma; if((mca_rcache_vma_t*)opal_list_get_end(&vma_rcache->vma_list) == i) { vma = NULL; if(mca_rcache_vma_can_insert(vma_rcache, end - begin + 1, limit)) vma = mca_rcache_vma_new(vma_rcache, begin, end); if(!vma) goto remove; mca_rcache_vma_update_byte_count(vma_rcache, end - begin + 1); opal_list_append(&vma_rcache->vma_list, &vma->super); begin = vma->end + 1; mca_rcache_vma_add_reg(vma, reg); } else if(i->start > begin) { uintptr_t tend = (i->start <= end)?(i->start - 1):end; vma = NULL; if(mca_rcache_vma_can_insert(vma_rcache, tend - begin + 1, limit)) vma = mca_rcache_vma_new(vma_rcache, begin, tend); if(!vma) goto remove; mca_rcache_vma_update_byte_count(vma_rcache, tend - begin + 1); /* insert before */ opal_list_insert_pos(&vma_rcache->vma_list, &i->super, &vma->super); i = vma; begin = vma->end + 1; mca_rcache_vma_add_reg(vma, reg); } else if(i->start == begin) { if (i->end > end) { vma = mca_rcache_vma_new(vma_rcache, end+1, i->end); if(!vma) goto remove; i->end = end; mca_rcache_vma_copy_reg_list(vma, i); /* add after */ opal_list_insert_pos(&vma_rcache->vma_list, opal_list_get_next(&i->super), &vma->super); mca_rcache_vma_add_reg(i, reg); begin = end + 1; } else { mca_rcache_vma_add_reg(i, reg); begin = i->end + 1; } } else { vma = mca_rcache_vma_new(vma_rcache, begin, i->end); if(!vma) goto remove; i->end = begin - 1; mca_rcache_vma_copy_reg_list(vma, i); /* add after */ opal_list_insert_pos(&vma_rcache->vma_list, opal_list_get_next(&i->super), &vma->super); } i = (mca_rcache_vma_t*)opal_list_get_next(&i->super); } return OMPI_SUCCESS; remove: mca_rcache_vma_tree_delete(vma_rcache, reg); return OMPI_ERR_TEMP_OUT_OF_RESOURCE; }
int mca_rcache_vma_delete(struct mca_rcache_base_module_t* rcache, mca_mpool_base_registration_t* reg) { mca_rcache_vma_module_t *vma_rcache = (mca_rcache_vma_module_t*)rcache; return mca_rcache_vma_tree_delete(vma_rcache, reg); }