lkml.org 
[lkml]   [2022]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v9 02/11] fprobe: Add ftrace based probe APIs
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>

\
 
 \ /
  Last update: 2022-03-07 15:01    [W:0.703 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site