From: AceVest Date: Mon, 28 Apr 2014 14:14:34 +0000 (+0800) Subject: fix bug in slub X-Git-Tag: 0.3.0~79 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=d9c35e11891e316c7581be3ad779b25aaeadda6e;p=kernel.git fix bug in slub --- diff --git a/mm/slub.c b/mm/slub.c index 2c817b6..ae2fd90 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -152,6 +152,10 @@ static void *__slub_alloc(kmem_cache_t *cache, gfp_t gfpflags) cache->page = page; } } + else + { + cache->page = page; + } } if(cache->page == 0) @@ -179,8 +183,6 @@ static void *slub_alloc(kmem_cache_t *cache, gfp_t gfpflags) if(cache == 0) return 0; - unsigned long objsize = cache->objsize; - if(cache->page == 0 || cache->page->freelist == 0) { cache->page = 0; @@ -190,6 +192,7 @@ static void *slub_alloc(kmem_cache_t *cache, gfp_t gfpflags) { object = cache->page->freelist; cache->page->freelist = object[0]; + cache->page->inuse++; } return object; @@ -202,7 +205,6 @@ static void __slub_free(kmem_cache_t *cache, page_t *page, void *addr) prior = object[0] = page->freelist; page->freelist = object; - page->inuse--; if(page->inuse == 0) { @@ -220,6 +222,8 @@ static void slub_free(kmem_cache_t *cache, page_t *page, void *addr) { void **object = addr; + page->inuse--; + if(page == cache->page) { object[0] = page->freelist; @@ -253,7 +257,7 @@ void *kmalloc(size_t size, gfp_t gfpflags) for(i=0; iobjsize > size) + if(p->objsize >= size) { cache = p; break; @@ -283,6 +287,7 @@ void init_slub_system() kmem_cache_init(cache, "kmalloc_old", 1UL<list), &slub_caches); + printk("kmem objsize %d size %d \n", cache->objsize, cache->size); } list_head_t *p; @@ -292,9 +297,26 @@ void init_slub_system() 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