bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>
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 v4 6/8] selftests/bpf: Add weak/typeless ksym test for light skeleton
Date: Wed, 20 Oct 2021 15:17:19 -0700	[thread overview]
Message-ID: <CAEf4BzajqpFv-pwt7vZ3+Ob8y7RnqcCMVRvWhF1Nfr_J-NFZ0A@mail.gmail.com> (raw)
In-Reply-To: <20211020191526.2306852-7-memxor@gmail.com>

On Wed, Oct 20, 2021 at 12:15 PM Kumar Kartikeya Dwivedi
<memxor@gmail.com> wrote:
>
> Also, avoid using CO-RE features, as lskel doesn't support CO-RE, yet.
> Include both light and libbpf skeleton in same file to test both of them
> together.
>
> In c48e51c8b07a ("bpf: selftests: Add selftests for module kfunc support"),
> I added support for generating both lskel and libbpf skel for a BPF
> object, however the name parameter for bpftool caused collisions when
> included in same file together. This meant that every test needed a
> separate file for a libbpf/light skeleton separation instead of
> subtests.
>
> Change that by appending a "_light" suffix to the name for files listed
> in LSKELS_EXTRA, such that both light and libbpf skeleton can be used in
> the same file for subtests, leading to better code sharing.
>
> While at it, improve the build output by saying GEN-LSKEL instead of
> GEN-SKEL for light skeleton generation recipe.
>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> ---
>  tools/testing/selftests/bpf/Makefile          |  7 ++--
>  .../selftests/bpf/prog_tests/ksyms_btf.c      | 35 +++++++++++++++-
>  .../selftests/bpf/prog_tests/ksyms_module.c   | 40 +++++++++++++++++--
>  .../bpf/prog_tests/ksyms_module_libbpf.c      | 28 -------------
>  .../selftests/bpf/progs/test_ksyms_weak.c     |  3 +-
>  5 files changed, 74 insertions(+), 39 deletions(-)
>  delete mode 100644 tools/testing/selftests/bpf/prog_tests/ksyms_module_libbpf.c
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 498222543c37..1c3c8befc249 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -325,7 +325,7 @@ LINKED_SKELS := test_static_linked.skel.h linked_funcs.skel.h               \
>  LSKELS := kfunc_call_test.c fentry_test.c fexit_test.c fexit_sleep.c \
>         test_ringbuf.c atomics.c trace_printk.c trace_vprintk.c
>  # Generate both light skeleton and libbpf skeleton for these
> -LSKELS_EXTRA := test_ksyms_module.c
> +LSKELS_EXTRA := test_ksyms_module.c test_ksyms_weak.c
>  SKEL_BLACKLIST += $$(LSKELS)
>
>  test_static_linked.skel.h-deps := test_static_linked1.o test_static_linked2.o
> @@ -399,12 +399,13 @@ $(TRUNNER_BPF_SKELS): %.skel.h: %.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
>         $(Q)$$(BPFTOOL) gen skeleton $$(<:.o=.linked3.o) name $$(notdir $$(<:.o=)) > $$@
>
>  $(TRUNNER_BPF_LSKELS): %.lskel.h: %.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
> -       $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
> +       $$(call msg,GEN-LSKEL,$(TRUNNER_BINARY),$$@)

This breaks nice output alignment:

  GEN-SKEL [test_progs-no_alu32] bpf_iter_tcp4.skel.h
  GEN-LSKEL [test_progs-no_alu32] trace_vprintk.lskel.h

Isn't ".lskel.h" suffix enough to distinguish them?

>         $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked1.o) $$<
>         $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked2.o) $$(<:.o=.linked1.o)
>         $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked3.o) $$(<:.o=.linked2.o)
>         $(Q)diff $$(<:.o=.linked2.o) $$(<:.o=.linked3.o)
> -       $(Q)$$(BPFTOOL) gen skeleton -L $$(<:.o=.linked3.o) name $$(notdir $$(<:.o=)) > $$@
> +       $$(eval LSKEL_NAME := $$(notdir $$(<:.o=$$(if $$(filter $$(notdir $$(<:.o=.c)),$(LSKELS_EXTRA)),_light,))))

eval inside eval?.. Wow, do we really need that? If you just want to
add _light (I suggest _lskel though, it will make for a more
meaningful and recognizable names in user-space code) suffix, do it
for all light skeletons unconditionally and keep it simple?

> +       $(Q)$$(BPFTOOL) gen skeleton -L $$(<:.o=.linked3.o) name $$(LSKEL_NAME) > $$@
>
>  $(TRUNNER_BPF_SKELS_LINKED): $(TRUNNER_BPF_OBJS) $(BPFTOOL) | $(TRUNNER_OUTPUT)
>         $$(call msg,LINK-BPF,$(TRUNNER_BINARY),$$(@:.skel.h=.o))

[...]

  reply	other threads:[~2021-10-20 22:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-20 19:15 [PATCH bpf-next v4 0/8] Typeless/weak ksym for gen_loader + misc fixups Kumar Kartikeya Dwivedi
2021-10-20 19:15 ` [PATCH bpf-next v4 1/8] bpf: Add bpf_kallsyms_lookup_name helper Kumar Kartikeya Dwivedi
2021-10-20 19:15 ` [PATCH bpf-next v4 2/8] libbpf: Add typeless ksym support to gen_loader Kumar Kartikeya Dwivedi
2021-10-20 19:15 ` [PATCH bpf-next v4 3/8] libbpf: Add weak " Kumar Kartikeya Dwivedi
2021-10-20 19:15 ` [PATCH bpf-next v4 4/8] libbpf: Ensure that BPF syscall fds are never 0, 1, or 2 Kumar Kartikeya Dwivedi
2021-10-20 22:09   ` Andrii Nakryiko
2021-10-20 22:33     ` Kumar Kartikeya Dwivedi
2021-10-20 23:02       ` Andrii Nakryiko
2021-10-20 19:15 ` [PATCH bpf-next v4 5/8] libbpf: Use O_CLOEXEC uniformly when opening fds Kumar Kartikeya Dwivedi
2021-10-20 19:15 ` [PATCH bpf-next v4 6/8] selftests/bpf: Add weak/typeless ksym test for light skeleton Kumar Kartikeya Dwivedi
2021-10-20 22:17   ` Andrii Nakryiko [this message]
2021-10-20 22:37     ` Kumar Kartikeya Dwivedi
2021-10-20 22:43       ` Andrii Nakryiko
2021-10-20 19:15 ` [PATCH bpf-next v4 7/8] selftests/bpf: Fix fd cleanup in sk_lookup test Kumar Kartikeya Dwivedi
2021-10-20 22:19   ` Andrii Nakryiko
2021-10-20 19:15 ` [PATCH bpf-next v4 8/8] selftests/bpf: Fix memory leak in test_ima Kumar Kartikeya Dwivedi

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=CAEf4BzajqpFv-pwt7vZ3+Ob8y7RnqcCMVRvWhF1Nfr_J-NFZ0A@mail.gmail.com \
    --to=andrii.nakryiko@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=memxor@gmail.com \
    --cc=netdev@vger.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 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).