Changeset 683 for trunk/kernel/mm/ppm.c
- Timestamp:
- Jan 13, 2021, 12:36:17 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/ppm.c
r672 r683 60 60 61 61 void * base_ptr = ppm->vaddr_base + 62 ((page_ptr - ppm->pages_tbl)<<CONFIG_PPM_PAGE_ SHIFT);62 ((page_ptr - ppm->pages_tbl)<<CONFIG_PPM_PAGE_ORDER); 63 63 64 64 return XPTR( page_cxy , base_ptr ); … … 75 75 76 76 page_t * page_ptr = ppm->pages_tbl + 77 ((base_ptr - ppm->vaddr_base)>>CONFIG_PPM_PAGE_ SHIFT);77 ((base_ptr - ppm->vaddr_base)>>CONFIG_PPM_PAGE_ORDER); 78 78 79 79 return XPTR( base_cxy , page_ptr ); … … 91 91 page_t * page_ptr = GET_PTR( page_xp ); 92 92 93 paddr_t paddr = PADDR( page_cxy , (page_ptr - ppm->pages_tbl)<<CONFIG_PPM_PAGE_ SHIFT);94 95 return (ppn_t)(paddr >> CONFIG_PPM_PAGE_ SHIFT);93 paddr_t paddr = PADDR( page_cxy , (page_ptr - ppm->pages_tbl)<<CONFIG_PPM_PAGE_ORDER ); 94 95 return (ppn_t)(paddr >> CONFIG_PPM_PAGE_ORDER); 96 96 97 97 } // end hal_page2ppn() … … 102 102 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 103 103 104 paddr_t paddr = ((paddr_t)ppn) << CONFIG_PPM_PAGE_ SHIFT;104 paddr_t paddr = ((paddr_t)ppn) << CONFIG_PPM_PAGE_ORDER; 105 105 106 106 cxy_t cxy = CXY_FROM_PADDR( paddr ); 107 107 lpa_t lpa = LPA_FROM_PADDR( paddr ); 108 108 109 return XPTR( cxy , &ppm->pages_tbl[lpa>>CONFIG_PPM_PAGE_ SHIFT] );109 return XPTR( cxy , &ppm->pages_tbl[lpa>>CONFIG_PPM_PAGE_ORDER] ); 110 110 111 111 } // end hal_ppn2page … … 118 118 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 119 119 120 paddr_t paddr = ((paddr_t)ppn) << CONFIG_PPM_PAGE_ SHIFT;120 paddr_t paddr = ((paddr_t)ppn) << CONFIG_PPM_PAGE_ORDER; 121 121 122 122 cxy_t cxy = CXY_FROM_PADDR( paddr ); … … 137 137 paddr_t paddr = PADDR( base_cxy , (base_ptr - ppm->vaddr_base) ); 138 138 139 return (ppn_t)(paddr >> CONFIG_PPM_PAGE_ SHIFT);139 return (ppn_t)(paddr >> CONFIG_PPM_PAGE_ORDER); 140 140 141 141 } // end ppm_base2ppn() … … 159 159 160 160 assert( __FUNCTION__, !page_is_flag( page , PG_FREE ) , 161 "page already released : ppn = %x \n" , ppm_page2ppn( XPTR( local_cxy , page ) ) );161 "page already released : ppn = %x" , ppm_page2ppn( XPTR( local_cxy , page ) ) ); 162 162 163 163 assert( __FUNCTION__, !page_is_flag( page , PG_RESERVED ) , 164 "reserved page : ppn = %x \n" , ppm_page2ppn( XPTR( local_cxy , page ) ) );164 "reserved page : ppn = %x" , ppm_page2ppn( XPTR( local_cxy , page ) ) ); 165 165 166 166 // set FREE flag in released page descriptor … … 214 214 page_t * found_block; 215 215 216 thread_t * this = CURRENT_THREAD;217 218 216 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 219 217 220 #if DEBUG_PPM_ALLOC_PAGES 221 uint32_t cycle = (uint32_t)hal_get_cycles(); 218 #if DEBUG_PPM_ALLOC_PAGES || DEBUG_PPM_ERROR 219 thread_t * this = CURRENT_THREAD; 220 uint32_t cycle = (uint32_t)hal_get_cycles(); 222 221 #endif 223 222 … … 232 231 233 232 // check order 234 assert( __FUNCTION__, (order < CONFIG_PPM_MAX_ORDER) , "illegal order argument = %d\n" , order ); 233 assert( __FUNCTION__, (order < CONFIG_PPM_MAX_ORDER) , 234 "illegal order argument = %d" , order ); 235 235 236 236 //build extended pointer on lock protecting remote PPM … … 273 273 if( current_block == NULL ) // return failure if no free block found 274 274 { 275 // release lock protecting free lists 275 276 #if DEBUG_PPM_ERROR 277 printk("\n[ERROR] in %s thread[%x,%x] cannot allocate %d page(s) in cluster %x / cycle %d\n", 278 __FUNCTION__, this->process->pid, this->trdid, 1<<order, local_cxy, cycle ); 279 #endif 280 // release lock protecting free lists 276 281 remote_busylock_release( lock_xp ); 277 278 printk("\n[%s] thread[%x,%x] cannot allocate %d page(s) in cluster %x\n",279 __FUNCTION__, this->process->pid, this->trdid, 1<<order, local_cxy );280 281 282 return NULL; 282 283 } … … 385 386 page_t * found_block; 386 387 387 thread_t * this = CURRENT_THREAD;388 389 388 // check order 390 assert( __FUNCTION__, (order < CONFIG_PPM_MAX_ORDER) , "illegal order argument = %d\n" , order ); 389 assert( __FUNCTION__, (order < CONFIG_PPM_MAX_ORDER) , 390 "illegal order argument = %d" , order ); 391 391 392 392 // get local pointer on PPM (same in all clusters) 393 393 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 394 394 395 #if DEBUG_PPM_REMOTE_ALLOC_PAGES 395 #if DEBUG_PPM_ALLOC_PAGES || DEBUG_PPM_ERROR 396 thread_t * this = CURRENT_THREAD; 396 397 uint32_t cycle = (uint32_t)hal_get_cycles(); 397 398 #endif 398 399 399 #if DEBUG_PPM_ REMOTE_ALLOC_PAGES400 if( DEBUG_PPM_ REMOTE_ALLOC_PAGES < cycle )400 #if DEBUG_PPM_ALLOC_PAGES 401 if( DEBUG_PPM_ALLOC_PAGES < cycle ) 401 402 { 402 403 printk("\n[%s] thread[%x,%x] enter for %d page(s) in cluster %x / cycle %d\n", 403 404 __FUNCTION__, this->process->pid, this->trdid, 1<<order, cxy, cycle ); 404 if( DEBUG_PPM_ REMOTE_ALLOC_PAGES & 1 ) ppm_remote_display( cxy );405 if( DEBUG_PPM_ALLOC_PAGES & 1 ) ppm_remote_display( cxy ); 405 406 } 406 407 #endif … … 445 446 if( current_block == NULL ) // return failure 446 447 { 448 449 #if DEBUG_PPM_ERROR 450 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate %d page(s) in cluster %x / cycle %d\n", 451 __FUNCTION__, this->process->pid, this->trdid, 1<<order, cxy, cycle ); 452 #endif 447 453 // release lock protecting free lists 448 454 remote_busylock_release( lock_xp ); 449 450 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate %d page(s) in cluster %x\n",451 __FUNCTION__, this->process->pid, this->trdid, 1<<order, cxy );452 453 455 return XPTR_NULL; 454 456 } … … 489 491 hal_fence(); 490 492 491 #if DEBUG_PPM_ REMOTE_ALLOC_PAGES492 if( DEBUG_PPM_ REMOTE_ALLOC_PAGES < cycle )493 #if DEBUG_PPM_ALLOC_PAGES 494 if( DEBUG_PPM_ALLOC_PAGES < cycle ) 493 495 { 494 496 printk("\n[%s] thread[%x,%x] allocated %d page(s) in cluster %x / ppn %x / cycle %d\n", 495 497 __FUNCTION__, this->process->pid, this->trdid, 496 498 1<<order, cxy, ppm_page2ppn(XPTR( cxy , found_block )), cycle ); 497 if( DEBUG_PPM_ REMOTE_ALLOC_PAGES & 1 ) ppm_remote_display( cxy );499 if( DEBUG_PPM_ALLOC_PAGES & 1 ) ppm_remote_display( cxy ); 498 500 } 499 501 #endif … … 521 523 uint32_t order = hal_remote_l32( XPTR( page_cxy , &page_ptr->order ) ); 522 524 523 #if DEBUG_PPM_ REMOTE_FREE_PAGES525 #if DEBUG_PPM_FREE_PAGES 524 526 thread_t * this = CURRENT_THREAD; 525 527 uint32_t cycle = (uint32_t)hal_get_cycles(); … … 527 529 #endif 528 530 529 #if DEBUG_PPM_ REMOTE_FREE_PAGES530 if( DEBUG_PPM_ REMOTE_FREE_PAGES < cycle )531 #if DEBUG_PPM_FREE_PAGES 532 if( DEBUG_PPM_FREE_PAGES < cycle ) 531 533 { 532 534 printk("\n[%s] thread[%x,%x] enter for %d page(s) in cluster %x / ppn %x / cycle %d\n", 533 535 __FUNCTION__, this->process->pid, this->trdid, 1<<order, page_cxy, ppn, cycle ); 534 if( DEBUG_PPM_ REMOTE_FREE_PAGES & 1 ) ppm_remote_display( page_cxy );536 if( DEBUG_PPM_FREE_PAGES & 1 ) ppm_remote_display( page_cxy ); 535 537 } 536 538 #endif … … 549 551 550 552 assert( __FUNCTION__, !page_remote_is_flag( page_xp , PG_FREE ) , 551 "page already released : ppn = %x \n" , ppm_page2ppn(XPTR( page_cxy , page_ptr ) ) );553 "page already released : ppn = %x" , ppm_page2ppn(XPTR( page_cxy , page_ptr ) ) ); 552 554 553 555 assert( __FUNCTION__, !page_remote_is_flag( page_xp , PG_RESERVED ) , 554 "reserved page : ppn = %x \n" , ppm_page2ppn(XPTR( page_cxy , page_ptr ) ) );556 "reserved page : ppn = %x" , ppm_page2ppn(XPTR( page_cxy , page_ptr ) ) ); 555 557 556 558 // set the FREE flag in released page descriptor … … 607 609 hal_fence(); 608 610 609 #if DEBUG_PPM_ REMOTE_FREE_PAGES610 if( DEBUG_PPM_ REMOTE_FREE_PAGES < cycle )611 #if DEBUG_PPM_FREE_PAGES 612 if( DEBUG_PPM_FREE_PAGES < cycle ) 611 613 { 612 614 printk("\n[%s] thread[%x,%x] released %d page(s) in cluster %x / ppn %x / cycle %d\n", 613 615 __FUNCTION__, this->process->pid, this->trdid, 1<<order, page_cxy, ppn, cycle ); 614 if( DEBUG_PPM_ REMOTE_FREE_PAGES & 1 ) ppm_remote_display( page_cxy );616 if( DEBUG_PPM_FREE_PAGES & 1 ) ppm_remote_display( page_cxy ); 615 617 } 616 618 #endif
Note: See TracChangeset
for help on using the changeset viewer.