From b9b78f8f5d4d6fd514fd3cfb61aa7fe3158332db Mon Sep 17 00:00:00 2001 From: Galen Shipman Date: Wed, 28 Sep 2005 02:11:35 +0000 Subject: [PATCH] modify rcache_rb to find registrations in the middle of a base and bound This commit was SVN r7528. --- ompi/mca/pml/ob1/pml_ob1_rdma.c | 8 ++++---- ompi/mca/rcache/rb/rcache_rb.c | 24 ++++++++++++++++++++++-- ompi/mca/rcache/rb/rcache_rb_tree.c | 8 ++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/ompi/mca/pml/ob1/pml_ob1_rdma.c b/ompi/mca/pml/ob1/pml_ob1_rdma.c index 6772484b2f..e75af56683 100644 --- a/ompi/mca/pml/ob1/pml_ob1_rdma.c +++ b/ompi/mca/pml/ob1/pml_ob1_rdma.c @@ -91,8 +91,8 @@ size_t mca_pml_ob1_rdma_btls( /* otherwise if leave_pinned re-register */ } else if(mca_pml_ob1.leave_pinned) { - unsigned char* new_base = reg->base; - size_t new_len = (base - reg->base) + size; + unsigned char* new_base = reg->base < base ? reg->base : base; + size_t new_len = (base - new_base) + size; /* printf("re-reg 2: base %p size %d new_base %p new_len %d\n", base, size, new_base, new_len); */ assert(new_len >= size); btl_mpool->mpool_deregister(btl_mpool, reg); @@ -255,8 +255,8 @@ mca_mpool_base_registration_t* mca_pml_ob1_rdma_registration( assert(fit->ref_count >= 3); /* a registration exists but is not large enough */ } else { - unsigned char* new_base = largest->base; - size_t new_len = (base - largest->base) + size; + unsigned char* new_base = largest->base < base ? largest->base: base; + size_t new_len = (base - new_base) + size; /* printf("re-reg 2: base %p size %d new_base %p new_len %d\n", base, size, new_base, new_len); */ btl_mpool->mpool_deregister(btl_mpool, largest); diff --git a/ompi/mca/rcache/rb/rcache_rb.c b/ompi/mca/rcache/rb/rcache_rb.c index 4179b4997d..00425cea2a 100644 --- a/ompi/mca/rcache/rb/rcache_rb.c +++ b/ompi/mca/rcache/rb/rcache_rb.c @@ -19,6 +19,10 @@ #include "rcache_rb_tree.h" #include "rcache_rb_mru.h" #include "opal/util/output.h" +#include "ompi/mca/mpool/base/base.h" + +extern unsigned int mca_mpool_base_page_size; +extern unsigned int mca_mpool_base_page_size_log; /** * Initialize the rcache @@ -44,14 +48,31 @@ int mca_rcache_rb_find ( int pos, rc = OMPI_SUCCESS; mca_rcache_rb_tree_item_t* tree_item; + void* base_addr; + void* bound_addr; + if(size == 0) { + return OMPI_ERROR; + } OPAL_THREAD_LOCK(&rcache->lock); *cnt = 0; - tree_item = mca_rcache_rb_tree_find( (mca_rcache_rb_module_t*) rcache, addr ); + + base_addr = down_align_addr(addr, mca_mpool_base_page_size_log); + bound_addr = up_align_addr((void*) ((unsigned long) addr + size - 1), mca_mpool_base_page_size_log); + + for( ; base_addr <= bound_addr; + base_addr =(void*) ((unsigned long) base_addr + mca_mpool_base_page_size)) { + tree_item = mca_rcache_rb_tree_find( (mca_rcache_rb_module_t*) rcache, base_addr ); + if(NULL != tree_item) { + break; + } + } + if(NULL == tree_item) { OPAL_THREAD_UNLOCK(&rcache->lock); return OMPI_ERROR; } + OBJ_DESTRUCT(regs); OBJ_CONSTRUCT(regs, ompi_pointer_array_t); @@ -76,7 +97,6 @@ int mca_rcache_rb_find ( *cnt = 1; } assert(tree_item->reg->bound - tree_item->reg->base >= 0); - assert(((void*) tree_item->reg->base) <= addr); assert(((void*) tree_item->reg->bound) >= addr); return rc; } diff --git a/ompi/mca/rcache/rb/rcache_rb_tree.c b/ompi/mca/rcache/rb/rcache_rb_tree.c index 546fab16ef..a2b15f9a40 100644 --- a/ompi/mca/rcache/rb/rcache_rb_tree.c +++ b/ompi/mca/rcache/rb/rcache_rb_tree.c @@ -58,13 +58,9 @@ struct mca_rcache_rb_tree_item_t * mca_rcache_rb_tree_find( key.bound = base; found = (mca_rcache_rb_tree_item_t *) ompi_rb_tree_find(&rcache->rb_tree, &key); + if(found) + assert((void*)found->reg->bound >= base); - if(NULL != found ) { - if((void*) found->reg->base > base || - (void*) found->reg->bound < base){ - assert(0); - } - } return found; }