lkml.org 
[lkml]   [2020]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mm/slab.c: micro-optimization spare one branch in main flow
Date
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
\
 
 \ /
  Last update: 2020-09-16 22:10    [W:0.025 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site