@@ -412,12 +412,35 @@ int mca_mpool_rgpusm_register(mca_mpool_base_module_t *mpool, void *addr,
412412 opal_output_verbose (80 , mca_mpool_rgpusm_component .output ,
413413 "RGPUSM: About to insert in rgpusm cache addr=%p, size=%d" , addr , (int )size );
414414 SET_PAGE_ALIGNMENT_TO_ZERO ();
415- while ((rc = mpool -> rcache -> rcache_insert (mpool -> rcache , (mca_mpool_base_registration_t * )rgpusm_reg ,
416- mca_mpool_rgpusm_component .rcache_size_limit )) ==
417- OMPI_ERR_TEMP_OUT_OF_RESOURCE ) {
418- opal_output (-1 , "No room in the cache - boot one out" );
419- if (!mca_mpool_rgpusm_deregister_lru (mpool )) {
420- break ;
415+ rc = mpool -> rcache -> rcache_insert (mpool -> rcache , (mca_mpool_base_registration_t * )rgpusm_reg ,
416+ mca_mpool_rgpusm_component .rcache_size_limit );
417+ if (OPAL_ERR_TEMP_OUT_OF_RESOURCE == rc ) {
418+ opal_output_verbose (40 , mca_mpool_rgpusm_component .output ,
419+ "RGPUSM: No room in the cache - boot the first one out" );
420+ (void )mca_mpool_rgpusm_deregister_lru (mpool );
421+ if (mca_mpool_rgpusm_component .empty_cache ) {
422+ int remNum = 1 ;
423+ /* Empty out every registration from LRU until it is empty */
424+ opal_output_verbose (40 , mca_mpool_rgpusm_component .output ,
425+ "RGPUSM: About to delete all the unused entries in the cache" );
426+ while (mca_mpool_rgpusm_deregister_lru (mpool )) {
427+ remNum ++ ;
428+ }
429+ opal_output_verbose (40 , mca_mpool_rgpusm_component .output ,
430+ "RGPUSM: Deleted and deregistered %d entries" , remNum );
431+ rc = mpool -> rcache -> rcache_insert (mpool -> rcache , (mca_mpool_base_registration_t * )rgpusm_reg ,
432+ mca_mpool_rgpusm_component .rcache_size_limit );
433+ } else {
434+ /* Check for room after one removal. If not, remove another one until there is space */
435+ while ((rc = mpool -> rcache -> rcache_insert (mpool -> rcache , (mca_mpool_base_registration_t * )rgpusm_reg ,
436+ mca_mpool_rgpusm_component .rcache_size_limit )) ==
437+ OPAL_ERR_TEMP_OUT_OF_RESOURCE ) {
438+ opal_output_verbose (40 , mca_mpool_rgpusm_component .output ,
439+ "RGPUSM: No room in the cache - boot one out" );
440+ if (!mca_mpool_rgpusm_deregister_lru (mpool )) {
441+ break ;
442+ }
443+ }
421444 }
422445 }
423446 RESTORE_PAGE_ALIGNMENT ();
0 commit comments