Changeset 656 for trunk/kernel/mm/ppm.c
- Timestamp:
- Dec 6, 2019, 12:07:51 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/ppm.c
r651 r656 151 151 page_t * buddy; // searched buddy page descriptor 152 152 uint32_t buddy_index; // buddy page index in page_tbl[] 153 page_t * current ;// current (merged) page descriptor153 page_t * current_ptr; // current (merged) page descriptor 154 154 uint32_t current_index; // current (merged) page index in page_tbl[] 155 155 uint32_t current_order; // current (merged) page order … … 168 168 169 169 // initialise loop variables 170 current 170 current_ptr = page; 171 171 current_order = page->order; 172 172 current_index = page - ppm->pages_tbl; … … 191 191 buddy->order = 0; 192 192 193 // compute next (merged) page index in page_tbl[]193 // compute next values for loop variables 194 194 current_index &= buddy_index; 195 196 // compute next (merged) page order197 195 current_order++; 198 199 // compute next (merged) page descripror 200 current = pages_tbl + current_index; 196 current_ptr = pages_tbl + current_index; 201 197 } 202 198 203 199 // update order field for merged page descriptor 204 current ->order = current_order;200 current_ptr->order = current_order; 205 201 206 202 // insert merged page in relevant free list 207 list_add_first( &ppm->free_pages_root[current_order] , ¤t ->list );203 list_add_first( &ppm->free_pages_root[current_order] , ¤t_ptr->list ); 208 204 ppm->free_pages_nr[current_order] ++; 209 205 210 206 } // end ppm_free_pages_nolock() 211 212 207 213 208 //////////////////////////////////////////// … … 221 216 thread_t * this = CURRENT_THREAD; 222 217 218 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 219 223 220 #if DEBUG_PPM_ALLOC_PAGES 224 221 uint32_t cycle = (uint32_t)hal_get_cycles(); 225 222 #endif 226 223 227 #if (DEBUG_PPM_ALLOC_PAGES & 1)224 #if DEBUG_PPM_ALLOC_PAGES 228 225 if( DEBUG_PPM_ALLOC_PAGES < cycle ) 229 226 { 230 227 printk("\n[%s] thread[%x,%x] enter for %d page(s) in cluster %x / cycle %d\n", 231 228 __FUNCTION__, this->process->pid, this->trdid, 1<<order, local_cxy, cycle ); 232 ppm_remote_display( local_cxy ); 233 } 234 #endif 235 236 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 229 if( DEBUG_PPM_ALLOC_PAGES & 1 ) ppm_remote_display( local_cxy ); 230 } 231 #endif 237 232 238 233 // check order … … 316 311 dqdt_increment_pages( local_cxy , order ); 317 312 313 hal_fence(); 314 318 315 #if DEBUG_PPM_ALLOC_PAGES 319 316 if( DEBUG_PPM_ALLOC_PAGES < cycle ) … … 322 319 __FUNCTION__, this->process->pid, this->trdid, 323 320 1<<order, local_cxy, ppm_page2ppn(XPTR( local_cxy , found_block )), cycle ); 324 ppm_remote_display( local_cxy );321 if( DEBUG_PPM_ALLOC_PAGES & 1 ) ppm_remote_display( local_cxy ); 325 322 } 326 323 #endif … … 340 337 #endif 341 338 342 #if ( DEBUG_PPM_FREE_PAGES & 1 )339 #if DEBUG_PPM_FREE_PAGES 343 340 if( DEBUG_PPM_FREE_PAGES < cycle ) 344 341 { … … 346 343 __FUNCTION__, this->process->pid, this->trdid, 347 344 1<<page->order, local_cxy, ppm_page2ppn(XPTR(local_cxy , page)), cycle ); 348 ppm_remote_display( local_cxy ); 345 if( DEBUG_PPM_FREE_PAGES & 1 ) ppm_remote_display( local_cxy ); 346 } 349 347 #endif 350 348 … … 362 360 // update DQDT 363 361 dqdt_decrement_pages( local_cxy , page->order ); 362 363 hal_fence(); 364 364 365 365 #if DEBUG_PPM_FREE_PAGES … … 369 369 __FUNCTION__, this->process->pid, this->trdid, 370 370 1<<page->order, local_cxy, ppm_page2ppn(XPTR(local_cxy , page)) , cycle ); 371 ppm_remote_display( local_cxy );371 if( DEBUG_PPM_FREE_PAGES & 1 ) ppm_remote_display( local_cxy ); 372 372 } 373 373 #endif … … 376 376 377 377 378 379 380 378 ///////////////////////////////////////////// 381 void *ppm_remote_alloc_pages( cxy_t cxy,379 xptr_t ppm_remote_alloc_pages( cxy_t cxy, 382 380 uint32_t order ) 383 381 { … … 389 387 thread_t * this = CURRENT_THREAD; 390 388 389 // check order 390 assert( (order < CONFIG_PPM_MAX_ORDER) , "illegal order argument = %d\n" , order ); 391 392 // get local pointer on PPM (same in all clusters) 393 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 394 391 395 #if DEBUG_PPM_REMOTE_ALLOC_PAGES 392 396 uint32_t cycle = (uint32_t)hal_get_cycles(); 393 397 #endif 394 398 395 #if ( DEBUG_PPM_REMOTE_ALLOC_PAGES & 1 )399 #if DEBUG_PPM_REMOTE_ALLOC_PAGES 396 400 if( DEBUG_PPM_REMOTE_ALLOC_PAGES < cycle ) 397 401 { 398 printk("\n[%s] thread[%x,%x] enter for %d smallpage(s) in cluster %x / cycle %d\n",402 printk("\n[%s] thread[%x,%x] enter for %d page(s) in cluster %x / cycle %d\n", 399 403 __FUNCTION__, this->process->pid, this->trdid, 1<<order, cxy, cycle ); 400 ppm_remote_display( cxy ); 401 } 402 #endif 403 404 // check order 405 assert( (order < CONFIG_PPM_MAX_ORDER) , "illegal order argument = %d\n" , order ); 406 407 // get local pointer on PPM (same in all clusters) 408 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 404 if( DEBUG_PPM_REMOTE_ALLOC_PAGES & 1 ) ppm_remote_display( cxy ); 405 } 406 #endif 409 407 410 408 //build extended pointer on lock protecting remote PPM … … 489 487 dqdt_increment_pages( cxy , order ); 490 488 489 hal_fence(); 490 491 491 #if DEBUG_PPM_REMOTE_ALLOC_PAGES 492 492 if( DEBUG_PPM_REMOTE_ALLOC_PAGES < cycle ) … … 495 495 __FUNCTION__, this->process->pid, this->trdid, 496 496 1<<order, cxy, ppm_page2ppn(XPTR( cxy , found_block )), cycle ); 497 ppm_remote_display( cxy );498 } 499 #endif 500 501 return found_block;497 if( DEBUG_PPM_REMOTE_ALLOC_PAGES & 1 ) ppm_remote_display( cxy ); 498 } 499 #endif 500 501 return XPTR( cxy , found_block ); 502 502 503 503 } // end ppm_remote_alloc_pages() … … 515 515 uint32_t current_order; // current (merged) page order 516 516 517 // get local pointer on PPM (same in all clusters) 518 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 519 520 // get page ppn and order 521 uint32_t order = hal_remote_l32( XPTR( page_cxy , &page_ptr->order ) ); 522 517 523 #if DEBUG_PPM_REMOTE_FREE_PAGES 518 524 thread_t * this = CURRENT_THREAD; 519 525 uint32_t cycle = (uint32_t)hal_get_cycles(); 520 #endif 521 522 #if ( DEBUG_PPM_REMOTE_FREE_PAGES & 1 ) 526 ppn_t ppn = ppm_page2ppn( XPTR( page_cxy , page_ptr ) ); 527 #endif 528 529 #if DEBUG_PPM_REMOTE_FREE_PAGES 523 530 if( DEBUG_PPM_REMOTE_FREE_PAGES < cycle ) 524 531 { 525 532 printk("\n[%s] thread[%x,%x] enter for %d page(s) in cluster %x / ppn %x / cycle %d\n", 526 __FUNCTION__, this->process->pid, this->trdid, 527 1<<page_ptr->order, page_cxy, ppm_page2ppn(XPTR( page_cxy , page_ptr )), cycle ); 528 ppm_remote_display( page_cxy ); 533 __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 ); 529 535 } 530 536 #endif … … 533 539 page_xp = XPTR( page_cxy , page_ptr ); 534 540 535 // get local pointer on PPM (same in all clusters)536 ppm_t * ppm = &LOCAL_CLUSTER->ppm;537 538 541 // build extended pointer on lock protecting remote PPM 539 542 xptr_t lock_xp = XPTR( page_cxy , &ppm->free_lock ); … … 556 559 // initialise loop variables 557 560 current_ptr = page_ptr; 558 current_order = hal_remote_l32( XPTR( page_cxy , &page_ptr->order ) );561 current_order = order; 559 562 current_index = page_ptr - ppm->pages_tbl; 560 563 … … 582 585 hal_remote_s32( XPTR( page_cxy , &buddy_ptr->order ) , 0 ); 583 586 584 // compute next (merged) page index in page_tbl[]587 // compute next values for loop variables 585 588 current_index &= buddy_index; 586 587 // compute next (merged) page order588 589 current_order++; 589 590 // compute next (merged) page descripror591 590 current_ptr = pages_tbl + current_index; 592 591 … … 594 593 595 594 // update current (merged) page descriptor order field 596 current_ptr = pages_tbl + current_index;597 595 hal_remote_s32( XPTR( page_cxy , ¤t_ptr->order ) , current_order ); 598 596 599 597 // insert current (merged) page into relevant free list 600 list_remote_add_first( page_cxy , &ppm->free_pages_root[current_order], ¤t_ptr->list );598 list_remote_add_first( page_cxy, &ppm->free_pages_root[current_order], ¤t_ptr->list ); 601 599 hal_remote_atomic_add( XPTR( page_cxy , &ppm->free_pages_nr[current_order] ) , 1 ); 602 600 … … 607 605 dqdt_decrement_pages( page_cxy , page_ptr->order ); 608 606 607 hal_fence(); 608 609 609 #if DEBUG_PPM_REMOTE_FREE_PAGES 610 610 if( DEBUG_PPM_REMOTE_FREE_PAGES < cycle ) 611 611 { 612 612 printk("\n[%s] thread[%x,%x] released %d page(s) in cluster %x / ppn %x / cycle %d\n", 613 __FUNCTION__, this->process->pid, this->trdid, 614 1<<page_ptr->order, page_cxy, ppm_page2ppn(XPTR( page_cxy , page_ptr ) ), cycle ); 615 ppm_remote_display( page_cxy ); 613 __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 615 } 617 616 #endif … … 658 657 uint32_t n = hal_remote_l32( XPTR( cxy , &ppm->free_pages_nr[order] ) ); 659 658 660 // display directfree_list[order]661 nolock_printk("- forward : order = %d / n = %d \t: ", order , n );659 // display forward free_list[order] 660 nolock_printk("- forward : order = %d / n = %d : ", order , n ); 662 661 LIST_REMOTE_FOREACH( cxy , &ppm->free_pages_root[order] , iter ) 662 { 663 page_xp = XPTR( cxy , LIST_ELEMENT( iter , page_t , list ) ); 664 nolock_printk("%x," , ppm_page2ppn( page_xp ) ); 665 } 666 nolock_printk("\n"); 667 668 // display backward free_list[order] 669 nolock_printk("- backward : order = %d / n = %d : ", order , n ); 670 LIST_REMOTE_FOREACH_BACKWARD( cxy , &ppm->free_pages_root[order] , iter ) 663 671 { 664 672 page_xp = XPTR( cxy , LIST_ELEMENT( iter , page_t , list ) );
Note: See TracChangeset
for help on using the changeset viewer.