public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ricardo B. Marlière" <rbm@suse.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 03/11] selftests/bpf: Tolerate BPF and skeleton generation failures
Date: Wed, 15 Apr 2026 21:15:32 +0000	[thread overview]
Message-ID: <20260415211532.A56BEC19424@smtp.kernel.org> (raw)
In-Reply-To: <20260415-selftests-bpf_misconfig-v5-3-03d0a52a898a@suse.com>

Sashiko AI review found 2 potential issue(s):
- [High] Silent masking of skeleton generation failures when PERMISSIVE is disabled (strict mode).
- [High] Stale skeleton artifacts are left on disk on incremental builds when prerequisite BPF objects fail to compile.
--

commit 3cf9cc67632ce30dc796d085a5a01c842575cf10
Author: Ricardo B. Marlière <rbm@suse.com>

selftests/bpf: Tolerate BPF and skeleton generation failures

Some BPF programs cannot be built on distro kernels because required BTF
types or features are missing. Make BPF object and skeleton generation best
effort: emit SKIP-BPF or SKIP-SKEL, remove failed outputs so downstream rules
can detect absence, and continue with remaining tests.

> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 5c4cdf1dafc8b..a305d13409e4b 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
[ ... ]
> @@ -598,47 +602,77 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o:				\
>  					  $$($$<-$2-CFLAGS),$(TRUNNER_BINARY))
>  
>  $(TRUNNER_BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
> -	$$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
> -	$(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 $$(<:.o=.linked3.o) name $$(notdir $$(<:.bpf.o=)) > $$@
> -	$(Q)$$(BPFTOOL) gen subskeleton $$(<:.o=.linked3.o) name $$(notdir $$(<:.bpf.o=)) > $$(@:.skel.h=.subskel.h)
> -	$(Q)rm -f $$(<:.o=.linked1.o) $$(<:.o=.linked2.o) $$(<:.o=.linked3.o)
> +	$(Q)$(if $(PERMISSIVE),if [ ! -f $$< ]; then			\
> +		printf '  %-12s %s\n' 'SKIP-SKEL' '$$(notdir $$@)' 1>&2; \
> +		exit 0;							\
> +	fi;)								\

If $$< is missing during an incremental build because a previous permissive run
failed to compile it, does exiting 0 here leave a stale .skel.h on disk?

Since $@ is not removed before exiting, it appears downstream targets might
incorrectly compile against the stale skeleton instead of failing or skipping.

> +	printf '  %-12s %s\n' 'GEN-SKEL' '[$(TRUNNER_BINARY)] $$(notdir $$@)' 1>&2; \
> +	$$(BPFTOOL) gen object $$(<:.o=.linked1.o) $$< &&		\
> +	$$(BPFTOOL) gen object $$(<:.o=.linked2.o) $$(<:.o=.linked1.o) && \
> +	$$(BPFTOOL) gen object $$(<:.o=.linked3.o) $$(<:.o=.linked2.o) && \
> +	diff $$(<:.o=.linked2.o) $$(<:.o=.linked3.o) &&		\
> +	$$(BPFTOOL) gen skeleton $$(<:.o=.linked3.o) name $$(notdir $$(<:.bpf.o=)) > $$@ && \
> +	$$(BPFTOOL) gen subskeleton $$(<:.o=.linked3.o) name $$(notdir $$(<:.bpf.o=)) > $$(@:.skel.h=.subskel.h) $(if $(PERMISSIVE),|| { \
> +		$$(RM) $$@ $$(@:.skel.h=.subskel.h); \
> +		printf '  %-12s %s\n' 'SKIP-SKEL' '$$(notdir $$@)' 1>&2; \
> +	}); \
> +	rm -f $$(<:.o=.linked1.o) $$(<:.o=.linked2.o) $$(<:.o=.linked3.o)

When PERMISSIVE is disabled, does the generated shell command chain hide
generation failures?

Because the $(if) block evaluates to nothing in strict mode, the generated
command ends with a semicolon:

> > $$(@:.skel.h=.subskel.h) ; \
> rm -f ...

If bpftool or diff fails earlier in the && chain, the shell will skip to the
semicolon and execute rm -f. Since rm -f always succeeds, it will return exit
code 0, which seems like it would cause make to silently ignore actual
compilation regressions in strict mode.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260415-selftests-bpf_misconfig-v5-0-03d0a52a898a@suse.com?part=3

  reply	other threads:[~2026-04-15 21:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-15 20:59 [PATCH bpf-next v5 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
2026-04-15 20:59 ` [PATCH bpf-next v5 01/11] selftests/bpf: Add BPF_STRICT_BUILD toggle Ricardo B. Marlière
2026-04-15 20:59 ` [PATCH bpf-next v5 02/11] selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels Ricardo B. Marlière
2026-04-15 21:18   ` sashiko-bot
2026-04-15 21:43   ` bot+bpf-ci
2026-04-15 20:59 ` [PATCH bpf-next v5 03/11] selftests/bpf: Tolerate BPF and skeleton generation failures Ricardo B. Marlière
2026-04-15 21:15   ` sashiko-bot [this message]
2026-04-15 21:43   ` bot+bpf-ci
2026-04-15 20:59 ` [PATCH bpf-next v5 04/11] selftests/bpf: Avoid rebuilds when running emit_tests Ricardo B. Marlière
2026-04-15 20:59 ` [PATCH bpf-next v5 05/11] selftests/bpf: Make skeleton headers order-only prerequisites of .test.d Ricardo B. Marlière
2026-04-15 20:59 ` [PATCH bpf-next v5 06/11] selftests/bpf: Tolerate test file compilation failures Ricardo B. Marlière
2026-04-15 20:59 ` [PATCH bpf-next v5 07/11] selftests/bpf: Allow test_progs to link with a partial object set Ricardo B. Marlière
2026-04-15 21:19   ` sashiko-bot
2026-04-15 21:54   ` bot+bpf-ci
2026-04-15 20:59 ` [PATCH bpf-next v5 08/11] selftests/bpf: Tolerate benchmark build failures Ricardo B. Marlière
2026-04-15 20:59 ` [PATCH bpf-next v5 09/11] selftests/bpf: Provide weak definitions for cross-test functions Ricardo B. Marlière
2026-04-15 20:59 ` [PATCH bpf-next v5 10/11] selftests/bpf: Skip tests whose objects were not built Ricardo B. Marlière
2026-04-15 21:11   ` sashiko-bot
2026-04-15 21:43   ` bot+bpf-ci
2026-04-15 20:59 ` [PATCH bpf-next v5 11/11] selftests/bpf: Tolerate missing files during install Ricardo B. Marlière

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=20260415211532.A56BEC19424@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=rbm@suse.com \
    --cc=sashiko@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox