mm/slab.c: micro-optimization spare one branch in main flow
PATCH 1/1 mm/slab.c: micro-optimization spare one branch in main flow
From: Mateusz Nosek <[email protected]>
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 <[email protected]>
--- mm/slab.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
mm/slab.c +3 -2
@@ -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 ;
Signature · 1 line
2.20.1