提交 dfce8648 编写于 作者: C Christoph Lameter 提交者: Linus Torvalds

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: NChristoph Lameter <clameter@sgi.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 2e443fd0
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册