* [PATCH] jump_label: unlikely(x) > 0
@ 2013-10-11 20:50 Roel Kluin
2013-10-11 20:57 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Roel Kluin @ 2013-10-11 20:50 UTC (permalink / raw)
To: Andrew Jones, Raghavendra K T, Konrad Rzeszutek Wilk,
H. Peter Anvin, Ingo Molnar, Andrew Morton, LKML
untested, but wasn't this intended instead?
--------------
if (unlikely(x) > 0) doesn't seem to help branch prediction
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index a507907..cf08540 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -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;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] jump_label: unlikely(x) > 0
2013-10-11 20:50 [PATCH] jump_label: unlikely(x) > 0 Roel Kluin
@ 2013-10-11 20:57 ` Andrew Morton
2013-10-15 16:53 ` H. Peter Anvin
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2013-10-11 20:57 UTC (permalink / raw)
To: Roel Kluin
Cc: Andrew Jones, Raghavendra K T, Konrad Rzeszutek Wilk,
H. Peter Anvin, Ingo Molnar, LKML
On Fri, 11 Oct 2013 22:50:50 +0200 (CEST) Roel Kluin <roel.kluin@gmail.com> wrote:
> untested, but wasn't this intended instead?
> --------------
> if (unlikely(x) > 0) doesn't seem to help branch prediction
>
> ...
>
> --- a/include/linux/jump_label.h
> +++ b/include/linux/jump_label.h
> @@ -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;
> }
I'm sure this was intended instead ;) The patch doesn't seem to make
any difference in code generation with my gcc.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] jump_label: unlikely(x) > 0
2013-10-11 20:57 ` Andrew Morton
@ 2013-10-15 16:53 ` H. Peter Anvin
2013-10-16 6:46 ` Ingo Molnar
0 siblings, 1 reply; 4+ messages in thread
From: H. Peter Anvin @ 2013-10-15 16:53 UTC (permalink / raw)
To: Andrew Morton
Cc: Roel Kluin, Andrew Jones, Raghavendra K T, Konrad Rzeszutek Wilk,
Ingo Molnar, LKML
On 10/11/2013 01:57 PM, Andrew Morton wrote:
>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] jump_label: unlikely(x) > 0
2013-10-15 16:53 ` H. Peter Anvin
@ 2013-10-16 6:46 ` Ingo Molnar
0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2013-10-16 6:46 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Andrew Morton, Roel Kluin, Andrew Jones, Raghavendra K T,
Konrad Rzeszutek Wilk, LKML
* H. Peter Anvin <hpa@linux.intel.com> wrote:
> On 10/11/2013 01:57 PM, Andrew Morton wrote:
> >
> > 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-10-16 6:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-11 20:50 [PATCH] jump_label: unlikely(x) > 0 Roel Kluin
2013-10-11 20:57 ` Andrew Morton
2013-10-15 16:53 ` H. Peter Anvin
2013-10-16 6:46 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).