lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Wed, 16 Sep 2020 22:05:39 +0200
From:   mateusznosek0@...il.com
To:     linux-mm@...ck.org, linux-kernel@...r.kernel.org
Cc:     Mateusz Nosek <mateusznosek0@...il.com>, cl@...ux.com,
        penberg@...nel.org, rientjes@...gle.com, iamjoonsoo.kim@....com,
        akpm@...ux-foundation.org
Subject: [PATCH] mm/slab.c: micro-optimization spare one branch in main flow

From: Mateusz Nosek <mateusznosek0@...il.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@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ