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

    SLUB: extract dma_kmalloc_cache from get_cache.
    
    The rarely used dma functionality in get_slab() makes the function too
    complex.  The compiler begins to spill variables from the working set onto 
the
    stack.  The created function is only used in extremely rare cases so make 
sure
    that the compiler does not decide on its own to merge it back into 
get_slab().
    
    Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 mm/slub.c |   66 +++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 55b508d..2b50b97 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2272,6 +2272,40 @@ panic:
        panic("Creation of kmalloc slab %s size=%d failed.\n", name, size);
 }
 
+#ifdef CONFIG_ZONE_DMA
+static noinline struct kmem_cache *dma_kmalloc_cache(int index, gfp_t flags)
+{
+       struct kmem_cache *s;
+       struct kmem_cache *x;
+       char *text;
+       size_t realsize;
+
+       s = kmalloc_caches_dma[index];
+       if (s)
+               return s;
+
+       /* Dynamically create dma cache */
+       x = kmalloc(kmem_size, flags & ~SLUB_DMA);
+       if (!x)
+               panic("Unable to allocate memory for dma cache\n");
+
+       if (index <= KMALLOC_SHIFT_HIGH)
+               realsize = 1 << index;
+       else {
+               if (index == 1)
+                       realsize = 96;
+               else
+                       realsize = 192;
+       }
+
+       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;
+}
+#endif
+
 static struct kmem_cache *get_slab(size_t size, gfp_t flags)
 {
        int index = kmalloc_index(size);
@@ -2284,36 +2318,8 @@ static struct kmem_cache *get_slab(size_t size, gfp_t 
flags)
                return NULL;
 
 #ifdef CONFIG_ZONE_DMA
-       if ((flags & SLUB_DMA)) {
-               struct kmem_cache *s;
-               struct kmem_cache *x;
-               char *text;
-               size_t realsize;
-
-               s = kmalloc_caches_dma[index];
-               if (s)
-                       return s;
-
-               /* Dynamically create dma cache */
-               x = kmalloc(kmem_size, flags & ~SLUB_DMA);
-               if (!x)
-                       panic("Unable to allocate memory for dma cache\n");
-
-               if (index <= KMALLOC_SHIFT_HIGH)
-                       realsize = 1 << index;
-               else {
-                       if (index == 1)
-                               realsize = 96;
-                       else
-                               realsize = 192;
-               }
-
-               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;
-       }
+       if ((flags & SLUB_DMA))
+               return dma_kmalloc_cache(index, flags);
 #endif
        return &kmalloc_caches[index];
 }
-
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