All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kprobes: drop the unnecessary unlikely()
@ 2022-06-13  4:25 l3b2w1
  2022-06-15  0:15 ` Masami Hiramatsu
  0 siblings, 1 reply; 2+ messages in thread
From: l3b2w1 @ 2022-06-13  4:25 UTC (permalink / raw)
  To: mhiramat
  Cc: naveen.n.rao, anil.s.keshavamurthy, davem, linux-kernel, binglei.wang

From: "binglei.wang" <l3b2w1@gmail.com>

!ap is likely when checking re-registering existing kprobe.
	register_kprobe -> warn_kprobe_rereg -> __get_valid_kprobe

!ap is unlikely when checking whether the kprobe is valid
on enable/disable ocassion.
	__disable_kprobe/enable_kprobe -> __get_valid_kprobe

Considering these two cases, choose to drop the unlikely() here.

Signed-off-by: binglei.wang <l3b2w1@gmail.com>
---
 kernel/kprobes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index f214f8c08..f4a829d98 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1504,7 +1504,7 @@ static struct kprobe *__get_valid_kprobe(struct kprobe *p)
 	lockdep_assert_held(&kprobe_mutex);
 
 	ap = get_kprobe(p->addr);
-	if (unlikely(!ap))
+	if (!ap)
 		return NULL;
 
 	if (p != ap) {
-- 
2.27.0


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

* Re: [PATCH] kprobes: drop the unnecessary unlikely()
  2022-06-13  4:25 [PATCH] kprobes: drop the unnecessary unlikely() l3b2w1
@ 2022-06-15  0:15 ` Masami Hiramatsu
  0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2022-06-15  0:15 UTC (permalink / raw)
  To: l3b2w1
  Cc: naveen.n.rao, anil.s.keshavamurthy, davem, linux-kernel, Steven Rostedt

On Mon, 13 Jun 2022 12:25:36 +0800
l3b2w1@gmail.com wrote:

> From: "binglei.wang" <l3b2w1@gmail.com>
> 
> !ap is likely when checking re-registering existing kprobe.
> 	register_kprobe -> warn_kprobe_rereg -> __get_valid_kprobe
> 
> !ap is unlikely when checking whether the kprobe is valid
> on enable/disable ocassion.
> 	__disable_kprobe/enable_kprobe -> __get_valid_kprobe
> 
> Considering these two cases, choose to drop the unlikely() here.
> 
> Signed-off-by: binglei.wang <l3b2w1@gmail.com>

This looks good to me.

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thank you!

> ---
>  kernel/kprobes.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index f214f8c08..f4a829d98 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1504,7 +1504,7 @@ static struct kprobe *__get_valid_kprobe(struct kprobe *p)
>  	lockdep_assert_held(&kprobe_mutex);
>  
>  	ap = get_kprobe(p->addr);
> -	if (unlikely(!ap))
> +	if (!ap)
>  		return NULL;
>  
>  	if (p != ap) {
> -- 
> 2.27.0
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

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

end of thread, other threads:[~2022-06-15  0:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13  4:25 [PATCH] kprobes: drop the unnecessary unlikely() l3b2w1
2022-06-15  0:15 ` Masami Hiramatsu

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.