From: Jiri Olsa <olsajiri@gmail.com>
To: Quentin Monnet <quentin@isovalent.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Yafang Shao <laoar.shao@gmail.com>
Subject: Re: [PATCH bpf-next 8/8] bpftool: Display cookie for kprobe multi link
Date: Fri, 19 Jan 2024 09:03:07 +0100 [thread overview]
Message-ID: <Zaosu7TEPONDZRog@krava> (raw)
In-Reply-To: <48e86f23-d938-4705-b91a-adbe4ee3123c@isovalent.com>
On Thu, Jan 18, 2024 at 05:51:17PM +0000, Quentin Monnet wrote:
SNIP
> > static __u64 *u64_to_arr(__u64 val)
> > @@ -675,8 +706,8 @@ void netfilter_dump_plain(const struct bpf_link_info *info)
> >
> > static void show_kprobe_multi_plain(struct bpf_link_info *info)
> > {
> > + struct addr_cookie *data;
> > __u32 i, j = 0;
> > - __u64 *addrs;
> >
> > if (!info->kprobe_multi.count)
> > return;
> > @@ -688,8 +719,11 @@ static void show_kprobe_multi_plain(struct bpf_link_info *info)
> > printf("func_cnt %u ", info->kprobe_multi.count);
> > if (info->kprobe_multi.missed)
> > printf("missed %llu ", info->kprobe_multi.missed);
> > - addrs = (__u64 *)u64_to_ptr(info->kprobe_multi.addrs);
> > - qsort(addrs, info->kprobe_multi.count, sizeof(__u64), cmp_u64);
> > + data = get_addr_cookie_array(u64_to_ptr(info->kprobe_multi.addrs),
> > + u64_to_ptr(info->kprobe_multi.cookies),
> > + info->kprobe_multi.count);
> > + if (!data)
> > + return;
> >
> > /* Load it once for all. */
> > if (!dd.sym_count)
> > @@ -697,12 +731,12 @@ static void show_kprobe_multi_plain(struct bpf_link_info *info)
> > if (!dd.sym_count)
> > return;
>
> Don't we need to free(data) if we return here?
good catch! I guess I got distracted by show_kprobe_multi_plain being
similar to show_kprobe_multi_json, which does not check dd.sym_count
and does not return, which it should :-\ I'll include that fix as well
thanks,
jirka
>
> >
> > - printf("\n\t%-16s %s", "addr", "func [module]");
> > + printf("\n\t%-16s %-16s %s", "addr", "cookie", "func [module]");
> > for (i = 0; i < dd.sym_count; i++) {
> > - if (dd.sym_mapping[i].address != addrs[j])
> > + if (dd.sym_mapping[i].address != data[j].addr)
> > continue;
> > - printf("\n\t%016lx %s",
> > - dd.sym_mapping[i].address, dd.sym_mapping[i].name);
> > + printf("\n\t%016lx %-16llx %s",
> > + dd.sym_mapping[i].address, data[j].cookie, dd.sym_mapping[i].name);
> > if (dd.sym_mapping[i].module[0] != '\0')
> > printf(" [%s] ", dd.sym_mapping[i].module);
> > else
> > @@ -711,6 +745,7 @@ static void show_kprobe_multi_plain(struct bpf_link_info *info)
> > if (j++ == info->kprobe_multi.count)
> > break;
> > }
> > + free(data);
> > }
> >
> > static void show_uprobe_multi_plain(struct bpf_link_info *info)
> > @@ -966,6 +1001,14 @@ static int do_show_link(int fd)
> > return -ENOMEM;
> > }
> > info.kprobe_multi.addrs = ptr_to_u64(addrs);
> > + cookies = calloc(count, sizeof(__u64));
> > + if (!cookies) {
> > + p_err("mem alloc failed");
> > + free(addrs);
> > + close(fd);
> > + return -ENOMEM;
> > + }
> > + info.kprobe_multi.cookies = ptr_to_u64(cookies);
> > goto again;
> > }
> > }
>
next prev parent reply other threads:[~2024-01-19 8:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-18 9:54 [PATCH bpf-next 0/8] bpf: Add cookies retrieval for perf/kprobe multi links Jiri Olsa
2024-01-18 9:54 ` [PATCH bpf-next 1/8] bpf: Add cookie to perf_event bpf_link_info records Jiri Olsa
2024-01-18 12:24 ` Yafang Shao
2024-01-19 8:03 ` Jiri Olsa
2024-01-18 9:54 ` [PATCH bpf-next 2/8] bpf: Store cookies in kprobe_multi bpf_link_info data Jiri Olsa
2024-01-18 13:21 ` Yafang Shao
2024-01-18 9:54 ` [PATCH bpf-next 3/8] bpftool: Fix wrong free call in do_show_link Jiri Olsa
2024-01-18 12:29 ` Yafang Shao
2024-01-18 17:51 ` Quentin Monnet
2024-01-18 9:54 ` [PATCH bpf-next 4/8] selftests/bpf: Add cookies check for kprobe_multi fill_link_info test Jiri Olsa
2024-01-18 9:54 ` [PATCH bpf-next 5/8] selftests/bpf: Add cookies check for perf_event " Jiri Olsa
2024-01-18 9:54 ` [PATCH bpf-next 6/8] selftests/bpf: Add fill_link_info test for perf event Jiri Olsa
2024-01-18 9:54 ` [PATCH bpf-next 7/8] bpftool: Display cookie for perf event link probes Jiri Olsa
2024-01-18 17:51 ` Quentin Monnet
2024-01-18 9:54 ` [PATCH bpf-next 8/8] bpftool: Display cookie for kprobe multi link Jiri Olsa
2024-01-18 17:51 ` Quentin Monnet
2024-01-19 8:03 ` Jiri Olsa [this message]
2024-01-18 12:42 ` [PATCH bpf-next 0/8] bpf: Add cookies retrieval for perf/kprobe multi links Yafang Shao
2024-01-19 8:03 ` Jiri Olsa
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=Zaosu7TEPONDZRog@krava \
--to=olsajiri@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=laoar.shao@gmail.com \
--cc=quentin@isovalent.com \
--cc=sdf@google.com \
--cc=songliubraving@fb.com \
--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