Changeset 9179d0a in mainline for generic/src/mm/slab.c


Ignore:
Timestamp:
2006-04-27T17:13:49Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
040e4e9
Parents:
eaa202a
Message:

Add some @file doxygen comments and improve already existing comments.

File:
1 edited

Legend:

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

    reaa202a r9179d0a  
    2727 */
    2828
    29 /*
    30  * The SLAB allocator is closely modelled after OpenSolaris SLAB allocator
    31  * http://www.usenix.org/events/usenix01/full_papers/bonwick/bonwick_html/
     29/**
     30 * @file        slab.c
     31 * @brief       Slab allocator.
     32 *
     33 * The slab allocator is closely modelled after OpenSolaris slab allocator.
     34 * @see http://www.usenix.org/events/usenix01/full_papers/bonwick/bonwick_html/
    3235 *
    3336 * with the following exceptions:
    34  *   - empty SLABS are deallocated immediately
     37 * @li empty slabs are deallocated immediately
    3538 *     (in Linux they are kept in linked list, in Solaris ???)
    36  *   - empty magazines are deallocated when not needed
     39 * @li empty magazines are deallocated when not needed
    3740 *     (in Solaris they are held in linked list in slab cache)
    3841 *
    39  *   Following features are not currently supported but would be easy to do:
    40  *   - cache coloring
    41  *   - dynamic magazine growing (different magazine sizes are already
     42 * Following features are not currently supported but would be easy to do:
     43 * @li cache coloring
     44 * @li dynamic magazine growing (different magazine sizes are already
    4245 *     supported, but we would need to adjust allocation strategy)
    4346 *
    44  * The SLAB allocator supports per-CPU caches ('magazines') to facilitate
     47 * The slab allocator supports per-CPU caches ('magazines') to facilitate
    4548 * good SMP scaling.
    4649 *
    4750 * When a new object is being allocated, it is first checked, if it is
    4851 * available in CPU-bound magazine. If it is not found there, it is
    49  * allocated from CPU-shared SLAB - if partial full is found, it is used,
     52 * allocated from CPU-shared slab - if partial full is found, it is used,
    5053 * otherwise a new one is allocated.
    5154 *
    5255 * When an object is being deallocated, it is put to CPU-bound magazine.
    5356 * If there is no such magazine, new one is allocated (if it fails,
    54  * the object is deallocated into SLAB). If the magazine is full, it is
     57 * the object is deallocated into slab). If the magazine is full, it is
    5558 * put into cpu-shared list of magazines and new one is allocated.
    5659 *
     
    6164 * 
    6265 * Every cache contains list of full slabs and list of partialy full slabs.
    63  * Empty SLABS are immediately freed (thrashing will be avoided because
     66 * Empty slabs are immediately freed (thrashing will be avoided because
    6467 * of magazines).
    6568 *
    66  * The SLAB information structure is kept inside the data area, if possible.
     69 * The slab information structure is kept inside the data area, if possible.
    6770 * The cache can be marked that it should not use magazines. This is used
    68  * only for SLAB related caches to avoid deadlocks and infinite recursion
    69  * (the SLAB allocator uses itself for allocating all it's control structures).
    70  *
    71  * The SLAB allocator allocates lot of space and does not free it. When
     71 * only for slab related caches to avoid deadlocks and infinite recursion
     72 * (the slab allocator uses itself for allocating all it's control structures).
     73 *
     74 * The slab allocator allocates lot of space and does not free it. When
    7275 * frame allocator fails to allocate the frame, it calls slab_reclaim().
    7376 * It tries 'light reclaim' first, then brutal reclaim. The light reclaim
     
    7780 * magazines.
    7881 *
    79  * TODO: For better CPU-scaling the magazine allocation strategy should
     82 * TODO:@n
     83 * For better CPU-scaling the magazine allocation strategy should
    8084 * be extended. Currently, if the cache does not have magazine, it asks
    8185 * for non-cpu cached magazine cache to provide one. It might be feasible
     
    8690 * magazine cache.
    8791 *
    88  * - it might be good to add granularity of locks even to slab level,
    89  *   we could then try_spinlock over all partial slabs and thus improve
    90  *   scalability even on slab level
    91  */
    92 
     92 * @li it might be good to add granularity of locks even to slab level,
     93 *     we could then try_spinlock over all partial slabs and thus improve
     94 *     scalability even on slab level
     95 */
    9396
    9497#include <synch/spinlock.h>
     
    114117/** Cache for external slab descriptors
    115118 * This time we want per-cpu cache, so do not make it static
    116  * - using SLAB for internal SLAB structures will not deadlock,
     119 * - using slab for internal slab structures will not deadlock,
    117120 *   as all slab structures are 'small' - control structures of
    118121 *   their caches do not require further allocation
     
    142145
    143146/**************************************/
    144 /* SLAB allocation functions          */
     147/* Slab allocation functions          */
    145148
    146149/**
     
    191194
    192195/**
    193  * Deallocate space associated with SLAB
     196 * Deallocate space associated with slab
    194197 *
    195198 * @return number of freed frames
     
    213216
    214217/**************************************/
    215 /* SLAB functions */
     218/* Slab functions */
    216219
    217220
     
    274277        if (list_empty(&cache->partial_slabs)) {
    275278                /* Allow recursion and reclaiming
    276                  * - this should work, as the SLAB control structures
     279                 * - this should work, as the slab control structures
    277280                 *   are small and do not need to allocte with anything
    278281                 *   other ten frame_alloc when they are allocating,
     
    510513
    511514/**************************************/
    512 /* SLAB CACHE functions */
     515/* Slab cache functions */
    513516
    514517/** Return number of objects that fit in certain cache size */
     
    790793        ipl = interrupts_disable();
    791794        spinlock_lock(&slab_cache_lock);
    792         printf("SLAB name\t  Osize\t  Pages\t Obj/pg\t  Slabs\t Cached\tAllocobjs\tCtl\n");
     795        printf("slab name\t  Osize\t  Pages\t Obj/pg\t  Slabs\t Cached\tAllocobjs\tCtl\n");
    793796        for (cur = slab_cache_list.next;cur!=&slab_cache_list; cur=cur->next) {
    794797                cache = list_get_instance(cur, slab_cache_t, link);
Note: See TracChangeset for help on using the changeset viewer.