Changes in kernel/generic/src/mm/slab.c [4d194be:7ce7cfb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/slab.c
r4d194be r7ce7cfb 264 264 freed = cache->destructor(obj); 265 265 266 irq_spinlock_lock(&cache->slablock, true);266 spinlock_lock(&cache->slablock); 267 267 ASSERT(slab->available < cache->objects); 268 268 … … 275 275 /* Free associated memory */ 276 276 list_remove(&slab->link); 277 irq_spinlock_unlock(&cache->slablock, true);277 spinlock_unlock(&cache->slablock); 278 278 279 279 return freed + slab_space_free(cache, slab); … … 284 284 } 285 285 286 irq_spinlock_unlock(&cache->slablock, true);286 spinlock_unlock(&cache->slablock); 287 287 return freed; 288 288 } … … 295 295 NO_TRACE static void *slab_obj_create(slab_cache_t *cache, unsigned int flags) 296 296 { 297 irq_spinlock_lock(&cache->slablock, true);297 spinlock_lock(&cache->slablock); 298 298 299 299 slab_t *slab; … … 308 308 * 309 309 */ 310 irq_spinlock_unlock(&cache->slablock, true);310 spinlock_unlock(&cache->slablock); 311 311 slab = slab_space_alloc(cache, flags); 312 312 if (!slab) 313 313 return NULL; 314 314 315 irq_spinlock_lock(&cache->slablock, true);315 spinlock_lock(&cache->slablock); 316 316 } else { 317 317 slab = list_get_instance(list_first(&cache->partial_slabs), … … 329 329 list_prepend(&slab->link, &cache->partial_slabs); 330 330 331 irq_spinlock_unlock(&cache->slablock, true);331 spinlock_unlock(&cache->slablock); 332 332 333 333 if ((cache->constructor) && (cache->constructor(obj, flags))) { … … 355 355 link_t *cur; 356 356 357 irq_spinlock_lock(&cache->maglock, true);357 spinlock_lock(&cache->maglock); 358 358 if (!list_empty(&cache->magazines)) { 359 359 if (first) … … 366 366 atomic_dec(&cache->magazine_counter); 367 367 } 368 irq_spinlock_unlock(&cache->maglock, true);369 368 369 spinlock_unlock(&cache->maglock); 370 370 return mag; 371 371 } … … 377 377 slab_magazine_t *mag) 378 378 { 379 irq_spinlock_lock(&cache->maglock, true);379 spinlock_lock(&cache->maglock); 380 380 381 381 list_prepend(&mag->link, &cache->magazines); 382 382 atomic_inc(&cache->magazine_counter); 383 383 384 irq_spinlock_unlock(&cache->maglock, true);384 spinlock_unlock(&cache->maglock); 385 385 } 386 386 … … 414 414 slab_magazine_t *lastmag = cache->mag_cache[CPU->id].last; 415 415 416 ASSERT( irq_spinlock_locked(&cache->mag_cache[CPU->id].lock));416 ASSERT(spinlock_locked(&cache->mag_cache[CPU->id].lock)); 417 417 418 418 if (cmag) { /* First try local CPU magazines */ … … 451 451 return NULL; 452 452 453 irq_spinlock_lock(&cache->mag_cache[CPU->id].lock, true);453 spinlock_lock(&cache->mag_cache[CPU->id].lock); 454 454 455 455 slab_magazine_t *mag = get_full_current_mag(cache); 456 456 if (!mag) { 457 irq_spinlock_unlock(&cache->mag_cache[CPU->id].lock, true);457 spinlock_unlock(&cache->mag_cache[CPU->id].lock); 458 458 return NULL; 459 459 } 460 460 461 461 void *obj = mag->objs[--mag->busy]; 462 irq_spinlock_unlock(&cache->mag_cache[CPU->id].lock, true);462 spinlock_unlock(&cache->mag_cache[CPU->id].lock); 463 463 464 464 atomic_dec(&cache->cached_objs); … … 481 481 slab_magazine_t *lastmag = cache->mag_cache[CPU->id].last; 482 482 483 ASSERT( irq_spinlock_locked(&cache->mag_cache[CPU->id].lock));483 ASSERT(spinlock_locked(&cache->mag_cache[CPU->id].lock)); 484 484 485 485 if (cmag) { … … 531 531 return -1; 532 532 533 irq_spinlock_lock(&cache->mag_cache[CPU->id].lock, true);533 spinlock_lock(&cache->mag_cache[CPU->id].lock); 534 534 535 535 slab_magazine_t *mag = make_empty_current_mag(cache); 536 536 if (!mag) { 537 irq_spinlock_unlock(&cache->mag_cache[CPU->id].lock, true);537 spinlock_unlock(&cache->mag_cache[CPU->id].lock); 538 538 return -1; 539 539 } … … 541 541 mag->objs[mag->busy++] = obj; 542 542 543 irq_spinlock_unlock(&cache->mag_cache[CPU->id].lock, true);543 spinlock_unlock(&cache->mag_cache[CPU->id].lock); 544 544 545 545 atomic_inc(&cache->cached_objs); … … 593 593 for (i = 0; i < config.cpu_count; i++) { 594 594 memsetb(&cache->mag_cache[i], sizeof(cache->mag_cache[i]), 0); 595 irq_spinlock_initialize(&cache->mag_cache[i].lock,595 spinlock_initialize(&cache->mag_cache[i].lock, 596 596 "slab.cache.mag_cache[].lock"); 597 597 } … … 624 624 list_initialize(&cache->magazines); 625 625 626 irq_spinlock_initialize(&cache->slablock, "slab.cache.slablock");627 irq_spinlock_initialize(&cache->maglock, "slab.cache.maglock");626 spinlock_initialize(&cache->slablock, "slab.cache.slablock"); 627 spinlock_initialize(&cache->maglock, "slab.cache.maglock"); 628 628 629 629 if (!(cache->flags & SLAB_CACHE_NOMAGAZINE)) … … 704 704 size_t i; 705 705 for (i = 0; i < config.cpu_count; i++) { 706 irq_spinlock_lock(&cache->mag_cache[i].lock, true);706 spinlock_lock(&cache->mag_cache[i].lock); 707 707 708 708 mag = cache->mag_cache[i].current; … … 716 716 cache->mag_cache[i].last = NULL; 717 717 718 irq_spinlock_unlock(&cache->mag_cache[i].lock, true);718 spinlock_unlock(&cache->mag_cache[i].lock); 719 719 } 720 720 }
Note:
See TracChangeset
for help on using the changeset viewer.