mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: l3b2w1@gmail.com
Cc: naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com,
	davem@davemloft.net, linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] kprobes: drop the unnecessary unlikely()
Date: Wed, 15 Jun 2022 09:15:01 +0900	[thread overview]
Message-ID: <20220615091501.0323c2c7cc89b2d337cb0322@kernel.org> (raw)
In-Reply-To: <20220613042536.20329-1-l3b2w1@gmail.com>

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>

      reply	other threads:[~2022-06-15  0:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-13  4:25 l3b2w1
2022-06-15  0:15 ` Masami Hiramatsu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220615091501.0323c2c7cc89b2d337cb0322@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=davem@davemloft.net \
    --cc=l3b2w1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®