cache->page = page;
}
}
+ else
+ {
+ cache->page = page;
+ }
}
if(cache->page == 0)
if(cache == 0)
return 0;
- unsigned long objsize = cache->objsize;
-
if(cache->page == 0 || cache->page->freelist == 0)
{
cache->page = 0;
{
object = cache->page->freelist;
cache->page->freelist = object[0];
+ cache->page->inuse++;
}
return object;
prior = object[0] = page->freelist;
page->freelist = object;
- page->inuse--;
if(page->inuse == 0)
{
{
void **object = addr;
+ page->inuse--;
+
if(page == cache->page)
{
object[0] = page->freelist;
for(i=0; i<SLUB_INIT_CACHE_SIZE; ++i)
{
kmem_cache_t *p = kmalloc_caches + i;
- if(p->objsize > size)
+ if(p->objsize >= size)
{
cache = p;
break;
kmem_cache_init(cache, "kmalloc_old", 1UL<<i, KMALLOC_MIN_ALIGN);
list_add(&(cache->list), &slub_caches);
+ printk("kmem objsize %d size %d \n", cache->objsize, cache->size);
}
list_head_t *p;
printk("cache size %d align %d \n", cache->size, cache->align);
}
- for(i=0; i<10; ++i)
+#define SIZE 10000
+ void *addrs[SIZE];
+ void *addr;
+ for(i=0; i<SIZE; ++i)
+ {
+ addr = kmalloc(2048, 0);
+ printk("kmalloc addr %08x\n", (unsigned long) addr);
+ addrs[i] = addr;
+ }
+
+ printk("Cleaning...\n");
+ for(i=0; i<SIZE; ++i)
+ {
+ kfree(addrs[i]);
+ }
+
+ for(i=0; i<SIZE; ++i)
{
- void *addr = slub_alloc(kmalloc_caches+2, 0);
- printk("slub addr %08x\n", (unsigned long)addr);
+ addr = kmalloc(2048, 0);
+ printk("kmalloc addr %08x\n", (unsigned long) addr);
+ addrs[i] = addr;
}
}