aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2007-07-17 07:03:24 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-17 13:23:01 -0400
commit2e443fd003d76394a8ceb78f079260478aa10710 (patch)
treee67fe6e1382ec7a2f636ab09285a41620192eb9f /mm
parent0c710013200e72b5e0bc680ff4ec6bdac53c5ce8 (diff)
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 <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')
-rw-r--r--mm/slub.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 55b508df62a3..2b50b97a0fc3 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2272,6 +2272,40 @@ panic:
2272 panic("Creation of kmalloc slab %s size=%d failed.\n", name, size); 2272 panic("Creation of kmalloc slab %s size=%d failed.\n", name, size);
2273} 2273}
2274 2274
2275#ifdef CONFIG_ZONE_DMA
2276static noinline struct kmem_cache *dma_kmalloc_cache(int index, gfp_t flags)
2277{
2278 struct kmem_cache *s;
2279 struct kmem_cache *x;
2280 char *text;
2281 size_t realsize;
2282
2283 s = kmalloc_caches_dma[index];
2284 if (s)
2285 return s;
2286
2287 /* Dynamically create dma cache */
2288 x = kmalloc(kmem_size, flags & ~SLUB_DMA);
2289 if (!x)
2290 panic("Unable to allocate memory for dma cache\n");
2291
2292 if (index <= KMALLOC_SHIFT_HIGH)
2293 realsize = 1 << index;
2294 else {
2295 if (index == 1)
2296 realsize = 96;
2297 else
2298 realsize = 192;
2299 }
2300
2301 text = kasprintf(flags & ~SLUB_DMA, "kmalloc_dma-%d",
2302 (unsigned int)realsize);
2303 s = create_kmalloc_cache(x, text, realsize, flags);
2304 kmalloc_caches_dma[index] = s;
2305 return s;
2306}
2307#endif
2308
2275static struct kmem_cache *get_slab(size_t size, gfp_t flags) 2309static struct kmem_cache *get_slab(size_t size, gfp_t flags)
2276{ 2310{
2277 int index = kmalloc_index(size); 2311 int index = kmalloc_index(size);
@@ -2284,36 +2318,8 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
2284 return NULL; 2318 return NULL;
2285 2319
2286#ifdef CONFIG_ZONE_DMA 2320#ifdef CONFIG_ZONE_DMA
2287 if ((flags & SLUB_DMA)) { 2321 if ((flags & SLUB_DMA))
2288 struct kmem_cache *s; 2322 return dma_kmalloc_cache(index, flags);
2289 struct kmem_cache *x;
2290 char *text;
2291 size_t realsize;
2292
2293 s = kmalloc_caches_dma[index];
2294 if (s)
2295 return s;
2296
2297 /* Dynamically create dma cache */
2298 x = kmalloc(kmem_size, flags & ~SLUB_DMA);
2299 if (!x)
2300 panic("Unable to allocate memory for dma cache\n");
2301
2302 if (index <= KMALLOC_SHIFT_HIGH)
2303 realsize = 1 << index;
2304 else {
2305 if (index == 1)
2306 realsize = 96;
2307 else
2308 realsize = 192;
2309 }
2310
2311 text = kasprintf(flags & ~SLUB_DMA, "kmalloc_dma-%d",
2312 (unsigned int)realsize);
2313 s = create_kmalloc_cache(x, text, realsize, flags);
2314 kmalloc_caches_dma[index] = s;
2315 return s;
2316 }
2317#endif 2323#endif
2318 return &kmalloc_caches[index]; 2324 return &kmalloc_caches[index];
2319} 2325}