Changes in kernel/generic/src/mm/slab.c [f97f1e51:cd3b380] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/slab.c
rf97f1e51 rcd3b380 182 182 size_t zone = 0; 183 183 184 void *data = frame_alloc_generic(cache->order, FRAME_KA | flags, &zone); 185 if (!data) { 184 uintptr_t data_phys = 185 frame_alloc_generic(cache->frames, flags, 0, &zone); 186 if (!data_phys) 186 187 return NULL; 187 } 188 189 void *data = (void *) PA2KA(data_phys); 188 190 189 191 slab_t *slab; … … 193 195 slab = slab_alloc(slab_extern_cache, flags); 194 196 if (!slab) { 195 frame_free(KA2PA(data) );197 frame_free(KA2PA(data), cache->frames); 196 198 return NULL; 197 199 } 198 200 } else { 199 fsize = (PAGE_SIZE << cache->order);201 fsize = FRAMES2SIZE(cache->frames); 200 202 slab = data + fsize - sizeof(*slab); 201 203 } … … 203 205 /* Fill in slab structures */ 204 206 size_t i; 205 for (i = 0; i < ((size_t) 1 << cache->order); i++)207 for (i = 0; i < cache->frames; i++) 206 208 frame_set_parent(ADDR2PFN(KA2PA(data)) + i, slab, zone); 207 209 … … 225 227 NO_TRACE static size_t slab_space_free(slab_cache_t *cache, slab_t *slab) 226 228 { 227 frame_free(KA2PA(slab->start) );229 frame_free(KA2PA(slab->start), slab->cache->frames); 228 230 if (!(cache->flags & SLAB_CACHE_SLINSIDE)) 229 231 slab_free(slab_extern_cache, slab); … … 231 233 atomic_dec(&cache->allocated_slabs); 232 234 233 return (1 << cache->order);235 return cache->frames; 234 236 } 235 237 … … 558 560 { 559 561 if (cache->flags & SLAB_CACHE_SLINSIDE) 560 return ( (PAGE_SIZE << cache->order)561 - sizeof(slab_t)) /cache->size;562 return (FRAMES2SIZE(cache->frames) - sizeof(slab_t)) / 563 cache->size; 562 564 else 563 return (PAGE_SIZE << cache->order) / cache->size;565 return FRAMES2SIZE(cache->frames) / cache->size; 564 566 } 565 567 … … 570 572 { 571 573 size_t objects = comp_objects(cache); 572 size_t ssize = PAGE_SIZE << cache->order;574 size_t ssize = FRAMES2SIZE(cache->frames); 573 575 574 576 if (cache->flags & SLAB_CACHE_SLINSIDE) … … 634 636 cache->flags |= SLAB_CACHE_SLINSIDE; 635 637 636 /* Minimum slab order */ 637 size_t pages = SIZE2FRAMES(cache->size); 638 639 /* We need the 2^order >= pages */ 640 if (pages == 1) 641 cache->order = 0; 642 else 643 cache->order = fnzb(pages - 1) + 1; 638 /* Minimum slab frames */ 639 cache->frames = SIZE2FRAMES(cache->size); 644 640 645 641 while (badness(cache) > SLAB_MAX_BADNESS(cache)) 646 cache-> order += 1;642 cache->frames <<= 1; 647 643 648 644 cache->objects = comp_objects(cache); … … 810 806 811 807 size_t frames = 0; 812 list_foreach(slab_cache_list, cur) { 813 slab_cache_t *cache = list_get_instance(cur, slab_cache_t, link); 808 list_foreach(slab_cache_list, link, slab_cache_t, cache) { 814 809 frames += _slab_reclaim(cache, flags); 815 810 } … … 871 866 872 867 const char *name = cache->name; 873 uint8_t order = cache->order;868 size_t frames = cache->frames; 874 869 size_t size = cache->size; 875 870 size_t objects = cache->objects; … … 881 876 irq_spinlock_unlock(&slab_cache_lock, true); 882 877 883 printf("%-18s %8zu %8 u %8zu %8ld %8ld %8ld %-5s\n",884 name, size, (1 << order), objects, allocated_slabs,878 printf("%-18s %8zu %8zu %8zu %8ld %8ld %8ld %-5s\n", 879 name, size, frames, objects, allocated_slabs, 885 880 cached_objs, allocated_objs, 886 881 flags & SLAB_CACHE_SLINSIDE ? "in" : "out"); … … 936 931 irq_spinlock_lock(&slab_cache_lock, false); 937 932 938 list_foreach(slab_cache_list, cur) { 939 slab_cache_t *slab = list_get_instance(cur, slab_cache_t, link); 933 list_foreach(slab_cache_list, link, slab_cache_t, slab) { 940 934 if ((slab->flags & SLAB_CACHE_MAGDEFERRED) != 941 935 SLAB_CACHE_MAGDEFERRED)
Note:
See TracChangeset
for help on using the changeset viewer.