Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=dfce8648d64c07eade40d456d59cb4bfcbba008c
Commit:     dfce8648d64c07eade40d456d59cb4bfcbba008c
Parent:     2e443fd003d76394a8ceb78f079260478aa10710
Author:     Christoph Lameter <[EMAIL PROTECTED]>
AuthorDate: Tue Jul 17 04:03:25 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Tue Jul 17 10:23:01 2007 -0700

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 mm/slub.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 2b50b97..f93adb9 100644
--- 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
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to