lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20120209143924.886e0ff6.akpm@linux-foundation.org>
Date:	Thu, 9 Feb 2012 14:39:24 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	daniel.santos@...ox.com
Cc:	Daniel Santos <danielfsantos@....net>,
	torvalds@...ux-foundation.org, linux-kernel@...r.kernel.org,
	Pekka Enberg <penberg@...helsinki.fi>
Subject: Re: mm/slab.c: remove effectively dead code from kmem_cache_create

On Wed, 08 Feb 2012 22:16:23 -0600
Daniel Santos <danielfsantos@....net> wrote:

> I was examining slab.c when I noticed that there is code that will never
> be executed, but that the compiler probably wouldn't determine as such. 

Please cc the maintainer (Pekka) on slab patches.

Please include a Signed-off-by: on patches, as discussed in
Documentation/SubmittingPatches.

--- a/mm/slab.c~mm-slabc-remove-effectively-dead-code-from-kmem_cache_create
+++ a/mm/slab.c
@@ -2326,6 +2326,7 @@ kmem_cache_create (const char *name, siz
 		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, siz
 		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, siz
 	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, siz
 		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.
_


kmem_cache_create() is called extremely rarely, so the performance
benefit here is negligible.

We could presumably avoid two of those ifdefs by defining SLAB_RED_ZONE
and SLAB_STORE_USER to be zero if !defined(DEBUG).  Personally I think
that's a bit too subtle and would prefer the explicit ifdefs.

In my x86_64 allnoconfig build the patch reduces slab.o's text size
from 12859 bytes to 12812.  I'll let Pekka decide if that's worth it ;)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ