[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220408095815.9827bcf7aa98127046f69481@kernel.org>
Date: Fri, 8 Apr 2022 09:58:15 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: Jiri Olsa <jolsa@...nel.org>
Cc: 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>
Subject: Re: [RFC bpf-next 2/4] fprobe: Resolve symbols with
kallsyms_lookup_names
On Thu, 7 Apr 2022 14:52:22 +0200
Jiri Olsa <jolsa@...nel.org> wrote:
> Using kallsyms_lookup_names to speed up symbols lookup
> in register_fprobe_syms API.
OK, this looks good to me.
Acked-by: Masami Hiramatsu <mhiramat@...nel.org>
Thank you!
>
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
> kernel/kallsyms.c | 2 +-
> kernel/trace/fprobe.c | 23 ++---------------------
> 2 files changed, 3 insertions(+), 22 deletions(-)
>
> diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
> index a3738ddf9e87..7d89da375c23 100644
> --- a/kernel/kallsyms.c
> +++ b/kernel/kallsyms.c
> @@ -230,7 +230,7 @@ unsigned long kallsyms_lookup_name(const char *name)
> return module_kallsyms_lookup_name(name);
> }
>
> -#ifdef CONFIG_LIVEPATCH
> +#if defined(CONFIG_LIVEPATCH) || defined(CONFIG_FPROBE)
> /*
> * Iterate over all symbols in vmlinux. For symbols from modules use
> * module_kallsyms_on_each_symbol instead.
> diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
> index 89d9f994ebb0..d466803dc2b2 100644
> --- a/kernel/trace/fprobe.c
> +++ b/kernel/trace/fprobe.c
> @@ -88,36 +88,17 @@ NOKPROBE_SYMBOL(fprobe_exit_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++) {
> - addr = kallsyms_lookup_name(syms[i]);
> - if (!addr) /* Maybe wrong symbol */
> - goto error;
> + if (!kallsyms_lookup_names(syms, num, addrs))
> + return addrs;
>
> - /* Convert symbol address to ftrace location. */
> - if (!kallsyms_lookup_size_offset(addr, &size, NULL) || !size)
> - goto error;
> -
> - addr = ftrace_location_range(addr, addr + size - 1);
> - if (!addr) /* No dynamic ftrace there. */
> - goto error;
> -
> - addrs[i] = addr;
> - }
> -
> - return addrs;
> -
> -error:
> kfree(addrs);
> -
> return ERR_PTR(-ENOENT);
> }
>
> --
> 2.35.1
>
--
Masami Hiramatsu <mhiramat@...nel.org>
Powered by blists - more mailing lists