diff options
author | Christoph Lameter <clameter@sgi.com> | 2007-07-17 07:03:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-17 13:23:01 -0400 |
commit | dfce8648d64c07eade40d456d59cb4bfcbba008c (patch) | |
tree | 7141882bd03d9848ec6299a48bc08796a8382062 /mm/slub.c | |
parent | 2e443fd003d76394a8ceb78f079260478aa10710 (diff) |
SLUB: do proper locking during dma slab creation
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>
Diffstat (limited to 'mm/slub.c')
-rw-r--r-- | mm/slub.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -2301,8 +2301,15 @@ static noinline struct kmem_cache *dma_kmalloc_cache(int index, gfp_t flags) | |||
2301 | text = kasprintf(flags & ~SLUB_DMA, "kmalloc_dma-%d", | 2301 | text = kasprintf(flags & ~SLUB_DMA, "kmalloc_dma-%d", |
2302 | (unsigned int)realsize); | 2302 | (unsigned int)realsize); |
2303 | s = create_kmalloc_cache(x, text, realsize, flags); | 2303 | s = create_kmalloc_cache(x, text, realsize, flags); |
2304 | kmalloc_caches_dma[index] = s; | 2304 | down_write(&slub_lock); |
2305 | return s; | 2305 | if (!kmalloc_caches_dma[index]) { |
2306 | kmalloc_caches_dma[index] = s; | ||
2307 | up_write(&slub_lock); | ||
2308 | return s; | ||
2309 | } | ||
2310 | up_write(&slub_lock); | ||
2311 | kmem_cache_destroy(s); | ||
2312 | return kmalloc_caches_dma[index]; | ||
2306 | } | 2313 | } |
2307 | #endif | 2314 | #endif |
2308 | 2315 | ||