Skip to contentSkip to conversation

slab: avoid double initialization & do it in 1 function

PATCH Superseded Marcin Slusarz 2 participants 2 messages Dec 27, 2007 – Dec 29, 2007 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 slab: avoid double initialization & do it in 1 function

* alloc_slabmgmt: initialize all slab fields in 1 function
* slab->nodeid was initialized twice: in alloc_slabmgmt and immediately after it in cache_grow

CC Christoph Lameter <[email protected]>
CC Pekka Enberg <[email protected]>
mm/slab.c +1 -2
index 2e338a5..458b07a 100644
@@ -2626,6 +2626,7 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
 	slabp->colouroff = colour_off;
 	slabp->s_mem = objp + colour_off;
 	slabp->nodeid = nodeid;
+	slabp->free = 0;
 	return slabp;
 }
 
@@ -2679,7 +2680,6 @@ static void cache_init_objs(struct kmem_cache *cachep,
 		slab_bufctl(slabp)[i] = i + 1;
 	}
 	slab_bufctl(slabp)[i - 1] = BUFCTL_END;
-	slabp->free = 0;
 }
 
 static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags)
@@ -2812,7 +2812,6 @@ static int cache_grow(struct kmem_cache *cachep,
 	if (!slabp)
 		goto opps1;
 
-	slabp->nodeid = nodeid;
 	slab_map_pages(cachep, slabp, objp);
 
 	cache_init_objs(cachep, slabp);
Reviewed-by on v1 1/1
#1 lore raw

Hi Marcin,

Quoted 3 lines · Marcin Slusarz

* alloc_slabmgmt: initialize all slab fields in 1 function
* slab->nodeid was initialized twice: in alloc_slabmgmt and immediately after it in cache_grow

Looks good to me.