Changeset 657 for trunk/kernel/mm/kcm.c
- Timestamp:
- Mar 18, 2020, 11:16:59 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/kcm.c
r656 r657 43 43 ////////////////////////////////////////////////////////////////////////////////////// 44 44 // This static function must be called by a local thread. 45 // It returns a pointer on a block allocated from a non-fullkcm_page.46 // It makes a panic if no block is available in selected page.45 // It returns a pointer on a block allocated from an active kcm_page. 46 // It makes a panic if no block is available in the selected page. 47 47 // It changes the page status as required. 48 48 ////////////////////////////////////////////////////////////////////////////////////// 49 49 // @ kcm : pointer on KCM allocator. 50 // @ kcm_page : pointer on a non-fullkcm_page.50 // @ kcm_page : pointer on an active kcm_page. 51 51 // @ return pointer on allocated block. 52 52 ///////////////////////////////////////////////////////////////////////////////////// … … 64 64 uint32_t index = 1; 65 65 uint64_t mask = (uint64_t)0x2; 66 uint32_t found = 0;67 66 68 67 // allocate first free block in kcm_page, update status, … … 70 69 while( index <= max ) 71 70 { 72 if( (status & mask) == 0 ) // block non allocated71 if( (status & mask) == 0 ) // block found 73 72 { 73 // update page count and status 74 74 kcm_page->status = status | mask; 75 75 kcm_page->count = count + 1; 76 found = 1;77 78 76 break; 79 77 } … … 83 81 } 84 82 85 // change the page list if almost full83 // change the page list if found block is the last 86 84 if( count == max-1 ) 87 85 { … … 162 160 163 161 ///////////////////////////////////////////////////////////////////////////////////// 164 // This privatestatic function must be called by a local thread.165 // It returns one non-full kcm_page with t e following policy :162 // This static function must be called by a local thread. 163 // It returns one non-full kcm_page with the following policy : 166 164 // - if the "active_list" is non empty, it returns the first "active" page, 167 165 // without modifying the KCM state. 168 // - if the "active_list" is empty, it allocates a new page from mPPM, inserts166 // - if the "active_list" is empty, it allocates a new page from PPM, inserts 169 167 // this page in the active_list, and returns it. 170 168 ///////////////////////////////////////////////////////////////////////////////////// … … 275 273 // release KCM lock 276 274 remote_busylock_release( lock_xp ); 277 } 275 276 } // end kcm_destroy() 278 277 279 278 ////////////////////////////////// … … 284 283 void * block_ptr; 285 284 286 285 // min block size is 64 bytes 287 286 if( order < 6 ) order = 6; 288 287 … … 301 300 kcm_page = kcm_get_page( kcm_ptr ); 302 301 302 #if DEBUG_KCM 303 thread_t * this = CURRENT_THREAD; 304 uint32_t cycle = (uint32_t)hal_get_cycles(); 305 if( (DEBUG_KCM < cycle) && (local_cxy == 1) ) 306 { 307 printk("\n[%s] thread[%x,%x] enters / order %d / page %x / kcm %x / page_status (%x|%x)\n", 308 __FUNCTION__, this->process->pid, this->trdid, order, kcm_page, kcm_ptr, 309 GET_CXY( kcm_page->status ), GET_PTR( kcm_page->status ) ); 310 kcm_remote_display( local_cxy , kcm_ptr ); 311 } 312 #endif 313 303 314 if( kcm_page == NULL ) 304 315 { … … 314 325 315 326 #if DEBUG_KCM 316 thread_t * this = CURRENT_THREAD; 317 uint32_t cycle = (uint32_t)hal_get_cycles(); 318 if( DEBUG_KCM < cycle ) 319 printk("\n[%s] thread[%x,%x] allocated block %x / order %d / kcm %x / status[%x,%x] / count %d\n", 320 __FUNCTION__, this->process->pid, this->trdid, block_ptr, order, kcm_ptr, 321 GET_CXY(kcm_page->status), GET_PTR(kcm_page->status), kcm_page->count ); 327 if( (DEBUG_KCM < cycle) && (local_cxy == 1) ) 328 { 329 printk("\n[%s] thread[%x,%x] exit / order %d / block %x / kcm %x / page_status (%x|%x)\n", 330 __FUNCTION__, this->process->pid, this->trdid, order, block_ptr, kcm_ptr, 331 GET_CXY( kcm_page->status ), GET_PTR( kcm_page->status ) ); 332 kcm_remote_display( local_cxy , kcm_ptr ); 333 } 322 334 #endif 323 335 … … 344 356 thread_t * this = CURRENT_THREAD; 345 357 uint32_t cycle = (uint32_t)hal_get_cycles(); 346 if( DEBUG_KCM < cycle ) 347 printk("\n[%s] thread[%x,%x] release block %x / order %d / kcm %x / status [%x,%x] / count %d\n", 348 __FUNCTION__, this->process->pid, this->trdid, block_ptr, kcm_ptr->order, kcm_ptr, 349 GET_CXY(kcm_page->status), GET_PTR(kcm_page->status), kcm_page->count ); 358 if( (DEBUG_KCM < cycle) && (local_cxy == 1) ) 359 { 360 printk("\n[%s] thread[%x,%x] enters / order %d / block %x / page %x / kcm %x / status [%x,%x]\n", 361 __FUNCTION__, this->process->pid, this->trdid, kcm_ptr->order, block_ptr, kcm_page, kcm_ptr, 362 GET_CXY(kcm_page->status), GET_PTR(kcm_page->status) ); 363 kcm_remote_display( local_cxy , kcm_ptr ); 364 } 350 365 #endif 351 366 … … 361 376 // release lock 362 377 remote_busylock_release( lock_xp ); 378 379 #if DEBUG_KCM 380 if( (DEBUG_KCM < cycle) && (local_cxy == 1) ) 381 { 382 printk("\n[%s] thread[%x,%x] exit / order %d / page %x / status [%x,%x]\n", 383 __FUNCTION__, this->process->pid, this->trdid, kcm_ptr->order, kcm_ptr, 384 GET_CXY(kcm_page->status), GET_PTR(kcm_page->status) ); 385 kcm_remote_display( local_cxy , kcm_ptr ); 363 386 } 387 #endif 388 389 } // end kcm_free() 364 390 365 391 ///////////////////////////////////////////////////////////////////////////////////// … … 369 395 ///////////////////////////////////////////////////////////////////////////////////// 370 396 // This static function can be called by any thread running in any cluster. 371 // It returns a local pointer on a block allocated from an non-fullkcm_page.372 // It makes a panic if no block available in selectedpage.397 // It returns a local pointer on a block allocated from an active kcm_page. 398 // It makes a panic if no block available in the selected kcm_page. 373 399 // It changes the page status as required. 374 400 ///////////////////////////////////////////////////////////////////////////////////// 375 // @ kcm_cxy : remote KCM cluster identi dfier.401 // @ kcm_cxy : remote KCM cluster identifier. 376 402 // @ kcm_ptr : local pointer on remote KCM allocator. 377 // @ kcm_page : pointer on active kcmpage to use.403 // @ kcm_page : local pointer on remote active kcm_page to use. 378 404 // @ return a local pointer on the allocated block. 379 405 ///////////////////////////////////////////////////////////////////////////////////// … … 392 418 uint32_t index = 1; 393 419 uint64_t mask = (uint64_t)0x2; 394 uint32_t found = 0;395 420 396 421 // allocate first free block in kcm_page, update status, … … 398 423 while( index <= max ) 399 424 { 400 if( (status & mask) == 0 ) // block non allocated425 if( (status & mask) == 0 ) // block found 401 426 { 402 427 hal_remote_s64( XPTR( kcm_cxy , &kcm_page->status ) , status | mask ); 403 hal_remote_s64( XPTR( kcm_cxy , &kcm_page->count ) , count + 1 ); 404 found = 1; 428 hal_remote_s32( XPTR( kcm_cxy , &kcm_page->count ) , count + 1 ); 405 429 break; 406 430 } … … 410 434 } 411 435 412 // change the page list if almost full436 // change the page list if found block is the last 413 437 if( count == max-1 ) 414 438 { … … 631 655 kcm_t * kcm_ptr ) 632 656 { 657 list_entry_t * iter; 658 kcm_page_t * kcm_page; 659 uint64_t status; 660 uint32_t count; 661 633 662 uint32_t order = hal_remote_l32( XPTR( kcm_cxy , &kcm_ptr->order) ); 634 663 uint32_t full_pages_nr = hal_remote_l32( XPTR( kcm_cxy , &kcm_ptr->full_pages_nr ) ); 635 664 uint32_t active_pages_nr = hal_remote_l32( XPTR( kcm_cxy , &kcm_ptr->active_pages_nr ) ); 636 665 637 printk("*** KCM / cxy %x / order %d / full_pages %d / empty_pages %d / active_pages%d\n",666 printk("*** KCM : cxy %x / order %d / full_pages_nr %d / active_pages_nr %d\n", 638 667 kcm_cxy, order, full_pages_nr, active_pages_nr ); 639 } 668 669 if( active_pages_nr ) 670 { 671 LIST_REMOTE_FOREACH( kcm_cxy , &kcm_ptr->active_root , iter ) 672 { 673 kcm_page = LIST_ELEMENT( iter , kcm_page_t , list ); 674 status = hal_remote_l64( XPTR( kcm_cxy , &kcm_page->status ) ); 675 count = hal_remote_l32( XPTR( kcm_cxy , &kcm_page->count ) ); 676 677 printk("- active page %x / status (%x,%x) / count %d\n", 678 kcm_page, GET_CXY( status ), GET_PTR( status ), count ); 679 } 680 } 681 682 if( full_pages_nr ) 683 { 684 LIST_REMOTE_FOREACH( kcm_cxy , &kcm_ptr->full_root , iter ) 685 { 686 kcm_page = LIST_ELEMENT( iter , kcm_page_t , list ); 687 status = hal_remote_l64( XPTR( kcm_cxy , &kcm_page->status ) ); 688 count = hal_remote_l32( XPTR( kcm_cxy , &kcm_page->count ) ); 689 690 printk("- full page %x / status (%x,%x) / count %d\n", 691 kcm_page, GET_CXY( status ), GET_PTR( status ), count ); 692 } 693 } 694 } // end kcm remote_display()
Note: See TracChangeset
for help on using the changeset viewer.