Changeset 683 for trunk/kernel/mm/mapper.c
- Timestamp:
- Jan 13, 2021, 12:36:17 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/mapper.c
r672 r683 3 3 * 4 4 * Authors Mohamed Lamine Karaoui (2015) 5 * Alain Greiner (2016,2017,2018,2019,2020)5 * Alain Greiner (2016,2017,2018,2019,2020) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites … … 51 51 { 52 52 mapper_t * mapper_ptr; 53 kmem_req_t req;54 53 error_t error; 55 54 56 55 // allocate memory for mapper descriptor 57 req.type = KMEM_KCM; 58 req.order = bits_log2( sizeof(mapper_t) ); 59 req.flags = AF_KERNEL | AF_ZERO; 60 mapper_ptr = kmem_remote_alloc( cxy , &req ); 56 mapper_ptr = kmem_remote_alloc( cxy , bits_log2(sizeof(mapper_t)) , AF_ZERO ); 61 57 62 58 if( mapper_ptr == NULL ) 63 59 { 64 printk("\n[ERROR] in %s : no memory for mapper descriptor\n", __FUNCTION__ ); 60 61 #if DEBUG_MAPPER_ERROR 62 printk("\n[ERROR] in %s : no memory for mapper descriptor\n", __FUNCTION__ ); 63 #endif 65 64 return XPTR_NULL; 66 65 } … … 77 76 if( error ) 78 77 { 79 printk("\n[ERROR] in %s : cannot initialize radix tree\n", __FUNCTION__ ); 80 req.type = KMEM_KCM; 81 req.ptr = mapper_ptr; 82 kmem_remote_free( cxy , &req ); 78 79 #if DEBUG_MAPPER_ERROR 80 printk("\n[ERROR] in %s : cannot initialize radix tree\n", __FUNCTION__ ); 81 kmem_remote_free( cxy , mapper_ptr , bits_log2(sizeof(mapper_t)) ); 82 #endif 83 83 return XPTR_NULL; 84 84 } … … 104 104 uint32_t found_index = 0; 105 105 uint32_t start_index = 0; 106 kmem_req_t req;107 106 108 107 cxy_t mapper_cxy = GET_CXY( mapper_xp ); … … 137 136 138 137 // release memory for mapper descriptor 139 req.type = KMEM_KCM; 140 req.ptr = mapper_ptr; 141 kmem_remote_free( mapper_cxy , &req ); 138 kmem_remote_free( mapper_cxy , mapper_ptr , bits_log2(sizeof(mapper_t)) ); 142 139 143 140 } // end mapper_destroy() … … 153 150 uint32_t inode_type = 0; 154 151 155 thread_t * this = CURRENT_THREAD; 152 #if DEBUG_MAPPER_HANDLE_MISS || DEBUG_MAPPER_ERROR 153 thread_t * this = CURRENT_THREAD; 154 uint32_t cycle = (uint32_t)hal_get_cycles(); 155 #endif 156 156 157 157 // get target mapper cluster and local pointer … … 170 170 171 171 #if DEBUG_MAPPER_HANDLE_MISS 172 uint32_t cycle = (uint32_t)hal_get_cycles();173 172 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 174 173 if( (DEBUG_MAPPER_HANDLE_MISS < cycle) && (inode != NULL) ) … … 185 184 #endif 186 185 187 #if( DEBUG_MAPPER_HANDLE_MISS & 2)186 #if( DEBUG_MAPPER_HANDLE_MISS & 1 ) 188 187 if( DEBUG_MAPPER_HANDLE_MISS < cycle ) 189 188 { … … 193 192 #endif 194 193 195 // allocate one 4 Kbytes page from the remote mapper cluster 196 xptr_t page_xp = ppm_remote_alloc_pages( mapper_cxy , 0 ); 194 // allocate one 4 Kbytes page in the remote mapper cluster 195 void * base_ptr = kmem_remote_alloc( mapper_cxy , 12 , AF_NONE ); 196 197 if( base_ptr == NULL ) 198 { 199 200 #if DEBUG_MAPPER_ERROR 201 printk("\n[ERROR] in %s : thread [%x,%x] cannot allocate page in cluster %x / cycle %d\n", 202 __FUNCTION__ , this->process->pid, this->trdid , mapper_cxy , cycle ); 203 #endif 204 return -1; 205 } 206 207 // get pointers on allocated page descrptor 208 xptr_t page_xp = ppm_base2page( XPTR( mapper_cxy , base_ptr ) ); 197 209 page_t * page_ptr = GET_PTR( page_xp ); 198 199 if( page_xp == XPTR_NULL )200 {201 printk("\n[ERROR] in %s : thread [%x,%x] cannot allocate page in cluster %x\n",202 __FUNCTION__ , this->process->pid, this->trdid , mapper_cxy );203 return -1;204 }205 210 206 211 // initialize the page descriptor … … 217 222 page_id, 218 223 page_ptr ); 219 220 224 if( error ) 221 225 { 222 printk("\n[ERROR] in %s : thread[%x,%x] cannot insert page in mapper\n", 223 __FUNCTION__ , this->process->pid, this->trdid ); 224 ppm_remote_free_pages( mapper_cxy , page_ptr ); 226 227 #if DEBUG_MAPPER_ERROR 228 printk("\n[ERROR] in %s : thread[%x,%x] cannot insert page in mapper / cycle %d\n", 229 __FUNCTION__ , this->process->pid, this->trdid , cycle ); 230 ppm_remote_free_pages( mapper_cxy , page_ptr ); 231 #endif 225 232 return -1; 226 233 } … … 236 243 if( error ) 237 244 { 238 printk("\n[ERROR] in %s : thread[%x,%x] cannot load page from device\n", 239 __FUNCTION__ , this->process->pid, this->trdid ); 240 mapper_remote_release_page( mapper_xp , page_ptr ); 245 246 #if DEBUG_MAPPER_ERROR 247 printk("\n[ERROR] in %s : thread[%x,%x] cannot load page from device / cycle %d\n", 248 __FUNCTION__ , this->process->pid, this->trdid , cycle ); 249 mapper_remote_release_page( mapper_xp , page_ptr ); 250 #endif 241 251 return -1; 242 252 } … … 260 270 #endif 261 271 262 #if( DEBUG_MAPPER_HANDLE_MISS & 2)272 #if( DEBUG_MAPPER_HANDLE_MISS & 1 ) 263 273 if( DEBUG_MAPPER_HANDLE_MISS < cycle ) 264 274 { … … 299 309 #endif 300 310 301 #if( DEBUG_MAPPER_GET_PAGE & 2)311 #if( DEBUG_MAPPER_GET_PAGE & 1 ) 302 312 if( DEBUG_MAPPER_GET_PAGE < cycle ) 303 313 ppm_remote_display( local_cxy ); … … 336 346 if( error ) 337 347 { 338 printk("\n[ERROR] in %s : thread[%x,%x] cannot handle mapper miss\n", 339 __FUNCTION__ , this->process->pid, this->trdid ); 340 remote_rwlock_wr_release( lock_xp ); 348 349 #if DEBUG_MAPPER_ERROR 350 printk("\n[ERROR] in %s : thread[%x,%x] cannot handle mapper miss\n", 351 __FUNCTION__ , this->process->pid, this->trdid ); 352 remote_rwlock_wr_release( lock_xp ); 353 #endif 341 354 return XPTR_NULL; 342 355 } … … 364 377 #endif 365 378 366 #if( DEBUG_MAPPER_GET_PAGE & 2)379 #if( DEBUG_MAPPER_GET_PAGE & 1) 367 380 if( DEBUG_MAPPER_GET_PAGE < cycle ) 368 381 ppm_remote_display( local_cxy ); … … 432 445 if( error ) 433 446 { 434 printk("\n[ERROR] in %s : thread[%x,%x] cannot handle mapper miss\n", 435 __FUNCTION__ , this->process->pid, this->trdid ); 436 remote_rwlock_wr_release( lock_xp ); 447 448 #if DEBUG_MAPPER_ERROR 449 printk("\n[ERROR] in %s : thread[%x,%x] cannot handle mapper miss\n", 450 __FUNCTION__ , this->process->pid, this->trdid ); 451 remote_rwlock_wr_release( lock_xp ); 452 #endif 437 453 return XPTR_NULL; 438 454 } … … 460 476 #endif 461 477 462 #if( DEBUG_MAPPER_GET_FAT_PAGE & 2)478 #if( DEBUG_MAPPER_GET_FAT_PAGE & 1) 463 479 if( DEBUG_MAPPER_GET_FAT_PAGE < cycle ) 464 480 ppm_remote_display( local_cxy ); … … 532 548 533 549 // compute indexes of pages for first and last byte in mapper 534 uint32_t first = min_byte >> CONFIG_PPM_PAGE_ SHIFT;535 uint32_t last = max_byte >> CONFIG_PPM_PAGE_ SHIFT;550 uint32_t first = min_byte >> CONFIG_PPM_PAGE_ORDER; 551 uint32_t last = max_byte >> CONFIG_PPM_PAGE_ORDER; 536 552 537 553 #if (DEBUG_MAPPER_MOVE_USER & 1) … … 668 684 669 685 // compute indexes for first and last pages in mapper 670 uint32_t first = min_byte >> CONFIG_PPM_PAGE_ SHIFT;671 uint32_t last = max_byte >> CONFIG_PPM_PAGE_ SHIFT;686 uint32_t first = min_byte >> CONFIG_PPM_PAGE_ORDER; 687 uint32_t last = max_byte >> CONFIG_PPM_PAGE_ORDER; 672 688 673 689 // compute source and destination clusters … … 853 869 if( error ) 854 870 { 855 printk("\n[ERROR] in %s : cannot synchonize dirty page %d\n", 856 __FUNCTION__, page_ptr->index ); 871 872 #if DEBUG_MAPPER_SYNC 873 printk("\n[ERROR] in %s : cannot synchonize dirty page %d\n", 874 __FUNCTION__, page_ptr->index ); 875 #endif 857 876 return -1; 858 877 }
Note: See TracChangeset
for help on using the changeset viewer.