Commit f2b0edc5 authored by Mathieu Maret's avatar Mathieu Maret

alloc: fix new slab allocation

parent f90b9bd3
......@@ -24,7 +24,7 @@ int allocInit(void)
pr_devel("Fail to allocBookSlab %d for slabDesc :( \n");
return ret;
}
for (uint i = start; i < SLUB_SIZE; i++) {
for (uint i = start; i <= SLUB_SIZE; i++) {
if ((ret = allocBookSlab(1U << i, 0))) {
pr_devel("Fail to allocBookSlab %d for %d \n", ret, (1U << i));
return ret;
......@@ -103,7 +103,7 @@ static void *allocFromSlab(struct slabDesc *slab)
{
vaddr_t *next = slab->freeEl;
if (*next == (vaddr_t)NULL) {
pr_devel("Slab @%d for %d full\n", slab, slab->size);
pr_devel("Slab @%d for %d is now full\n", slab, slab->size);
slab->full = 1;
} else {
slab->freeEl = (void *)(*next);
......@@ -128,6 +128,10 @@ void *malloc(size_t size)
int slabIdx;
list_foreach(slubEntry, slab, slabIdx)
{
if (slab->size > slubEntry->size){
pr_devel("No more room in slub %d\n", slubIdx);
break;
}
if (!slab->full) {
pr_devel("found place in slub %d at idx %d for size %d\n", slubIdx,
slabIdx, size);
......@@ -138,10 +142,11 @@ void *malloc(size_t size)
// No room found
struct slabDesc *newSlab;
int ret;
if ((ret = addSlab(&newSlab, slab->size, IS_SELF_CONTAINED(slubEntry)))) {
if ((ret = addSlab(&newSlab, slubEntry->size, IS_SELF_CONTAINED(slubEntry)))) {
pr_devel("Fail to addSlab %d\n", ret);
return NULL;
}
pr_devel("Allocate new slab for object of size %d\n", slubEntry->size);
list_add_head(slubEntry, newSlab);
return allocFromSlab(newSlab);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment