From: Jiri Olsa <olsajiri@gmail.com>
To: Jackie Liu <liu.yun@linux.dev>
Cc: olsajiri@gmail.com, andrii@kernel.org, martin.lau@linux.dev,
song@kernel.org, yhs@fb.com, bpf@vger.kernel.org,
liuyun01@kylinos.cn, rostedt@goodmis.org
Subject: Re: [PATCH] libbpf: kprobe.multi: Filter with available_filter_functions_addrs
Date: Fri, 23 Jun 2023 15:57:52 +0200 [thread overview]
Message-ID: <ZJWk4MR984KMiXKi@krava> (raw)
In-Reply-To: <20230623021245.2887248-1-liu.yun@linux.dev>
On Fri, Jun 23, 2023 at 10:12:45AM +0800, Jackie Liu wrote:
SNIP
> +
> +static void kprobe_multi_resolve_free(struct kprobe_multi_resolve *res)
> +{
> + free(res->addrs);
> +
> + /* reset to zero, when fallback */
> + res->cap = 0;
> + res->cnt = 0;
> + res->addrs = NULL;
> +}
> +
> struct bpf_link *
> bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
> const char *pattern,
> @@ -10477,9 +10539,16 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
> return libbpf_err_ptr(-EINVAL);
>
> if (pattern) {
> - err = libbpf_kallsyms_parse(resolve_kprobe_multi_cb, &res);
> - if (err)
> - goto error;
> + err = libbpf_available_kprobes_parse(ftrace_resolve_kprobe_multi_cb,
> + &res);
> + if (err) {
> + /* fallback to kallsyms */
> + kprobe_multi_resolve_free(&res);
> + err = libbpf_kallsyms_parse(kallsyms_resolve_kprobe_multi_cb,
> + &res);
> + if (err)
> + goto error;
> + }
> if (!res.cnt) {
> err = -ENOENT;
> goto error;
> @@ -10512,12 +10581,12 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
> goto error;
> }
> link->fd = link_fd;
> - free(res.addrs);
> + kprobe_multi_resolve_free(&res);
we don't need to zero res in here, so we could just leave the original
free(res.addrs) in here and perhaps rename kprobe_multi_resolve_free
to kprobe_multi_resolve_reinit
thanks,
jirka
> return link;
>
> error:
> free(link);
> - free(res.addrs);
> + kprobe_multi_resolve_free(&res);
> return libbpf_err_ptr(err);
> }
>
> --
> 2.25.1
>
prev parent reply other threads:[~2023-06-23 13:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 2:12 [PATCH] libbpf: kprobe.multi: Filter with available_filter_functions_addrs Jackie Liu
2023-06-23 13:57 ` Jiri Olsa [this message]
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=ZJWk4MR984KMiXKi@krava \
--to=olsajiri@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=liu.yun@linux.dev \
--cc=liuyun01@kylinos.cn \
--cc=martin.lau@linux.dev \
--cc=rostedt@goodmis.org \
--cc=song@kernel.org \
--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