[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YiYAw64nDTWB/V0t@krava>
Date: Mon, 7 Mar 2022 13:55:31 +0100
From: Jiri Olsa <olsajiri@...il.com>
To: Masami Hiramatsu <mhiramat@...nel.org>
Cc: Jiri Olsa <jolsa@...hat.com>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, netdev@...r.kernel.org,
bpf@...r.kernel.org, lkml <linux-kernel@...r.kernel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
"Naveen N . Rao" <naveen.n.rao@...ux.ibm.com>,
Anil S Keshavamurthy <anil.s.keshavamurthy@...el.com>,
"David S . Miller" <davem@...emloft.net>
Subject: Re: [PATCH v9 02/11] fprobe: Add ftrace based probe APIs
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 ?
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
Powered by blists - more mailing lists