On Mon, 7 Mar 2022 13:55:31 +0100 Jiri Olsa <olsajiri@xxxxxxxxx> 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@xxxxxxxxxx>