compile out effectively dead code from kmem_cache_create

From: Daniel Santos
Date: Wed Feb 08 2012 - 22:26:49 EST


---
mm/slab.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index f0bd785..1840a4a 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2326,6 +2326,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
ralign = BYTES_PER_WORD;
}

+#if DEBUG
/*
* Redzoning and user store require word alignment or possibly larger.
* Note this will be overridden by architecture or caller mandated
@@ -2341,6 +2342,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
size += REDZONE_ALIGN - 1;
size &= ~(REDZONE_ALIGN - 1);
}
+#endif

/* 2) arch mandated alignment */
if (ralign < ARCH_SLAB_MINALIGN) {
@@ -2350,9 +2352,13 @@ kmem_cache_create (const char *name, size_t size, size_t align,
if (ralign < align) {
ralign = align;
}
+
+#if DEBUG
/* disable debug if necessary */
if (ralign > __alignof__(unsigned long long))
flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
+#endif
+
/*
* 4) Store it.
*/
@@ -2442,7 +2448,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
slab_size =
cachep->num * sizeof(kmem_bufctl_t) + sizeof(struct slab);

-#ifdef CONFIG_PAGE_POISONING
+#if DEBUG && defined(CONFIG_PAGE_POISONING)
/* If we're going to use the generic kernel_map_pages()
* poisoning, then it's going to smash the contents of
* the redzone and userword anyhow, so switch them off.