linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/slab.c: micro-optimization spare one branch in main flow
@ 2020-09-16 20:05 mateusznosek0
  0 siblings, 0 replies; only message in thread
From: mateusznosek0 @ 2020-09-16 20:05 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Mateusz Nosek, cl, penberg, rientjes, iamjoonsoo.kim, akpm

From: Mateusz Nosek <mateusznosek0@gmail.com>

By small refactoring two 'unlikely' branches are changed so that if
not one of them is true then only one branch occurs in 'likely' path
of the function in question. Change verified in assembly generated
by gcc 8.3.0.

Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
---
 mm/slab.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 2cb494d98fe9..e04ea756bcbc 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4186,9 +4186,10 @@ size_t __ksize(const void *objp)
 	struct kmem_cache *c;
 	size_t size;
 
-	BUG_ON(!objp);
-	if (unlikely(objp == ZERO_SIZE_PTR))
+	if (unlikely(ZERO_OR_NULL_PTR(objp))) {
+		BUG_ON(!objp);
 		return 0;
+	}
 
 	c = virt_to_cache(objp);
 	size = c ? c->object_size : 0;
-- 
2.20.1



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

only message in thread, other threads:[~2020-09-16 20:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 20:05 [PATCH] mm/slab.c: micro-optimization spare one branch in main flow mateusznosek0

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox