jump_label: unlikely(x) > 0
PATCH 1/1 jump_label: unlikely(x) > 0
untested, but wasn't this intended instead?
--------------
if (unlikely(x) > 0) doesn't seem to help branch prediction
---
include/linux/jump_label.h +2 -2
@@ -132,14 +132,14 @@ static __always_inline void jump_label_init(void) static __always_inline bool static_key_false(struct static_key *key) { -if (unlikely (atomic_read (&key->enabled)) >0 ) +if (unlikely (atomic_read (&key->enabled) >0 ))return true;return false; } static __always_inline bool static_key_true(struct static_key *key) { -if (likely (atomic_read (&key->enabled)) >0 ) +if (likely (atomic_read (&key->enabled) >0 ))return true;return false; }
Quoted 15 lines · On Fri, 11 Oct 2013 22:50:50 +0200 (CEST) Roel Kluin <[email protected]>…
untested, but wasn't this intended instead?
--------------
if (unlikely(x) > 0) doesn't seem to help branch prediction...
include/linux/jump_label.h +1
-1@@ -132,14 +132,14 @@ static __always_inline void jump_label_init(void) static __always_inline bool static_key_false(struct static_key *key) { -if (unlikely (atomic_read (&key->enabled)) >0 ) +if (unlikely (atomic_read (&key->enabled) >0 ))return true;
include/linux/jump_label.h static __always_inline void jump_label_init(void) · line 145
Quoted 10 lines
include/linux/jump_label.h +1
-1return false; } static __always_inline bool static_key_true(struct static_key *key) { -if (likely (atomic_read (&key->enabled)) >0 ) +if (likely (atomic_read (&key->enabled) >0 ))return true;return false; }
I'm sure this was intended instead ;) The patch doesn't seem to make any difference in code generation with my gcc.
Quoted 4 lines · Andrew Morton
I'm sure this was intended instead ;) The patch doesn't seem to make any difference in code generation with my gcc.
Which is odd, because doesn't unlikely() booleanize?
-hpa
Quoted 7 lines · H. Peter Anvin
Quoted 4 lines · Andrew Morton
I'm sure this was intended instead ;) The patch doesn't seem to make any difference in code generation with my gcc.
Which is odd, because doesn't
unlikely()booleanize?
It's supposed to:
include/linux/compiler.h:#define unlikely_notrace(x) __builtin_expect(!!(x), 0)
Thanks,
Ingo