selftests/bpf: Support building selftests in optimized -O2 mode
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 6 Oct 2023 17:57:43 +0000 (10:57 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 6 Oct 2023 18:17:28 +0000 (20:17 +0200)
commit46475cc0dded2cd832a906fae4f91fd0ab73904b
tree3c53e701262cd73678836024cb07ac034799faa5
parent925a01577ea5a70416731c00e42b74c97f41cb6a
selftests/bpf: Support building selftests in optimized -O2 mode

Add support for building selftests with -O2 level of optimization, which
allows more compiler warnings detection (like lots of potentially
uninitialized usage), but also is useful to have a faster-running test
for some CPU-intensive tests.

One can build optimized versions of libbpf and selftests by running:

  $ make RELEASE=1

There is a measurable speed up of about 10 seconds for me locally,
though it's mostly capped by non-parallelized serial tests. User CPU
time goes down by total 40 seconds, from 1m10s to 0m28s.

Unoptimized build (-O0)
=======================
Summary: 430/3544 PASSED, 25 SKIPPED, 4 FAILED

real    1m59.937s
user    1m10.877s
sys     3m14.880s

Optimized build (-O2)
=====================
Summary: 425/3543 PASSED, 25 SKIPPED, 9 FAILED

real    1m50.540s
user    0m28.406s
sys     3m13.198s

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20231006175744.3136675-2-andrii@kernel.org
tools/testing/selftests/bpf/Makefile