Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1667493 > unrolled thread

Subject: [PATCH] mm/slab: trivial change to replace round-up code with ALIGN

Started by陆灿江 <canjiang.lu@samsung.com>
First post2017-06-16 09:30 +0200
Last post2017-06-16 09:30 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Subject: [PATCH] mm/slab: trivial change to replace round-up code  with ALIGN 陆灿江 <canjiang.lu@samsung.com> - 2017-06-16 09:30 +0200

#1667493 — Subject: [PATCH] mm/slab: trivial change to replace round-up code with ALIGN

From陆灿江 <canjiang.lu@samsung.com>
Date2017-06-16 09:30 +0200
SubjectSubject: [PATCH] mm/slab: trivial change to replace round-up code with ALIGN
Message-ID<tSTRF-5pn-25@gated-at.bofh.it>
This patch makes use of ALIGN() to remove duplicate round-up code.

Signed-off-by: Canjiang Lu <canjiang.lu@samsung.com>
---
 mm/slab.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 807d86c..69e08a4 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2040,17 +2040,13 @@ static bool set_on_slab_cache(struct kmem_cache *cachep,
 	 * 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 */
-- 
1.9.1

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web