All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/dmapool.c: micro-optimisation remove unnecessary branch
@ 2020-03-20 17:33 mateusznosek0
  0 siblings, 0 replies; only message in thread
From: mateusznosek0 @ 2020-03-20 17:33 UTC (permalink / raw)
  To: linux-mm, linux-kernel; +Cc: Mateusz Nosek, akpm

From: Mateusz Nosek <mateusznosek0@gmail.com>

Previously there was a check if 'size' is aligned to 'align' and if not
then it was aligned. This check was expensive as both branch and division
are expensive instructions in most architectures.
'ALIGN' function on already aligned value will not change it, and as it is
cheaper than branch + division it can be executed all the time and
branch can be removed.

Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
---
 mm/dmapool.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index fe5d33060415..f9fb9bbd733e 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -144,9 +144,7 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
 	else if (size < 4)
 		size = 4;
 
-	if ((size % align) != 0)
-		size = ALIGN(size, align);
-
+	size = ALIGN(size, align);
 	allocation = max_t(size_t, size, PAGE_SIZE);
 
 	if (!boundary)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-20 17:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 17:33 [PATCH] mm/dmapool.c: micro-optimisation remove unnecessary branch mateusznosek0

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.