Esempio n. 1
0
/* create a slab and add to kmem_cache_t */
int cache_grow(struct kmem_cache_t *cachep)
{
    if(cachep == NULL || cachep->obj_size == 0)
    {
        return -1;
    }
    void *ptr;
    struct slab *slabp = NULL;
    /*unsigned long slab_size;*/
    int obj_num = 0;

    ptr = slab_alloc(cachep);

    slabp = (struct slab *)ptr;
    slab_estimate(cachep->obj_size, &obj_num);
    cachep->obj_num = obj_num;
    cachep->nr_pages += pow(2, DEFAULT_SLAB_PAGES);

    ptr += sizeof(struct slab);
    slab_init(cachep, slabp, ptr);

    kmem_add_slab(cachep, slabp);

    return 0;
}
Esempio n. 2
0
/* create a slab and add to kmem_cache_t */
int cache_grow(kmem_cache_t *cachep)
{
    if(cachep == NULL || cachep->obj_size == 0)
    {
        return -1;
    }

    /*DD("----- cache %s grow -----", cachep->name);*/
    void *ptr = NULL;
    struct slab *slabp = NULL;
    int obj_num = 0;

    ptr = slab_alloc(cachep);

    slabp = (struct slab *)ptr;
    slab_estimate(cachep->obj_size, &obj_num);
    cachep->obj_num = obj_num;
    cachep->nr_pages += pow(2, DEFAULT_SLAB_PAGES);

    ptr += sizeof(struct slab);
    slab_init(cachep, slabp, ptr);

    kmem_add_slab(cachep, slabp);

    return 0;
}