slub: Initialize per-cpu stats
authorPekka Enberg <penberg@cs.helsinki.fi>
Mon, 14 Apr 2008 15:50:44 +0000 (18:50 +0300)
committerPekka Enberg <penberg@cs.helsinki.fi>
Mon, 14 Apr 2008 15:50:44 +0000 (18:50 +0300)
As spotted by kmemcheck, we need to initialize the per-CPU ->stat array before
using it.

[kmem_cache_cpu structures are usually allocated from arrays defined via
DEFINE_PER_CPU that are zeroed so we have not noticed this so far --cl].

Reported-by: Vegard Nossum <vegard.nossum@gmail.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
mm/slub.c

index acc975fcc8cc9f96a9d3ce7d37a1e1e9b7bbf2ca..15a7a0d45d71fe24eb1336a961a4288bf21ac026 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1886,6 +1886,9 @@ static void init_kmem_cache_cpu(struct kmem_cache *s,
        c->node = 0;
        c->offset = s->offset / sizeof(void *);
        c->objsize = s->objsize;
+#ifdef CONFIG_SLUB_STATS
+       memset(c->stat, 0, NR_SLUB_STAT_ITEMS * sizeof(unsigned));
+#endif
 }
 
 static void init_kmem_cache_node(struct kmem_cache_node *n)