Index: linux-2.6.14-rc2/mm/slab.c =================================================================== --- linux-2.6.14-rc2.orig/mm/slab.c 2005-09-22 11:58:45.000000000 -0700 +++ linux-2.6.14-rc2/mm/slab.c 2005-09-22 16:08:56.000000000 -0700 @@ -2508,11 +2508,21 @@ cache_alloc_debugcheck_after(kmem_cache_ #define cache_alloc_debugcheck_after(a,b,objp,d) (objp) #endif +static inline void obj_checkout(kmem_cache_t *cachep, unsinged int __nocast flags, void *objp) +{ + if (!objp) + return; + objp = cache_alloc_debugcheck_after(cachep, flags, objp, + __builtin_return_address(0)); + if (unlikely(flags & __GFP_ZERO)) + memset(objp, 0, cachep->objsize); + prefetchw(objp); +} static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast flags) { unsigned long save_flags; - void* objp; + void *objp; struct array_cache *ac; cache_alloc_debugcheck_before(cachep, flags); @@ -2528,9 +2538,7 @@ static inline void *__cache_alloc(kmem_c objp = cache_alloc_refill(cachep, flags); } local_irq_restore(save_flags); - objp = cache_alloc_debugcheck_after(cachep, flags, objp, - __builtin_return_address(0)); - prefetchw(objp); + obj_checkout(cachep, flags, objp); return objp; } @@ -2556,8 +2564,15 @@ retry: if (entry == &l3->slabs_partial) { l3->free_touched = 1; entry = l3->slabs_free.next; - if (entry == &l3->slabs_free) - goto must_grow; + if (entry == &l3->slabs_free) { + spin_unlock(&l3->list_lock); + x = cache_grow(cachep, flags, nodeid); + + if (!x) + return NULL; + + goto retry; + } } slabp = list_entry(entry, struct slab, list); @@ -2590,18 +2605,9 @@ retry: } spin_unlock(&l3->list_lock); - goto done; - -must_grow: - spin_unlock(&l3->list_lock); - x = cache_grow(cachep, flags, nodeid); + obj_checkout(cachep, flags, obj); + return obj; - if (!x) - return NULL; - - goto retry; -done: - return obj; } #endif @@ -2980,20 +2986,6 @@ void kmem_cache_free(kmem_cache_t *cache EXPORT_SYMBOL(kmem_cache_free); /** - * kzalloc - allocate memory. The memory is set to zero. - * @size: how many bytes of memory are required. - * @flags: the type of memory to allocate. - */ -void *kzalloc(size_t size, unsigned int __nocast flags) -{ - void *ret = kmalloc(size, flags); - if (ret) - memset(ret, 0, size); - return ret; -} -EXPORT_SYMBOL(kzalloc); - -/** * kfree - free previously allocated memory * @objp: pointer returned by kmalloc. * Index: linux-2.6.14-rc2/include/linux/slab.h =================================================================== --- linux-2.6.14-rc2.orig/include/linux/slab.h 2005-09-19 20:00:41.000000000 -0700 +++ linux-2.6.14-rc2/include/linux/slab.h 2005-09-22 15:56:49.000000000 -0700 @@ -99,7 +99,7 @@ found: return __kmalloc(size, flags); } -extern void *kzalloc(size_t, unsigned int __nocast); +#define kzalloc(__size, __flags) kmalloc(__size, (__flags) | __GFP_ZERO) /** * kcalloc - allocate memory for an array. The memory is set to zero.