From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
lkml <linux-kernel@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>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH 10/10] selftest/bpf: Add kprobe_multi test for bpf_cookie values
Date: Sun, 6 Mar 2022 18:29:42 +0100 [thread overview]
Message-ID: <YiTvht+4yyFghc+s@krava> (raw)
In-Reply-To: <CAEf4BzZW-W5PcNmB2PoRE-70e1FjqpE-EJKgxfj2SsvjwdBjRA@mail.gmail.com>
On Fri, Mar 04, 2022 at 03:11:26PM -0800, Andrii Nakryiko wrote:
> On Tue, Feb 22, 2022 at 9:08 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Adding bpf_cookie test for programs attached by kprobe_multi links.
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> > .../selftests/bpf/prog_tests/bpf_cookie.c | 72 +++++++++++++++++++
> > .../bpf/progs/kprobe_multi_bpf_cookie.c | 62 ++++++++++++++++
> > 2 files changed, 134 insertions(+)
> > create mode 100644 tools/testing/selftests/bpf/progs/kprobe_multi_bpf_cookie.c
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
> > index cd10df6cd0fc..edfb9f8736c6 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
> > @@ -7,6 +7,7 @@
> > #include <unistd.h>
> > #include <test_progs.h>
> > #include "test_bpf_cookie.skel.h"
> > +#include "kprobe_multi_bpf_cookie.skel.h"
> >
> > /* uprobe attach point */
> > static void trigger_func(void)
> > @@ -63,6 +64,75 @@ static void kprobe_subtest(struct test_bpf_cookie *skel)
> > bpf_link__destroy(retlink2);
> > }
> >
> > +static void kprobe_multi_subtest(void)
> > +{
> > + DECLARE_LIBBPF_OPTS(bpf_link_create_opts, opts);
> > + int err, prog_fd, link1_fd = -1, link2_fd = -1;
> > + LIBBPF_OPTS(bpf_test_run_opts, topts);
>
> consistency ftw, LIBBPF_OPTS
ok
>
>
> > + struct kprobe_multi_bpf_cookie *skel = NULL;
> > + __u64 addrs[8], cookies[8];
> > +
>
> [..]
>
> > diff --git a/tools/testing/selftests/bpf/progs/kprobe_multi_bpf_cookie.c b/tools/testing/selftests/bpf/progs/kprobe_multi_bpf_cookie.c
> > new file mode 100644
> > index 000000000000..d6f8454ba093
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/progs/kprobe_multi_bpf_cookie.c
> > @@ -0,0 +1,62 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +#include <linux/bpf.h>
> > +#include <bpf/bpf_helpers.h>
> > +#include <bpf/bpf_tracing.h>
> > +
> > +char _license[] SEC("license") = "GPL";
> > +
> > +extern const void bpf_fentry_test1 __ksym;
> > +extern const void bpf_fentry_test2 __ksym;
> > +extern const void bpf_fentry_test3 __ksym;
> > +extern const void bpf_fentry_test4 __ksym;
> > +extern const void bpf_fentry_test5 __ksym;
> > +extern const void bpf_fentry_test6 __ksym;
> > +extern const void bpf_fentry_test7 __ksym;
> > +extern const void bpf_fentry_test8 __ksym;
> > +
> > +/* No tests, just to trigger bpf_fentry_test* through tracing test_run */
> > +SEC("fentry/bpf_modify_return_test")
> > +int BPF_PROG(test1)
> > +{
> > + return 0;
> > +}
> > +
> > +__u64 test2_result = 0;
> > +
> > +SEC("kprobe.multi/bpf_fentry_tes??")
> > +int test2(struct pt_regs *ctx)
> > +{
> > + __u64 cookie = bpf_get_attach_cookie(ctx);
> > + __u64 addr = bpf_get_func_ip(ctx);
> > +
> > + test2_result += (const void *) addr == &bpf_fentry_test1 && cookie == 1;
> > + test2_result += (const void *) addr == &bpf_fentry_test2 && cookie == 2;
> > + test2_result += (const void *) addr == &bpf_fentry_test3 && cookie == 3;
> > + test2_result += (const void *) addr == &bpf_fentry_test4 && cookie == 4;
> > + test2_result += (const void *) addr == &bpf_fentry_test5 && cookie == 5;
> > + test2_result += (const void *) addr == &bpf_fentry_test6 && cookie == 6;
> > + test2_result += (const void *) addr == &bpf_fentry_test7 && cookie == 7;
> > + test2_result += (const void *) addr == &bpf_fentry_test8 && cookie == 8;
>
> this is not parallel mode friendly
>
> let's filter by pid, but also it's best to do count locally and just
> assign it (so that multiple calls of the program still produce the
> same value, instead of constantly increasing global variable with each
> run)
ah I did not think of the paralel run, right, will change
thanks,
jirka
next prev parent reply other threads:[~2022-03-06 17:29 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 17:05 [PATCHv2 bpf-next 0/8] bpf: Add kprobe multi link Jiri Olsa
2022-02-22 17:05 ` [PATCH 01/10] lib/sort: Add priv pointer to swap function Jiri Olsa
2022-02-23 3:22 ` Masami Hiramatsu
2022-02-22 17:05 ` [PATCH 02/10] bpf: Add multi kprobe link Jiri Olsa
2022-02-23 5:58 ` Masami Hiramatsu
2022-02-23 17:44 ` Jiri Olsa
2022-02-24 4:02 ` Masami Hiramatsu
2022-03-04 23:11 ` Andrii Nakryiko
2022-03-06 17:28 ` Jiri Olsa
2022-03-08 1:23 ` Andrii Nakryiko
2022-03-08 14:21 ` Jiri Olsa
2022-02-22 17:05 ` [PATCH 03/10] bpf: Add bpf_get_func_ip kprobe helper for " Jiri Olsa
2022-03-04 23:11 ` Andrii Nakryiko
2022-02-22 17:05 ` [PATCH 04/10] bpf: Add support to inline bpf_get_func_ip helper on x86 Jiri Olsa
2022-02-22 17:05 ` [PATCH 05/10] bpf: Add cookie support to programs attached with kprobe multi link Jiri Olsa
2022-03-04 23:11 ` Andrii Nakryiko
2022-03-06 17:29 ` Jiri Olsa
2022-03-08 1:23 ` Andrii Nakryiko
2022-03-08 14:27 ` Jiri Olsa
2022-02-22 17:05 ` [PATCH 06/10] libbpf: Add libbpf_kallsyms_parse function Jiri Olsa
2022-03-04 23:11 ` Andrii Nakryiko
2022-02-22 17:05 ` [PATCH 07/10] libbpf: Add bpf_link_create support for multi kprobes Jiri Olsa
2022-03-04 23:11 ` Andrii Nakryiko
2022-03-06 17:29 ` Jiri Olsa
2022-02-22 17:05 ` [PATCH 08/10] libbpf: Add bpf_program__attach_kprobe_opts " Jiri Olsa
2022-03-04 23:11 ` Andrii Nakryiko
2022-03-06 17:29 ` Jiri Olsa
2022-03-08 1:28 ` Andrii Nakryiko
2022-03-08 14:23 ` Jiri Olsa
2022-02-22 17:05 ` [PATCH 09/10] selftest/bpf: Add kprobe_multi attach test Jiri Olsa
2022-03-04 23:11 ` Andrii Nakryiko
2022-03-06 17:29 ` Jiri Olsa
2022-02-22 17:06 ` [PATCH 10/10] selftest/bpf: Add kprobe_multi test for bpf_cookie values Jiri Olsa
2022-03-04 23:11 ` Andrii Nakryiko
2022-03-06 17:29 ` Jiri Olsa [this message]
2022-03-04 23:10 ` [PATCHv2 bpf-next 0/8] bpf: Add kprobe multi link Andrii Nakryiko
2022-03-06 1:09 ` Steven Rostedt
2022-03-06 1:32 ` Masami Hiramatsu
2022-03-08 1:45 ` 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=YiTvht+4yyFghc+s@krava \
--to=olsajiri@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.