All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] signal: replace !likely with unlikely!
@ 2014-09-11  0:48 roy.qing.li
  2014-09-11 19:18 ` Guenter Roeck
  0 siblings, 1 reply; 5+ messages in thread
From: roy.qing.li @ 2014-09-11  0:48 UTC (permalink / raw)
  To: linux-kernel, viro, fabf, jkosina, paulmck, richard, oleg, akpm

From: Li RongQing <roy.qing.li@gmail.com> 

!likely() is hard to be understood, and I do not know if compiler can
optimise this condition, but unlikely(!()) is clear

Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
 kernel/signal.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 8f0876f..6156cfa 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1571,7 +1571,7 @@ int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group)
 	BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
 
 	ret = -1;
-	if (!likely(lock_task_sighand(t, &flags)))
+	if (unlikely(!lock_task_sighand(t, &flags)))
 		goto ret;
 
 	ret = 1; /* the signal is ignored */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC][PATCH] signal: replace !likely with unlikely!
  2014-09-11  0:48 [RFC][PATCH] signal: replace !likely with unlikely! roy.qing.li
@ 2014-09-11 19:18 ` Guenter Roeck
  2014-09-13  2:48   ` Li RongQing
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2014-09-11 19:18 UTC (permalink / raw)
  To: roy.qing.li
  Cc: linux-kernel, viro, fabf, jkosina, paulmck, richard, oleg, akpm

On Thu, Sep 11, 2014 at 08:48:16AM +0800, roy.qing.li@gmail.com wrote:
> From: Li RongQing <roy.qing.li@gmail.com> 
> 
> !likely() is hard to be understood, and I do not know if compiler can
> optimise this condition, but unlikely(!()) is clear
> 
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
> ---
>  kernel/signal.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/signal.c b/kernel/signal.c
> index 8f0876f..6156cfa 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -1571,7 +1571,7 @@ int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group)
>  	BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
>  
>  	ret = -1;
> -	if (!likely(lock_task_sighand(t, &flags)))
> +	if (unlikely(!lock_task_sighand(t, &flags)))

I wonder if you tested this code. Seems to be unlikely (punt not intended).

Guenter

>  		goto ret;
>  
>  	ret = 1; /* the signal is ignored */
> -- 
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC][PATCH] signal: replace !likely with unlikely!
  2014-09-11 19:18 ` Guenter Roeck
@ 2014-09-13  2:48   ` Li RongQing
  2014-09-13 10:04     ` Richard Weinberger
  0 siblings, 1 reply; 5+ messages in thread
From: Li RongQing @ 2014-09-13  2:48 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-kernel, viro, fabf, jkosina, Paul McKenney, richard, oleg, akpm

I did not test, how to test it?

On Fri, Sep 12, 2014 at 3:18 AM, Guenter Roeck <linux@roeck-us.net> wrote:
> On Thu, Sep 11, 2014 at 08:48:16AM +0800, roy.qing.li@gmail.com wrote:
>> From: Li RongQing <roy.qing.li@gmail.com>
>>
>> !likely() is hard to be understood, and I do not know if compiler can
>> optimise this condition, but unlikely(!()) is clear
>>
>> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
>> ---
>>  kernel/signal.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/signal.c b/kernel/signal.c
>> index 8f0876f..6156cfa 100644
>> --- a/kernel/signal.c
>> +++ b/kernel/signal.c
>> @@ -1571,7 +1571,7 @@ int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group)
>>       BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
>>
>>       ret = -1;
>> -     if (!likely(lock_task_sighand(t, &flags)))
>> +     if (unlikely(!lock_task_sighand(t, &flags)))
>
> I wonder if you tested this code. Seems to be unlikely (punt not intended).
>
> Guenter
>
>>               goto ret;
>>
>>       ret = 1; /* the signal is ignored */
>> --
>> 1.7.10.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>>
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC][PATCH] signal: replace !likely with unlikely!
  2014-09-13  2:48   ` Li RongQing
@ 2014-09-13 10:04     ` Richard Weinberger
  2014-09-13 13:28       ` Guenter Roeck
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Weinberger @ 2014-09-13 10:04 UTC (permalink / raw)
  To: Li RongQing, Guenter Roeck
  Cc: linux-kernel, viro, fabf, jkosina, Paul McKenney, oleg, akpm

Am 13.09.2014 04:48, schrieb Li RongQing:
> I did not test, how to test it?

Compare the object files of both variants to find out whether both create
semantically equivalent code and whether the un/likely have an effect.
i.e. objdump -S -d kernel/signal.o
I guess you can just remove the likely as gcc is smart enough to detect the "goto ret;"
as an unlikely taken branch.

Thanks,
//richard

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC][PATCH] signal: replace !likely with unlikely!
  2014-09-13 10:04     ` Richard Weinberger
@ 2014-09-13 13:28       ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2014-09-13 13:28 UTC (permalink / raw)
  To: Richard Weinberger, Li RongQing
  Cc: linux-kernel, viro, fabf, jkosina, Paul McKenney, oleg, akpm

On 09/13/2014 03:04 AM, Richard Weinberger wrote:
> Am 13.09.2014 04:48, schrieb Li RongQing:
>> I did not test, how to test it?
>
> Compare the object files of both variants to find out whether both create
> semantically equivalent code and whether the un/likely have an effect.
> i.e. objdump -S -d kernel/signal.o
> I guess you can just remove the likely as gcc is smart enough to detect the "goto ret;"
> as an unlikely taken branch.
>
Or just write similar test code and observe the result.

When you are doing that, you might learn that if "(!likely(expression))"
is _not_ the same as "if (unlikely(!expression))".

Guenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-09-13 13:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-11  0:48 [RFC][PATCH] signal: replace !likely with unlikely! roy.qing.li
2014-09-11 19:18 ` Guenter Roeck
2014-09-13  2:48   ` Li RongQing
2014-09-13 10:04     ` Richard Weinberger
2014-09-13 13:28       ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.