From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
Petr Mladek <pmladek@suse.com>,
Zhen Lei <thunder.leizhen@huawei.com>,
bpf@vger.kernel.org, live-patching@vger.kernel.org,
linux-modules@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>,
Joe Lawrence <joe.lawrence@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Luis Chamberlain <mcgrof@kernel.org>
Subject: Re: [PATCHv2 bpf-next 2/3] selftests/bpf: Add serial_test_kprobe_multi_bench_attach_kernel/module tests
Date: Sun, 15 Jan 2023 22:49:06 +0100 [thread overview]
Message-ID: <Y8R00sRwznbKlJV3@krava> (raw)
In-Reply-To: <CAEf4BzZSzM0NznnEH0oD9y6Zdd6YDZWEp4HyL1+2hLBrWk=j1w@mail.gmail.com>
On Fri, Jan 13, 2023 at 02:43:47PM -0800, Andrii Nakryiko wrote:
> On Fri, Jan 13, 2023 at 6:33 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Add bench test for module portion of the symbols as well.
> >
> > # ./test_progs -v -t kprobe_multi_bench_attach_module
> > bpf_testmod.ko is already unloaded.
> > Loading bpf_testmod.ko...
> > Successfully loaded bpf_testmod.ko.
> > test_kprobe_multi_bench_attach:PASS:get_syms 0 nsec
> > test_kprobe_multi_bench_attach:PASS:kprobe_multi_empty__open_and_load 0 nsec
> > test_kprobe_multi_bench_attach:PASS:bpf_program__attach_kprobe_multi_opts 0 nsec
> > test_kprobe_multi_bench_attach: found 26620 functions
> > test_kprobe_multi_bench_attach: attached in 0.182s
> > test_kprobe_multi_bench_attach: detached in 0.082s
> > #96 kprobe_multi_bench_attach_module:OK
> > Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
> > Successfully unloaded bpf_testmod.ko.
> >
> > It's useful for testing kprobe multi link modules resolving.
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> > .../bpf/prog_tests/kprobe_multi_test.c | 21 ++++++++++++++-----
> > 1 file changed, 16 insertions(+), 5 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
> > index c6f37e825f11..017a6996f3fa 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
> > @@ -322,7 +322,7 @@ static bool symbol_equal(long key1, long key2, void *ctx __maybe_unused)
> > return strcmp((const char *) key1, (const char *) key2) == 0;
> > }
> >
> > -static int get_syms(char ***symsp, size_t *cntp)
> > +static int get_syms(char ***symsp, size_t *cntp, bool kernel)
> > {
> > size_t cap = 0, cnt = 0, i;
> > char *name = NULL, **syms = NULL;
> > @@ -349,8 +349,9 @@ static int get_syms(char ***symsp, size_t *cntp)
> > }
> >
> > while (fgets(buf, sizeof(buf), f)) {
> > - /* skip modules */
> > - if (strchr(buf, '['))
> > + if (kernel && strchr(buf, '['))
> > + continue;
> > + if (!kernel && !strchr(buf, '['))
> > continue;
> >
> > free(name);
> > @@ -404,7 +405,7 @@ static int get_syms(char ***symsp, size_t *cntp)
> > return err;
> > }
> >
> > -void serial_test_kprobe_multi_bench_attach(void)
> > +static void test_kprobe_multi_bench_attach(bool kernel)
> > {
> > LIBBPF_OPTS(bpf_kprobe_multi_opts, opts);
> > struct kprobe_multi_empty *skel = NULL;
> > @@ -415,7 +416,7 @@ void serial_test_kprobe_multi_bench_attach(void)
> > char **syms = NULL;
> > size_t cnt = 0, i;
> >
> > - if (!ASSERT_OK(get_syms(&syms, &cnt), "get_syms"))
> > + if (!ASSERT_OK(get_syms(&syms, &cnt, kernel), "get_syms"))
> > return;
> >
> > skel = kprobe_multi_empty__open_and_load();
> > @@ -453,6 +454,16 @@ void serial_test_kprobe_multi_bench_attach(void)
> > }
> > }
> >
> > +void serial_test_kprobe_multi_bench_attach_kernel(void)
> > +{
> > + test_kprobe_multi_bench_attach(true);
> > +}
> > +
> > +void serial_test_kprobe_multi_bench_attach_module(void)
> > +{
> > + test_kprobe_multi_bench_attach(false);
> > +}
> > +
>
> minor nit: probably would be better to make kernel and module variants
> into subtests?
ok, will change that
thanks,
jirka
next prev parent reply other threads:[~2023-01-15 21:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-13 14:33 [PATCHv2 bpf-next 0/3] kallsyms: Optimize the search for module symbols by livepatch and bpf Jiri Olsa
2023-01-13 14:33 ` [PATCHv2 bpf-next 1/3] livepatch: Improve the search performance of module_kallsyms_on_each_symbol() Jiri Olsa
2023-01-13 20:24 ` Song Liu
2023-01-13 14:33 ` [PATCHv2 bpf-next 2/3] selftests/bpf: Add serial_test_kprobe_multi_bench_attach_kernel/module tests Jiri Olsa
2023-01-13 20:27 ` Song Liu
2023-01-13 22:43 ` Andrii Nakryiko
2023-01-15 21:49 ` Jiri Olsa [this message]
2023-01-13 14:33 ` [PATCHv2 bpf-next 3/3] bpf: Change modules resolving for kprobe multi link Jiri Olsa
2023-01-13 20:41 ` Song Liu
2023-01-13 22:22 ` 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=Y8R00sRwznbKlJV3@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=haoluo@google.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=john.fastabend@gmail.com \
--cc=jpoimboe@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-modules@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mbenes@suse.cz \
--cc=mcgrof@kernel.org \
--cc=mhiramat@kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sdf@google.com \
--cc=songliubraving@fb.com \
--cc=thunder.leizhen@huawei.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;
as well as URLs for NNTP newsgroup(s).