Common 22/22] Common object size alignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All allocators align the objects to a word boundary. Put that into
common code.

Signed-off-by: Christoph Lameter <cl@xxxxxxxxx>

---
 mm/slab.c        |   10 ----------
 mm/slab_common.c |    3 ++-
 mm/slub.c        |    7 -------
 3 files changed, 2 insertions(+), 18 deletions(-)

Index: linux-2.6/mm/slab.c
===================================================================
--- linux-2.6.orig/mm/slab.c	2012-05-23 09:13:05.938664721 -0500
+++ linux-2.6/mm/slab.c	2012-05-23 09:13:30.758664204 -0500
@@ -2240,16 +2240,6 @@ int __kmem_cache_create(struct kmem_cach
 	BUG_ON(flags & ~CREATE_MASK);
 
 	/*
-	 * Check that size is in terms of words.  This is needed to avoid
-	 * unaligned accesses for some archs when redzoning is used, and makes
-	 * sure any on-slab bufctl's are also correctly aligned.
-	 */
-	if (size & (BYTES_PER_WORD - 1)) {
-		size += (BYTES_PER_WORD - 1);
-		size &= ~(BYTES_PER_WORD - 1);
-	}
-
-	/*
 	 * Redzoning and user store require word alignment or possibly larger.
 	 * Note this will be overridden by architecture or caller mandated
 	 * alignment if either is greater than BYTES_PER_WORD.
Index: linux-2.6/mm/slab_common.c
===================================================================
--- linux-2.6.orig/mm/slab_common.c	2012-05-23 09:13:05.974664718 -0500
+++ linux-2.6/mm/slab_common.c	2012-05-23 09:14:49.634662589 -0500
@@ -127,6 +127,7 @@ struct kmem_cache *kmem_cache_create(con
 	WARN_ON(strchr(name, ' '));	/* It confuses parsers */
 #endif
 
+	/* Align size to a word boundary */
 	s = __kmem_cache_alias(name, size, align, flags, ctor);
 	if (s)
 		goto oops;
@@ -144,7 +145,7 @@ struct kmem_cache *kmem_cache_create(con
 
 	s->name = n;
 	s->ctor = ctor;
-	s->size = size;
+	s->size = ALIGN(s->size, sizeof(void *));
 	s->align = calculate_alignment(flags, align, size);
 	s->flags = flags;
 	r = __kmem_cache_create(s);
Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c	2012-05-23 09:13:05.954664718 -0500
+++ linux-2.6/mm/slub.c	2012-05-23 09:13:30.762664204 -0500
@@ -2860,13 +2860,6 @@ static int calculate_sizes(struct kmem_c
 	unsigned long align = s->align;
 	int order;
 
-	/*
-	 * Round up object size to the next word boundary. We can only
-	 * place the free pointer at word boundaries and this determines
-	 * the possible location of the free pointer.
-	 */
-	size = ALIGN(size, sizeof(void *));
-
 #ifdef CONFIG_SLUB_DEBUG
 	/*
 	 * Determine if we can poison the object itself. If the user of

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]