]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
SLUB: do proper locking during dma slab creation
authorChristoph Lameter <clameter@sgi.com>
Tue, 17 Jul 2007 11:03:25 +0000 (04:03 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 17 Jul 2007 17:23:01 +0000 (10:23 -0700)
We modify the kmalloc_cache_dma[] array without proper locking.  Do the proper
locking and undo the dma cache creation if another processor has already
created it.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/slub.c

index 2b50b97a0fc3fd8bac4bf3e601c52a53e004a6bf..f93adb915c00bedf53e114eb7fda163ef84a590e 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2301,8 +2301,15 @@ static noinline struct kmem_cache *dma_kmalloc_cache(int index, gfp_t flags)
        text = kasprintf(flags & ~SLUB_DMA, "kmalloc_dma-%d",
                        (unsigned int)realsize);
        s = create_kmalloc_cache(x, text, realsize, flags);
-       kmalloc_caches_dma[index] = s;
-       return s;
+       down_write(&slub_lock);
+       if (!kmalloc_caches_dma[index]) {
+               kmalloc_caches_dma[index] = s;
+               up_write(&slub_lock);
+               return s;
+       }
+       up_write(&slub_lock);
+       kmem_cache_destroy(s);
+       return kmalloc_caches_dma[index];
 }
 #endif