From: Masami Hiramatsu <mhiramat@kernel.org>
To: Punit Agrawal <punitagrawal@gmail.com>
Cc: naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com,
davem@davemloft.net, linux-kernel@vger.kernel.org,
guoren@kernel.org, linux-csky@vger.kernel.org
Subject: Re: [RFC PATCH 3/5] kprobe: Simplify prepare_kprobe() by dropping redundant version
Date: Wed, 9 Jun 2021 23:42:39 +0900 [thread overview]
Message-ID: <20210609234239.8b61d29b7f12fb1307048e6c@kernel.org> (raw)
In-Reply-To: <20210609105019.3626677-4-punitagrawal@gmail.com>
On Wed, 9 Jun 2021 19:50:17 +0900
Punit Agrawal <punitagrawal@gmail.com> wrote:
> The function prepare_kprobe() is called during kprobe registration and
> is responsible for ensuring any architecture related preparation for
> the kprobe is done before returning.
>
> One of two versions of prepare_kprobe() is chosen depending on the
> availability of KPROBE_ON_FTRACE in the kernel configuration.
>
> Simplify the code by dropping the version when KPROBE_ON_FTRACE is not
> selected - instead relying on kprobe_ftrace() to return false when
> KPROBE_ON_FTRACE is not set.
>
OK, since kprobe_ftrace() just checks a flag is set or not,
it is always usable in kprobes.c.
Looks good to me :)
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Thank you!
> No functional change.
>
> Signed-off-by: Punit Agrawal <punitagrawal@gmail.com>
> ---
> include/linux/kprobes.h | 5 +++++
> kernel/kprobes.c | 23 +++++++++--------------
> 2 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
> index 1883a4a9f16a..771013bab18a 100644
> --- a/include/linux/kprobes.h
> +++ b/include/linux/kprobes.h
> @@ -362,6 +362,11 @@ static inline void wait_for_kprobe_optimizer(void) { }
> extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
> struct ftrace_ops *ops, struct ftrace_regs *fregs);
> extern int arch_prepare_kprobe_ftrace(struct kprobe *p);
> +#else
> +static inline int arch_prepare_kprobe_ftrace(struct kprobe *p)
> +{
> + return -EINVAL;
> +}
> #endif
>
> int arch_check_ftrace_location(struct kprobe *p);
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 1a11d3c411bf..54d37d4ab897 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1022,15 +1022,6 @@ static struct ftrace_ops kprobe_ipmodify_ops __read_mostly = {
> static int kprobe_ipmodify_enabled;
> static int kprobe_ftrace_enabled;
>
> -/* Must ensure p->addr is really on ftrace */
> -static int prepare_kprobe(struct kprobe *p)
> -{
> - if (!kprobe_ftrace(p))
> - return arch_prepare_kprobe(p);
> -
> - return arch_prepare_kprobe_ftrace(p);
> -}
> -
> /* Caller must lock kprobe_mutex */
> static int __arm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops,
> int *cnt)
> @@ -1102,11 +1093,6 @@ static int disarm_kprobe_ftrace(struct kprobe *p)
> ipmodify ? &kprobe_ipmodify_enabled : &kprobe_ftrace_enabled);
> }
> #else /* !CONFIG_KPROBES_ON_FTRACE */
> -static inline int prepare_kprobe(struct kprobe *p)
> -{
> - return arch_prepare_kprobe(p);
> -}
> -
> static inline int arm_kprobe_ftrace(struct kprobe *p)
> {
> return -ENODEV;
> @@ -1118,6 +1104,15 @@ static inline int disarm_kprobe_ftrace(struct kprobe *p)
> }
> #endif
>
> +static int prepare_kprobe(struct kprobe *p)
> +{
> + /* Must ensure p->addr is really on ftrace */
> + if (kprobe_ftrace(p))
> + return arch_prepare_kprobe_ftrace(p);
> +
> + return arch_prepare_kprobe(p);
> +}
> +
> /* Arm a kprobe with text_mutex */
> static int arm_kprobe(struct kprobe *kp)
> {
> --
> 2.30.2
>
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2021-06-09 14:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 10:50 [PATCH 0/5] kprobes: Bugfix and improvements Punit Agrawal
2021-06-09 10:50 ` [PATCH 1/5] kprobes: Do not use local variable when creating debugfs file Punit Agrawal
2021-06-09 14:35 ` Masami Hiramatsu
2021-06-10 23:31 ` Punit Agrawal
2021-06-09 10:50 ` [RFC PATCH 2/5] kprobes: Use helper to parse boolean input from userspace Punit Agrawal
2021-06-09 14:37 ` Masami Hiramatsu
2021-06-09 10:50 ` [RFC PATCH 3/5] kprobe: Simplify prepare_kprobe() by dropping redundant version Punit Agrawal
2021-06-09 14:42 ` Masami Hiramatsu [this message]
2021-06-09 10:50 ` [RFC PATCH 4/5] csky: ftrace: Drop duplicate implementation of arch_check_ftrace_location() Punit Agrawal
2021-06-09 12:33 ` Guo Ren
2021-06-09 14:29 ` Masami Hiramatsu
2021-06-09 15:47 ` Guo Ren
2021-06-10 0:07 ` Masami Hiramatsu
2021-06-09 10:50 ` [RFC PATCH 5/5] kprobes: Make arch_check_ftrace_location static Punit Agrawal
2021-06-10 0:37 ` Masami Hiramatsu
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=20210609234239.8b61d29b7f12fb1307048e6c@kernel.org \
--to=mhiramat@kernel.org \
--cc=anil.s.keshavamurthy@intel.com \
--cc=davem@davemloft.net \
--cc=guoren@kernel.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=punitagrawal@gmail.com \
/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 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.