From: Masami Hiramatsu <mhiramat@kernel.org>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
lkml <linux-kernel@vger.kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
"Naveen N . Rao" <naveen.n.rao@linux.ibm.com>,
Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
"David S . Miller" <davem@davemloft.net>
Subject: Re: [PATCH v9 02/11] fprobe: Add ftrace based probe APIs
Date: Mon, 7 Mar 2022 23:00:27 +0900 [thread overview]
Message-ID: <20220307230027.679cca95a201b094e700716d@kernel.org> (raw)
In-Reply-To: <YiYAw64nDTWB/V0t@krava>
On Mon, 7 Mar 2022 13:55:31 +0100
Jiri Olsa <olsajiri@gmail.com> wrote:
> On Sun, Mar 06, 2022 at 06:36:03PM +0900, Masami Hiramatsu wrote:
>
> SNIP
>
> > +}
> > +NOKPROBE_SYMBOL(fprobe_handler);
> > +
> > +/* Convert ftrace location address from symbols */
> > +static unsigned long *get_ftrace_locations(const char **syms, int num)
> > +{
> > + unsigned long addr, size;
> > + unsigned long *addrs;
> > + int i;
> > +
> > + /* Convert symbols to symbol address */
> > + addrs = kcalloc(num, sizeof(*addrs), GFP_KERNEL);
> > + if (!addrs)
> > + return ERR_PTR(-ENOMEM);
> > +
> > + for (i = 0; i < num; i++) {
> > + addrs[i] = kallsyms_lookup_name(syms[i]);
> > + if (!addrs[i]) /* Maybe wrong symbol */
> > + goto error;
> > + }
> > +
> > + /* Convert symbol address to ftrace location. */
> > + for (i = 0; i < num; i++) {
> > + if (!kallsyms_lookup_size_offset(addrs[i], &size, NULL) || !size)
> > + goto error;
> > + addr = ftrace_location_range(addrs[i], addrs[i] + size - 1);
> > + if (!addr) /* No dynamic ftrace there. */
> > + goto error;
> > + addrs[i] = addr;
> > + }
>
> why not one just single loop ?
Indeed :-D Thanks!
>
> jirka
>
>
> > +
> > + return addrs;
> > +
> > +error:
> > + kfree(addrs);
> > +
> > + return ERR_PTR(-ENOENT);
> > +}
> > +
> > +static void fprobe_init(struct fprobe *fp)
> > +{
> > + fp->nmissed = 0;
> > + fp->ops.func = fprobe_handler;
> > + fp->ops.flags |= FTRACE_OPS_FL_SAVE_REGS;
> > +}
>
> SNIP
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2022-03-07 14:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-06 9:35 [PATCH v9 00/11] fprobe: Introduce fprobe function entry/exit probe Masami Hiramatsu
2022-03-06 9:35 ` [PATCH v9 01/11] ftrace: Add ftrace_set_filter_ips function Masami Hiramatsu
2022-03-06 9:36 ` [PATCH v9 02/11] fprobe: Add ftrace based probe APIs Masami Hiramatsu
2022-03-07 12:55 ` Jiri Olsa
2022-03-07 14:00 ` Masami Hiramatsu [this message]
2022-03-06 9:36 ` [PATCH v9 03/11] rethook: Add a generic return hook Masami Hiramatsu
2022-03-06 9:36 ` [PATCH v9 04/11] rethook: x86: Add rethook x86 implementation Masami Hiramatsu
2022-03-06 9:36 ` [PATCH v9 05/11] arm64: rethook: Add arm64 rethook implementation Masami Hiramatsu
2022-03-06 9:36 ` [PATCH v9 06/11] powerpc: Add rethook support Masami Hiramatsu
2022-03-06 9:37 ` [PATCH v9 07/11] fprobe: Add exit_handler support Masami Hiramatsu
2022-03-06 9:37 ` [PATCH v9 08/11] fprobe: Add sample program for fprobe Masami Hiramatsu
2022-03-06 9:37 ` [PATCH v9 09/11] fprobe: Introduce FPROBE_FL_KPROBE_SHARED flag " Masami Hiramatsu
2022-03-06 9:37 ` [PATCH v9 10/11] docs: fprobe: Add fprobe description to ftrace-use.rst Masami Hiramatsu
2022-03-06 9:37 ` [PATCH v9 11/11] fprobe: Add a selftest for fprobe 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=20220307230027.679cca95a201b094e700716d@kernel.org \
--to=mhiramat@kernel.org \
--cc=andrii@kernel.org \
--cc=anil.s.keshavamurthy@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=john.fastabend@gmail.com \
--cc=jolsa@redhat.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=olsajiri@gmail.com \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.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 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).