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
Subject: Re: [PATCH] libbpf: kprobe.multi: feedback function counts by kernel traced
Date: Mon, 26 Jun 2023 15:53:08 +0200 [thread overview]
Message-ID: <ZJmYRMGue8LvvchL@krava> (raw)
In-Reply-To: <20230625021816.1734617-1-liu.yun@linux.dev>
On Sun, Jun 25, 2023 at 10:18:16AM +0800, Jackie Liu wrote:
> From: Jackie Liu <liuyun01@kylinos.cn>
>
> When tracking functions through kprobe.multi, the number of tracked
> functions cannot be directly obtained. Sometimes in order to calculate
> this value, it is necessary to recalculate according to the pattern in
> the program. This is unnecessary. It is calculated by libbpf feedback
> through opts.cnt value, which can save resources. Example at [1].
>
> [1] https://github.com/JackieLiu1/ketones/blob/master/src/funccount/funccount.c#L317
>
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
> tools/lib/bpf/libbpf.c | 3 ++-
> tools/lib/bpf/libbpf.h | 2 +-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index fca5d2e412c5..ed3f1202c570 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -10506,7 +10506,7 @@ static void kprobe_multi_resolve_reinit(struct kprobe_multi_resolve *res)
> struct bpf_link *
> bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
> const char *pattern,
> - const struct bpf_kprobe_multi_opts *opts)
> + struct bpf_kprobe_multi_opts *opts)
> {
> LIBBPF_OPTS(bpf_link_create_opts, lopts);
> struct kprobe_multi_resolve res = {
> @@ -10582,6 +10582,7 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
> }
> link->fd = link_fd;
> free(res.addrs);
> + OPTS_SET(opts, cnt, res.cnt);
hum I'm not sure it's good idea to use opts for output values
there's ongoing patchset adding possibility to get this
info/value via BPF_OBJ_GET_INFO_BY_FD syscall [1]
jirka
[1] https://lore.kernel.org/bpf/20230623141546.3751-1-laoar.shao@gmail.com/
> return link;
>
> error:
> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> index 0b7362397ea3..f860dacc6add 100644
> --- a/tools/lib/bpf/libbpf.h
> +++ b/tools/lib/bpf/libbpf.h
> @@ -527,7 +527,7 @@ struct bpf_kprobe_multi_opts {
> LIBBPF_API struct bpf_link *
> bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
> const char *pattern,
> - const struct bpf_kprobe_multi_opts *opts);
> + struct bpf_kprobe_multi_opts *opts);
>
> struct bpf_ksyscall_opts {
> /* size of this struct, for forward/backward compatibility */
> --
> 2.25.1
>
next prev parent reply other threads:[~2023-06-26 13:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-25 2:18 [PATCH] libbpf: kprobe.multi: feedback function counts by kernel traced Jackie Liu
2023-06-26 13:53 ` Jiri Olsa [this message]
2023-06-26 23:49 ` Andrii Nakryiko
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=ZJmYRMGue8LvvchL@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=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