diff options
author | Mateusz Nosek <mateusznosek0@gmail.com> | 2020-04-06 20:08:49 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-04-07 10:43:42 -0700 |
commit | 1386f7a3bfa6245a69f1fa39786be54a73889ff7 (patch) | |
tree | 90e9f94f112a2c2b5eeda15c10fe9a33b882ec53 /mm/dmapool.c | |
parent | 1d90b6491014ead775146726b81a78ed993c3188 (diff) |
mm/dmapool.c: micro-optimisation remove unnecessary branch
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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20200320173317.26408-1-mateusznosek0@gmail.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/dmapool.c')
-rw-r--r-- | mm/dmapool.c | 4 |
1 files changed, 1 insertions, 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) |