Skip to contentSkip to conversation

mm/slab.c: replace open-coded round-up code with ALIGN

PATCH New [email protected] 1 participant 1 message Jul 6, 2017 Memory management

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 25/108 mm/slab.c: replace open-coded round-up code with ALIGN

From: Canjiang Lu <[email protected]>
Subject: mm/slab.c: replace open-coded round-up code with ALIGN

---

 mm/slab.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
mm/slab.c renamed from mm/slab.c~subject-mm-slab-trivial-change-to-replace-round-up-code-with-align +2 -6
diff -puN mm/slab.c~subject-mm-slab-trivial-change-to-replace-round-up-code-with-align mm/slab.c
@@ -2040,17 +2040,13 @@ __kmem_cache_create (struct kmem_cache *
 	 * 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);
-	}
+	size = ALIGN(size, BYTES_PER_WORD);
 
 	if (flags & SLAB_RED_ZONE) {
 		ralign = REDZONE_ALIGN;
 		/* If redzoning, ensure that the second redzone is suitably
 		 * aligned, by adjusting the object size accordingly. */
-		size += REDZONE_ALIGN - 1;
-		size &= ~(REDZONE_ALIGN - 1);
+		size = ALIGN(size, REDZONE_ALIGN);
 	}
 
 	/* 3) caller mandated alignment */

_