Changeset 214f5bb in mainline


Ignore:
Timestamp:
2006-02-06T01:43:24Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c7ec94a4
Parents:
c585827
Message:

better utilization of memory in slab alloc
removed malloc-8 slab

Location:
generic
Files:
2 edited

Legend:

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

    rc585827 r214f5bb  
    3535
    3636/** Minimum size to be allocated by malloc */
    37 #define SLAB_MIN_MALLOC_W 3
     37#define SLAB_MIN_MALLOC_W 4
    3838
    3939/** Maximum size to be allocated by malloc */
  • generic/src/mm/slab.c

    rc585827 r214f5bb  
    113113/** Cache for cache descriptors */
    114114static slab_cache_t slab_cache_cache;
    115 /** Cache for magcache structure from cache_t */
    116 static slab_cache_t *cpu_cache = NULL;
    117115/** Cache for external slab descriptors
    118116 * This time we want per-cpu cache, so do not make it static
     
    125123static slab_cache_t *malloc_caches[SLAB_MAX_MALLOC_W-SLAB_MIN_MALLOC_W+1];
    126124char *malloc_names[] =  {
    127         "malloc-8","malloc-16","malloc-32","malloc-64","malloc-128",
     125        "malloc-16","malloc-32","malloc-64","malloc-128",
    128126        "malloc-256","malloc-512","malloc-1K","malloc-2K",
    129127        "malloc-4K","malloc-8K","malloc-16K","malloc-32K",
     
    139137        index_t nextavail; /**< The index of next available item */
    140138}slab_t;
     139
     140#ifdef CONFIG_DEBUG
     141static int _slab_initialized = 0;
     142#endif
    141143
    142144/**************************************/
     
    544546{
    545547        int i;
    546 
    547         ASSERT(cpu_cache);
    548         cache->mag_cache = slab_alloc(cpu_cache, 0);
     548       
     549        ASSERT(_slab_initialized >= 2);
     550
     551        cache->mag_cache = kalloc(sizeof(slab_mag_cache_t)*config.cpu_count,0);
    549552        for (i=0; i < config.cpu_count; i++) {
    550553                memsetb((__address)&cache->mag_cache[i],
     
    709712
    710713        if (!(cache->flags & SLAB_CACHE_NOMAGAZINE))
    711                 slab_free(cpu_cache, cache->mag_cache);
     714                kfree(cache->mag_cache);
    712715        slab_free(&slab_cache_cache, cache);
    713716}
     
    805808        interrupts_restore(ipl);
    806809}
    807 
    808 #ifdef CONFIG_DEBUG
    809 static int _slab_initialized = 0;
    810 #endif
    811810
    812811void slab_cache_init(void)
     
    859858        slab_cache_t *s;
    860859
    861         cpu_cache = slab_cache_create("magcpucache",
    862                                       sizeof(slab_mag_cache_t) * config.cpu_count,
    863                                       0, NULL, NULL,
    864                                       SLAB_CACHE_NOMAGAZINE);
     860#ifdef CONFIG_DEBUG
     861        _slab_initialized = 2;
     862#endif
     863
    865864        spinlock_lock(&slab_cache_lock);
    866865       
Note: See TracChangeset for help on using the changeset viewer.