Changeset bc504ef2 in mainline
- Timestamp:
- 2006-02-02T16:14:19Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 086d4fd
- Parents:
- 2d43f3e
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/mips32/src/mm/tlb.c
r2d43f3e rbc504ef2 367 367 */ 368 368 if (!pte) { 369 printf("No such mapping .\n");369 printf("No such mapping: %P.\n", badvaddr); 370 370 return NULL; 371 371 } -
generic/include/mm/slab.h
r2d43f3e rbc504ef2 32 32 #include <list.h> 33 33 #include <synch/spinlock.h> 34 #include <arch/atomic.h> 34 35 35 36 /** Initial Magazine size (TODO: dynamically growing magazines) */ … … 73 74 74 75 /* Statistics */ 76 atomic_t allocated_slabs; 77 atomic_t allocated_objs; 75 78 76 79 /* Slabs */ -
generic/src/mm/frame.c
r2d43f3e rbc504ef2 185 185 v = PA2KA(v); 186 186 187 if (flags & FRAME_ATOMIC) { 188 ASSERT(status != NULL); 187 if (status) 189 188 *status = FRAME_OK; 190 } 189 191 190 if (pzone) 192 191 *pzone = zone; -
generic/src/mm/slab.c
r2d43f3e rbc504ef2 70 70 zone_t *zone = NULL; 71 71 int status; 72 frame_t *frame; 72 73 73 74 data = (void *)frame_alloc(FRAME_KA | flags, cache->order, &status, &zone); 74 if (status != FRAME_OK) 75 if (status != FRAME_OK) { 75 76 return NULL; 76 77 } 77 78 if (! cache->flags & SLAB_CACHE_SLINSIDE) { 78 79 slab = malloc(sizeof(*slab)); // , flags); … … 85 86 slab = data + fsize - sizeof(*slab); 86 87 } 87 88 88 89 /* Fill in slab structures */ 89 90 /* TODO: some better way of accessing the frame */ 90 91 for (i=0; i< (1<<cache->order); i++) { 91 ADDR2FRAME(zone, (__address)(data+i*PAGE_SIZE))->parent = slab; 92 frame = ADDR2FRAME(zone, KA2PA((__address)(data+i*PAGE_SIZE))); 93 frame->parent = slab; 92 94 } 93 95 … … 98 100 for (i=0; i<cache->objects;i++) 99 101 *((int *) (slab->start + i*cache->size)) = i+1; 102 103 atomic_inc(&cache->allocated_slabs); 104 100 105 return slab; 101 106 } … … 111 116 if (! cache->flags & SLAB_CACHE_SLINSIDE) 112 117 free(slab); 118 119 atomic_dec(&cache->allocated_slabs); 120 113 121 return 1 << cache->order; 114 122 } … … 154 162 /* It was in full, move to partial */ 155 163 list_remove(&slab->link); 156 list_prepend(& cache->partial_slabs, &slab->link);164 list_prepend(&slab->link, &cache->partial_slabs); 157 165 } 158 166 if (slab->available == cache->objects) { … … 192 200 slab = slab_space_alloc(cache, flags); 193 201 spinlock_lock(&cache->lock); 194 if (!slab) 202 if (!slab) { 195 203 return NULL; 204 } 196 205 } else { 197 206 slab = list_get_instance(cache->partial_slabs.next, … … 204 213 slab->available--; 205 214 if (! slab->available) 206 list_prepend(& cache->full_slabs, &slab->link);215 list_prepend(&slab->link, &cache->full_slabs); 207 216 else 208 list_prepend(& cache->partial_slabs, &slab->link);217 list_prepend(&slab->link, &cache->partial_slabs); 209 218 return obj; 210 219 } … … 316 325 if (!mag || mag->size == mag->busy) { 317 326 if (mag) 318 list_prepend(& cache->magazines, &mag->link);327 list_prepend(&mag->link, &cache->magazines); 319 328 320 329 mag = slab_alloc(&mag_cache, FRAME_ATOMIC | FRAME_NO_RECLAIM); … … 534 543 } 535 544 545 if (result) 546 atomic_inc(&cache->allocated_objs); 547 536 548 interrupts_restore(ipl); 549 537 550 538 551 return result; … … 553 566 spinlock_unlock(&cache->lock); 554 567 } 568 atomic_dec(&cache->allocated_objs); 555 569 interrupts_restore(ipl); 556 570 } … … 583 597 584 598 spinlock_lock(&slab_cache_lock); 585 printf("SLAB name\tOsize\tOrder\ n");599 printf("SLAB name\tOsize\tOrder\tOcnt\tSlabs\tAllocobjs\n"); 586 600 for (cur = slab_cache_list.next;cur!=&slab_cache_list; cur=cur->next) { 587 601 cache = list_get_instance(cur, slab_cache_t, link); 588 printf("%s\t%d\t%d\n", cache->name, cache->size, cache->order); 602 printf("%s\t%d\t%d\t%d\t%d\t%d\n", cache->name, cache->size, 603 cache->order, cache->objects, 604 atomic_get(&cache->allocated_slabs), 605 atomic_get(&cache->allocated_objs)); 589 606 } 590 607 spinlock_unlock(&slab_cache_lock); -
test/mm/slab1/test.c
r2d43f3e rbc504ef2 44 44 printf("Creating cache.\n"); 45 45 cache = slab_cache_create("test_cache", VAL_SIZE, 0, NULL, NULL, SLAB_CACHE_NOMAGAZINE); 46 slab_print_list();47 46 printf("Destroying cache.\n"); 48 47 slab_cache_destroy(cache); … … 62 61 } 63 62 printf("done.\n"); 63 64 printf("Allocating %d items...", VAL_COUNT); 65 for (i=0; i < VAL_COUNT; i++) { 66 data[i] = slab_alloc(cache, 0); 67 } 68 printf("done.\n"); 69 70 slab_print_list(); 71 printf("Freeing %d items...", VAL_COUNT/2); 72 for (i=VAL_COUNT-1; i >= VAL_COUNT/2; i--) { 73 slab_free(cache, data[i]); 74 } 75 printf("done.\n"); 76 77 printf("Allocating %d items...", VAL_COUNT/2); 78 for (i=VAL_COUNT/2; i < VAL_COUNT; i++) { 79 data[i] = slab_alloc(cache, 0); 80 } 81 printf("done.\n"); 82 printf("Freeing %d items...", VAL_COUNT); 83 for (i=0; i < VAL_COUNT; i++) { 84 slab_free(cache, data[i]); 85 } 86 printf("done.\n"); 87 slab_print_list(); 88 slab_cache_destroy(cache); 89 90 printf("Test complete.\n"); 64 91 }
Note:
See TracChangeset
for help on using the changeset viewer.