public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Tony Ambardar <tony.ambardar@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Ihor Solodrai <ihor.solodrai@pm.me>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"ast@kernel.org" <ast@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	"mykolal@fb.com" <mykolal@fb.com>
Subject: Re: [PATCH bpf-next v4] selftests/bpf: use auto-dependencies for test objects
Date: Fri, 19 Jul 2024 14:54:31 -0700	[thread overview]
Message-ID: <Zprglznwj5h1/Wps@kodidev-ubuntu> (raw)
In-Reply-To: <CAEf4BzYX=sfVGcEYq=KSmnC28cqUsRpN=fCwRuUpOMrYAfzzHg@mail.gmail.com>

On Fri, Jul 19, 2024 at 11:18:16AM -0700, Andrii Nakryiko wrote:
> On Thu, Jul 18, 2024 at 3:57 PM Ihor Solodrai <ihor.solodrai@pm.me> wrote:
> >
> > Make use of -M compiler options when building .test.o objects to
> > generate .d files and avoid re-building all tests every time.
> >
> > Previously, if a single test bpf program under selftests/bpf/progs/*.c
> > has changed, make would rebuild all the *.bpf.o, *.skel.h and *.test.o
> > objects, which is a lot of unnecessary work.
> >
> > A typical dependency chain is:
> > progs/x.c -> x.bpf.o -> x.skel.h -> x.test.o -> trunner_binary
> >
> > However for many tests it's not a 1:1 mapping by name, and so far
> > %.test.o have been simply dependent on all %.skel.h files, and
> > %.skel.h files on all %.bpf.o objects.
> >
> > Avoid full rebuilds by instructing the compiler (via -MMD) to
> > produce *.d files with real dependencies, and appropriately including
> > them. Exploit make feature that rebuilds included makefiles if they
> > were changed by setting %.test.d as prerequisite for %.test.o files.
> >
> > A couple of examples of compilation time speedup (after the first
> > clean build):
> >
> > $ touch progs/verifier_and.c && time make -j8
> > Before: real    0m16.651s
> > After:  real    0m2.245s
> > $ touch progs/read_vsyscall.c && time make -j8
> > Before: real    0m15.743s
> > After:  real    0m1.575s
> >
> > A drawback of this change is that now there is an overhead due to make
> > processing lots of .d files, which potentially may slow down unrelated
> > targets. However a time to make all from scratch hasn't changed
> > significantly:
> >
> > $ make clean && time make -j8
> > Before: real    1m31.148s
> > After:  real    1m30.309s
> >
> > Suggested-by: Eduard Zingerman <eddyz87@gmail.com>
> > Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
> >
> > ---
> > v3 -> v4: Make $(TRUNNER_BPF_OBJS) order only prereq of trunner binary
> > v2 -> v3: Restore dependency on $(TRUNNER_BPF_OBJS)
> > v1 -> v2: Make %.test.d prerequisite order only
> > ---
> >  tools/testing/selftests/bpf/.gitignore |  1 +
> >  tools/testing/selftests/bpf/Makefile   | 44 +++++++++++++++++++-------
> >  2 files changed, 34 insertions(+), 11 deletions(-)
> >
> 
> It seems to behave correctly, but it reports wrong flavor when
> building .bpf.o, e.g.,:
> 
Hi Andrii,

This is actually an old, confusing bug unrelated to the current (very
nice) improvements. I have a fix as part of a larger series
targeting libc portability and MIPS support which I'll post shortly.  Or
I can send separately if you like?

Thanks,
Tony

> $ touch progs/test_vmlinux.c
> $ make -j90
>   CLNG-BPF [test_maps] test_vmlinux.bpf.o
>   CLNG-BPF [test_maps] test_vmlinux.bpf.o
>   CLNG-BPF [test_maps] test_vmlinux.bpf.o
>   GEN-SKEL [test_progs] test_vmlinux.skel.h
>   GEN-SKEL [test_progs-cpuv4] test_vmlinux.skel.h
>   GEN-SKEL [test_progs-no_alu32] test_vmlinux.skel.h
>   TEST-OBJ [test_progs] vmlinux.test.o
>   TEST-OBJ [test_progs-no_alu32] vmlinux.test.o
>   EXT-COPY [test_progs-no_alu32] urandom_read bpf_testmod.ko
> bpf_test_no_cfi.ko liburandom_read.so xdp_synproxy sign-file
> uprobe_multi ima_setup.sh verify_sig_setup.sh
> btf_dump_test_case_bitfields.c btf_dump_test_case_multidim.c
> btf_dump_test_case_namespacing.c btf_dump_test_case_ordering.c
> btf_dump_test_case_packing.c btf_dump_test_case_padding.c
> btf_dump_test_case_syntax.c
>   TEST-OBJ [test_progs-cpuv4] vmlinux.test.o
>   EXT-COPY [test_progs-cpuv4] urandom_read bpf_testmod.ko
> bpf_test_no_cfi.ko liburandom_read.so xdp_synproxy sign-file
> uprobe_multi ima_setup.sh verify_sig_setup.sh
> btf_dump_test_case_bitfields.c btf_dump_test_case_multidim.c
> btf_dump_test_case_namespacing.c btf_dump_test_case_ordering.c
> btf_dump_test_case_packing.c btf_dump_test_case_padding.c
> btf_dump_test_case_syntax.c
> make[1]: Nothing to be done for 'docs'.
>   BINARY   test_progs
>   BINARY   test_progs-no_alu32
>   BINARY   test_progs-cpuv4
> $ ls -la test_vmlinux.bpf.o no_alu32/test_vmlinux.bpf.o cpuv4/test_vmlinux.bpf.o
> -rw-r--r-- 1 andriin users 21344 Jul 19 11:08 cpuv4/test_vmlinux.bpf.o
> -rw-r--r-- 1 andriin users 21408 Jul 19 11:08 no_alu32/test_vmlinux.bpf.o
> -rw-r--r-- 1 andriin users 21408 Jul 19 11:08 test_vmlinux.bpf.o
> 
> 
> Note [test_maps] for all three variants (I expected
> test_maps/test_progs + no_alu32 + cpuv4, just like we see for skel.h).
> Can you please double check what's going on? Looking at timestamps it
> seems like they are actually regenerated, though.
> 
> 
> BTW, if you get a chance, see if you can avoid unnecessary EXT-COPY as
> well (probably a bit smarter rule dependency should be set up, e.g.,
> phony target that then depends on actual files or something like
> that).
> 
> Regardless, this is a massive improvement and seems to work correctly,
> so I've applied this and will wait for follow ups. Thanks a lot!
> 
> BTW, are you planning to look into vmlinux.h optimization as well?
> 
> > diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftests/bpf/.gitignore
> > index 5025401323af..4e4aae8aa7ec 100644
> > --- a/tools/testing/selftests/bpf/.gitignore
> > +++ b/tools/testing/selftests/bpf/.gitignore
> > @@ -31,6 +31,7 @@ test_tcp_check_syncookie_user
> >  test_sysctl
> >  xdping
> >  test_cpp
> > +*.d
> >  *.subskel.h
> >  *.skel.h
> >  *.lskel.h
> 
> [...]

  parent reply	other threads:[~2024-07-19 21:54 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-18 22:57 [PATCH bpf-next v4] selftests/bpf: use auto-dependencies for test objects Ihor Solodrai
2024-07-19 18:18 ` Andrii Nakryiko
2024-07-19 19:03   ` Ihor Solodrai
2024-07-19 21:54   ` Tony Ambardar [this message]
2024-07-19 22:25     ` Andrii Nakryiko
2024-07-19 23:21       ` [PATCH bpf-next v1] selftests/bpf: Fix wrong binary in Makefile log output Tony Ambardar
2024-07-20  0:14         ` bot+bpf-ci
2024-07-20  1:23         ` Eduard Zingerman
2024-07-20  2:57         ` Andrii Nakryiko
2024-07-20  5:23           ` Tony Ambardar
2024-07-23  1:35             ` Tony Ambardar
2024-07-23  1:37               ` Eduard Zingerman
2024-07-23 20:28                 ` Andrii Nakryiko
2024-07-20  5:25         ` [PATCH bpf-next v2] " Tony Ambardar
2024-07-20  5:49           ` bot+bpf-ci
2024-07-22 15:17           ` bot+bpf-ci
2024-07-22 19:58           ` bot+bpf-ci
2024-07-23  1:40           ` bot+bpf-ci
2024-07-23  2:46           ` bot+bpf-ci
2024-07-23 20:30           ` patchwork-bot+netdevbpf
2024-07-19 18:20 ` [PATCH bpf-next v4] selftests/bpf: use auto-dependencies for test objects patchwork-bot+netdevbpf
2024-07-23  0:39   ` Alexei Starovoitov
2024-07-23  0:57     ` Eduard Zingerman
2024-07-23  1:49       ` Eduard Zingerman
2024-07-23  1:50       ` Ihor Solodrai
2024-07-23 19:25         ` Ihor Solodrai
2024-07-23 20:02           ` Andrii Nakryiko
2024-07-23 20:11             ` Ihor Solodrai
2024-09-13 14:51   ` Björn Töpel
2024-09-13 22:33     ` Ihor Solodrai
2024-09-14 10:54       ` Björn Töpel
2024-09-15  4:47         ` Ihor Solodrai
2024-09-15 15:41           ` Björn Töpel

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=Zprglznwj5h1/Wps@kodidev-ubuntu \
    --to=tony.ambardar@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=ihor.solodrai@pm.me \
    --cc=mykolal@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