Changeset 14e5d88 in mainline for generic/src


Ignore:
Timestamp:
2006-02-02T21:46:47Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4a5b2b0e
Parents:
086d4fd
Message:

Basic SLAB (without CPU-cache) passes test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/mm/slab.c

    r086d4fd r14e5d88  
    8989        /* Fill in slab structures */
    9090        /* TODO: some better way of accessing the frame */
    91         for (i=0; i< (1<<cache->order); i++) {
     91        for (i=0; i < (1 << cache->order); i++) {
    9292                frame = ADDR2FRAME(zone, KA2PA((__address)(data+i*PAGE_SIZE)));
    9393                frame->parent = slab;
     
    107107
    108108/**
    109  * Free space associated with SLAB
     109 * Deallocate space associated with SLAB
    110110 *
    111111 * @return number of freed frames
     
    151151        if (!slab)
    152152                slab = obj2slab(obj);
    153 
    154         spinlock_lock(&cache->lock);
    155153
    156154        *((int *)obj) = slab->nextavail;
     
    172170                spinlock_lock(&cache->lock);
    173171        }
    174 
    175         spinlock_unlock(&cache->lock);
    176172
    177173        return frames;
     
    389385        cache->name = name;
    390386
    391         if (align)
    392                 size = ALIGN_UP(size, align);
     387        if (align < sizeof(__native))
     388                align = sizeof(__native);
     389        size = ALIGN_UP(size, align);
     390               
    393391        cache->size = size;
    394392
     
    412410
    413411        /* Minimum slab order */
    414         cache->order = (cache->size >> PAGE_WIDTH) + 1;
    415                
     412        cache->order = (cache->size-1) >> PAGE_WIDTH;
     413
    416414        while (badness(cache) > SLAB_MAX_BADNESS(cache)) {
    417415                cache->order += 1;
    418416        }
    419 
    420417        cache->objects = comp_objects(cache);
     418        /* If info fits in, put it inside */
     419        if (badness(cache) > sizeof(slab_t))
     420                cache->flags |= SLAB_CACHE_SLINSIDE;
    421421
    422422        spinlock_lock(&slab_cache_lock);
     
    597597
    598598        spinlock_lock(&slab_cache_lock);
    599         printf("SLAB name\tOsize\tOrder\tOcnt\tSlabs\tAllocobjs\n");
     599        printf("SLAB name\tOsize\tPages\tOcnt\tSlabs\tAllocobjs\tCtl\n");
    600600        for (cur = slab_cache_list.next;cur!=&slab_cache_list; cur=cur->next) {
    601601                cache = list_get_instance(cur, slab_cache_t, link);
    602                 printf("%s\t%d\t%d\t%d\t%d\t%d\n", cache->name, cache->size,
    603                        cache->order, cache->objects,
     602                printf("%s\t%d\t%d\t%d\t%d\t%d\t\t%s\n", cache->name, cache->size,
     603                       (1 << cache->order), cache->objects,
    604604                       atomic_get(&cache->allocated_slabs),
    605                        atomic_get(&cache->allocated_objs));
     605                       atomic_get(&cache->allocated_objs),
     606                       cache->flags & SLAB_CACHE_SLINSIDE ? "In" : "Out");
    606607        }
    607608        spinlock_unlock(&slab_cache_lock);
Note: See TracChangeset for help on using the changeset viewer.