Changeset c3ebc47 in mainline


Ignore:
Timestamp:
2009-03-24T03:06:21Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
21a639b7
Parents:
05641a9e
Message:

add malloc slab caches for up to 4 MB blocks

Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/mm/slab.h

    r05641a9e rc3ebc47  
    4242
    4343/** Minimum size to be allocated by malloc */
    44 #define SLAB_MIN_MALLOC_W 4
     44#define SLAB_MIN_MALLOC_W  4
    4545
    4646/** Maximum size to be allocated by malloc */
    47 #define SLAB_MAX_MALLOC_W 18
     47#define SLAB_MAX_MALLOC_W  22
    4848
    4949/** Initial Magazine size (TODO: dynamically growing magazines) */
     
    5151
    5252/** If object size is less, store control structure inside SLAB */
    53 #define SLAB_INSIDE_SIZE   (PAGE_SIZE >> 3)
     53#define SLAB_INSIDE_SIZE  (PAGE_SIZE >> 3)
    5454
    5555/** Maximum wasted space we allow for cache */
    56 #define SLAB_MAX_BADNESS(cache) \
     56#define SLAB_MAX_BADNESS(cache) \
    5757        (((unsigned int) PAGE_SIZE << (cache)->order) >> 2)
    5858
     
    6565
    6666/** Do not use per-cpu cache */
    67 #define SLAB_CACHE_NOMAGAZINE 0x1
     67#define SLAB_CACHE_NOMAGAZINE   0x01
    6868/** Have control structure inside SLAB */
    69 #define SLAB_CACHE_SLINSIDE   0x2
     69#define SLAB_CACHE_SLINSIDE     0x02
    7070/** We add magazine cache later, if we have this flag */
    71 #define SLAB_CACHE_MAGDEFERRED (0x4 | SLAB_CACHE_NOMAGAZINE)
     71#define SLAB_CACHE_MAGDEFERRED  (0x04 | SLAB_CACHE_NOMAGAZINE)
    7272
    7373typedef struct {
    7474        link_t link;
    75         count_t busy;   /**< Count of full slots in magazine */
    76         count_t size;   /**< Number of slots in magazine */
    77         void *objs[];   /**< Slots in magazine */
     75        count_t busy;  /**< Count of full slots in magazine */
     76        count_t size;  /**< Number of slots in magazine */
     77        void *objs[];  /**< Slots in magazine */
    7878} slab_magazine_t;
    7979
     
    8787typedef struct {
    8888        char *name;
    89 
     89       
    9090        link_t link;
    91 
     91       
    9292        /* Configuration */
    9393        /** Size of slab position - align_up(sizeof(obj)) */
    9494        size_t size;
    95 
     95       
    9696        int (*constructor)(void *obj, int kmflag);
    9797        int (*destructor)(void *obj);
    98 
     98       
    9999        /** Flags changing behaviour of cache */
    100100        int flags;
    101 
     101       
    102102        /* Computed values */
    103         uint8_t order;                  /**< Order of frames to be allocated */
    104         unsigned int objects;           /**< Number of objects that fit in */
    105 
     103        uint8_t order;         /**< Order of frames to be allocated */
     104        unsigned int objects;  /**< Number of objects that fit in */
     105       
    106106        /* Statistics */
    107107        atomic_t allocated_slabs;
     
    110110        /** How many magazines in magazines list */
    111111        atomic_t magazine_counter;
    112 
     112       
    113113        /* Slabs */
    114         link_t full_slabs;      /**< List of full slabs */
    115         link_t partial_slabs;   /**< List of partial slabs */
     114        link_t full_slabs;     /**< List of full slabs */
     115        link_t partial_slabs;  /**< List of partial slabs */
    116116        SPINLOCK_DECLARE(slablock);
    117         /* Magazines  */
    118         link_t magazines;       /**< List o full magazines */
     117        /* Magazines */
     118        link_t magazines;  /**< List o full magazines */
    119119        SPINLOCK_DECLARE(maglock);
    120 
     120       
    121121        /** CPU cache */
    122122        slab_mag_cache_t *mag_cache;
     
    142142extern void *realloc(void *, unsigned int, int);
    143143extern void free(void *);
     144
    144145#endif
    145146
  • kernel/generic/src/mm/slab.c

    r05641a9e rc3ebc47  
    130130/** Caches for malloc */
    131131static slab_cache_t *malloc_caches[SLAB_MAX_MALLOC_W - SLAB_MIN_MALLOC_W + 1];
    132 char *malloc_names[] =  {
     132static char *malloc_names[] =  {
    133133        "malloc-16",
    134134        "malloc-32",
     
    145145        "malloc-64K",
    146146        "malloc-128K",
    147         "malloc-256K"
     147        "malloc-256K",
     148        "malloc-512K",
     149        "malloc-1M",
     150        "malloc-2M",
     151        "malloc-4M"
    148152};
    149153
Note: See TracChangeset for help on using the changeset viewer.