Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e443fd0 authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds
Browse files

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: default avatarChristoph Lameter <clameter@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0c710013
Loading
Loading
Loading
Loading
+36 −30
Original line number Diff line number Diff line
@@ -2272,19 +2272,9 @@ static struct kmem_cache *create_kmalloc_cache(struct kmem_cache *s,
	panic("Creation of kmalloc slab %s size=%d failed.\n", name, size);
}

static struct kmem_cache *get_slab(size_t size, gfp_t flags)
{
	int index = kmalloc_index(size);

	if (!index)
		return ZERO_SIZE_PTR;

	/* Allocation too large? */
	if (index < 0)
		return NULL;

#ifdef CONFIG_ZONE_DMA
	if ((flags & SLUB_DMA)) {
static noinline struct kmem_cache *dma_kmalloc_cache(int index, gfp_t flags)
{
	struct kmem_cache *s;
	struct kmem_cache *x;
	char *text;
@@ -2314,6 +2304,22 @@ static struct kmem_cache *get_slab(size_t size, gfp_t 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);

	if (!index)
		return ZERO_SIZE_PTR;

	/* Allocation too large? */
	if (index < 0)
		return NULL;

#ifdef CONFIG_ZONE_DMA
	if ((flags & SLUB_DMA))
		return dma_kmalloc_cache(index, flags);
#endif
	return &kmalloc_caches[index];
}