All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: Song Liu <song@kernel.org>
Cc: bpf <bpf@vger.kernel.org>, "Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <kafai@fb.com>,
	"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
	"Jesper Dangaard Brouer" <brouer@redhat.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	Networking <netdev@vger.kernel.org>
Subject: Re: [PATCH bpf-next v1 4/6] bpf: selftests: Move test_ksyms_weak test to lskel, add libbpf test
Date: Fri, 8 Oct 2021 02:16:09 +0530	[thread overview]
Message-ID: <20211007204609.ygrqpx4rahfzqzly@apollo.localdomain> (raw)
In-Reply-To: <CAPhsuW7y3ycWkXLwSmJ5TKbo7Syd65aLRABtWbZcohET0RF6rA@mail.gmail.com>

On Fri, Oct 08, 2021 at 02:03:49AM IST, Song Liu wrote:
> On Tue, Oct 5, 2021 at 5:29 PM Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote:
> >
> > Also, avoid using CO-RE features, as lskel doesn't support CO-RE, yet.
> > Create a file for testing libbpf skeleton as well, so that both
> > gen_loader and libbpf get tested.
> >
> > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> [...]
> > diff --git a/tools/testing/selftests/bpf/prog_tests/ksyms_weak_libbpf.c b/tools/testing/selftests/bpf/prog_tests/ksyms_weak_libbpf.c
> > new file mode 100644
> > index 000000000000..b75725e28647
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/prog_tests/ksyms_weak_libbpf.c
> > @@ -0,0 +1,31 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +
> > +#include <test_progs.h>
> > +#include "test_ksyms_weak.skel.h"
> > +
> > +void test_ksyms_weak_libbpf(void)
>
> This is (almost?) the same as test_weak_syms(), right? Why do we need both?
>

One includes lskel.h (light skeleton), the other includes skel.h (libbpf
skeleton). Trying to include both in the same file, it ends up redefining the
same struct. I am not sure whether adding a prefix/suffix to light skeleton
struct names is possible now, maybe through another option to bpftool in
addition to name?

> > +{
> > +       struct test_ksyms_weak *skel;
> > +       struct test_ksyms_weak__data *data;
> > +       int err;
> > +
> > +       skel = test_ksyms_weak__open_and_load();
> > +       if (!ASSERT_OK_PTR(skel, "test_ksyms_weak__open_and_load"))
> > +               return;
>
> [...]
>
> > diff --git a/tools/testing/selftests/bpf/progs/test_ksyms_weak.c b/tools/testing/selftests/bpf/progs/test_ksyms_weak.c
> > index 5f8379aadb29..521e7b99db08 100644
> > --- a/tools/testing/selftests/bpf/progs/test_ksyms_weak.c
> > +++ b/tools/testing/selftests/bpf/progs/test_ksyms_weak.c
> > @@ -21,7 +21,6 @@ __u64 out__non_existent_typed = -1;
> >  extern const struct rq runqueues __ksym __weak; /* typed */
> >  extern const void bpf_prog_active __ksym __weak; /* typeless */
> >
> > -
> >  /* non-existent weak symbols. */
> >
> >  /* typeless symbols, default to zero. */
> > @@ -38,7 +37,7 @@ int pass_handler(const void *ctx)
> >         /* tests existing symbols. */
> >         rq = (struct rq *)bpf_per_cpu_ptr(&runqueues, 0);
> >         if (rq)
> > -               out__existing_typed = rq->cpu;
> > +               out__existing_typed = 0;
>
> Why do we need this change?
>

Since they share the same BPF object for generating skeleton, it needs to remove
dependency on CO-RE which gen_loader does not support.

If it is kept, we get this:
...
libbpf: // TODO core_relo: prog 0 insn[5] rq kind 0
libbpf: prog 'pass_handler': relo #0: failed to relocate: -95
libbpf: failed to perform CO-RE relocations: -95
libbpf: failed to load object 'test_ksyms_weak'
...
> >         out__existing_typeless = (__u64)&bpf_prog_active;
> >
> >         /* tests non-existent symbols. */
> > --
> > 2.33.0
> >

--
Kartikeya

  reply	other threads:[~2021-10-07 20:46 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06  0:28 [PATCH bpf-next v1 0/6] Typeless/weak ksym for gen_loader + misc fixups Kumar Kartikeya Dwivedi
2021-10-06  0:28 ` [PATCH bpf-next v1 1/6] bpf: Add bpf_kallsyms_lookup_name helper Kumar Kartikeya Dwivedi
2021-10-07 20:23   ` Song Liu
2021-10-06  0:28 ` [PATCH bpf-next v1 2/6] libbpf: Add typeless and weak ksym support to gen_loader Kumar Kartikeya Dwivedi
2021-10-07 21:45   ` Song Liu
2021-10-07 22:01     ` Kumar Kartikeya Dwivedi
2021-10-07 22:17       ` Song Liu
2021-10-06  0:28 ` [PATCH bpf-next v1 3/6] libbpf: Ensure that module BTF fd is never 0 Kumar Kartikeya Dwivedi
2021-10-06  4:41   ` Andrii Nakryiko
2021-10-06  5:24     ` Kumar Kartikeya Dwivedi
2021-10-06 16:43       ` Andrii Nakryiko
2021-10-06 19:09         ` Alexei Starovoitov
2021-10-06 19:38           ` Andrii Nakryiko
2021-10-07 10:24             ` Toke Høiland-Jørgensen
2021-10-07 18:44               ` Kumar Kartikeya Dwivedi
2021-10-07 21:29                 ` Andrii Nakryiko
2021-10-06  0:28 ` [PATCH bpf-next v1 4/6] bpf: selftests: Move test_ksyms_weak test to lskel, add libbpf test Kumar Kartikeya Dwivedi
2021-10-07 20:33   ` Song Liu
2021-10-07 20:46     ` Kumar Kartikeya Dwivedi [this message]
2021-10-07 20:55       ` Kumar Kartikeya Dwivedi
2021-10-07 20:57       ` Song Liu
2021-10-06  0:28 ` [PATCH bpf-next v1 5/6] bpf: selftests: Fix fd cleanup in sk_lookup test Kumar Kartikeya Dwivedi
2021-10-06  6:49   ` Jakub Sitnicki
2021-10-07 21:48     ` Song Liu
2021-10-06  0:28 ` [PATCH bpf-next v1 6/6] bpf: selftests: Fix memory leak in test_ima Kumar Kartikeya Dwivedi
2021-10-06  4:44   ` Andrii Nakryiko
2021-10-07 21:48     ` Song Liu

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=20211007204609.ygrqpx4rahfzqzly@apollo.localdomain \
    --to=memxor@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=songliubraving@fb.com \
    --cc=toke@redhat.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.