All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mykola Lysenko" <nickolay.lysenko@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [RFC PATCH bpf-next 3/3] selftests/bpf: build each test runner instance in its own sub-make
Date: Tue, 21 Jul 2026 17:58:57 +0000	[thread overview]
Message-ID: <20260721175857.DCF371F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260721174909.8044-4-nickolay.lysenko@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Parallel build race on shared helper objects (`testing_helpers.o`, `cgroup_helpers.o`) due to overlapping rules between the parent Makefile and `Makefile.runner` sub-makes.
--

--- Patch [3]: [RFC PATCH bpf-next 3/3] selftests/bpf: build each test runner instance in its own sub-make ---
commit e06c43ef78e32188e09532ae20788ac48fd20702
Author: Mykola Lysenko <nickolay.lysenko@gmail.com>
selftests/bpf: build each test runner instance in its own sub-make

This patch refactors the BPF selftests build system by moving the
double-expansion DEFINE_TEST_RUNNER logic into independent sub-makes via a
new Makefile.runner. Shared configurations and prebuilt toolchain elements
are kept in the top-level Makefile.

> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index f5c0f81f61db7..a3ab525f7dfab 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile

[ ... ]

> +HELPER_OBJS := $(addprefix $(OUTPUT)/,testing_helpers.o cgroup_helpers.o \
> +	       trace_helpers.o network_helpers.o json_writer.o		\
> +	       cap_helpers.o unpriv_helpers.o usdt_1.o usdt_2.o xsk.o)
> +
> +# $(BPFTOOL) is a prerequisite because its sub-make is what installs
> +# libbpf's internal headers (bpf/hashmap.h, bpf/libbpf_internal.h) into
> +# $(INCLUDE_DIR); without it, helpers including those headers race the
> +# install and can silently pick up the source-tree copies instead.
> +$(HELPER_OBJS): flow_dissector_load.h ip_check_defrag_frags.h		\
> +		$(VERIFY_SIG_HDR) prog_tests/tests.h $(BPFOBJ) $(BPFTOOL)

[ ... ]

> diff --git a/tools/testing/selftests/bpf/Makefile.runner b/tools/testing/selftests/bpf/Makefile.runner
> new file mode 100644
> index 0000000000000..4c58cc51f2514
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/Makefile.runner

[ ... ]

> +ifeq ($(RUNNER),test_progs)
> +EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c		\
> +		 network_helpers.c testing_helpers.c btf_helpers.c	\
> +		 cap_helpers.c unpriv_helpers.c sysctl_helpers.c	\
> +		 netlink_helpers.c jit_disasm_helpers.c io_helpers.c	\
> +		 test_loader.c xsk.c disasm.c disasm_helpers.c		\
> +		 json_writer.c bpftool_helpers.c usdt_1.c usdt_2.c

[ ... ]

> +EXTRA_OBJS := $(patsubst %.c,$(RDIR)/%.o,$(filter %.c,$(EXTRA_SOURCES)))
> +LIB_OBJS   := $(patsubst %.c,$(RDIR)/%.o,$(LIB_SOURCES))

[ ... ]

> +$(EXTRA_OBJS): $(RDIR)/%.o: %.c $(EXTRA_HDRS) $(TESTS_HDR) $(BPFOBJ) | $(RDIR)

[Severity: Medium]
Could this cause a parallel build race on the shared helper objects?

The top-level Makefile builds shared helpers like testing_helpers.o and
cgroup_helpers.o with a limited set of dependencies (shown above). However,
this EXTRA_OBJS rule inside the sub-makes encompasses those same helpers and
declares broader dependencies, such as $(LIBARENA_SKEL) for test_progs and
map_tests/tests.h for test_maps.

Because these broader dependencies are built in parallel by the top-level
make, they can end up with newer timestamps than the pre-built helpers. If
that happens, both the test_progs and test_maps sub-makes might evaluate
the helpers as out-of-date and concurrently recompile them.

Can this lead to intermittent "file truncated" or "file format not recognized"
link errors when building with -j?

> +	$(call msg,EXT-OBJ,$(BINARY),$@)
> +	$(Q)$(CC) $(CFLAGS) -c $< -o $@

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260721174909.8044-1-nickolay.lysenko@gmail.com?part=3

  reply	other threads:[~2026-07-21 17:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21 17:49 [RFC PATCH bpf-next 0/3] selftests/bpf: restructure the Makefile as a layered build Mykola Lysenko
2026-07-21 17:49 ` [RFC PATCH bpf-next 1/3] selftests/bpf: extract BPF skeleton generation into a helper script Mykola Lysenko
2026-07-21 17:57   ` sashiko-bot
2026-07-21 19:43     ` Mykola Lysenko
2026-07-21 17:49 ` [RFC PATCH bpf-next 2/3] selftests/bpf: move shared build definitions into Makefile.buildvars Mykola Lysenko
2026-07-21 17:49 ` [RFC PATCH bpf-next 3/3] selftests/bpf: build each test runner instance in its own sub-make Mykola Lysenko
2026-07-21 17:58   ` sashiko-bot [this message]
2026-07-21 19:43     ` Mykola Lysenko

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=20260721175857.DCF371F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=nickolay.lysenko@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.