mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: jiayuan.chen@linux.dev,bpf@vger.kernel.org
Cc: jiayuan.chen@linux.dev,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev,shuah@kernel.org,yatsenko@meta.com,alan.maguire@oracle.com,linux-kernel@vger.kernel.org,linux-kselftest@vger.kernel.org,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf v3 4/5] selftests/bpf: Add test for key-less BTF hash map
Date: Mon, 31 Aug 2026 11:48:15 +0000 (UTC)	[thread overview]
Message-ID: <8b93223f148b0771b79336d636e7b6ddff030ffd2b3ffb264a51af6082149c01@mail.kernel.org> (raw)
In-Reply-To: <20260831110314.150870-5-jiayuan.chen@linux.dev>

[-- Attachment #1: Type: text/plain, Size: 2419 bytes --]

> diff --git a/tools/testing/selftests/bpf/prog_tests/btf_map_keyless.c b/tools/testing/selftests/bpf/prog_tests/btf_map_keyless.c
> new file mode 100644
> index 0000000000000..a7d037f57a7ef
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/btf_map_keyless.c
> @@ -0,0 +1,82 @@

[ ... ]

> +	/*
> +	 * Positive control: the same map with a real key type must be accepted,
> +	 * so the -EINVAL below is about the key-less BTF and not some unrelated
> +	 * rejection (e.g. an unknown map type).
> +	 */
> +	opts.btf_key_type_id = val_id;
> +	map_fd = bpf_map_create(map_type, "keyed_map", 4, 4, 8, &opts);
> +	if (!ASSERT_GE(map_fd, 0, "keyed create is accepted"))
> +		return;
> +	close(map_fd);

A subsystem pattern flags this as potentially concerning: the positive
control turns "this kernel does not implement the map type" into a hard test
failure instead of a skip.

BPF_MAP_TYPE_RHASH (used by the rhash subtest) is new; on any kernel that
lacks it, map_create() rejects the unknown map type and this ASSERT_GE fails,
reporting a red btf_map_keyless/rhash that has nothing to do with the
behaviour under test.

libbpf already provides the probe for this: libbpf_probe_bpf_map_type()
handles BPF_MAP_TYPE_RHASH explicitly (tools/lib/bpf/libbpf_probes.c:312,
including the BPF_F_NO_PREALLOC requirement), so the subtest could probe
and test__skip() with a reason instead.

Two arguments in the patch's favour: (a) an unknown map type is rejected with
-EINVAL, not EOPNOTSUPP/ENOSYS, so the errno match isn't literal; (b) the
comment on lines 26-30 shows the failure is deliberate - the author wants an
unrelated rejection to surface as a failed positive control rather than be
silently swallowed by the -EINVAL assertion below.

Both arguments are about the choice of signal, not about whether an absent map
type is a capability-absent condition, which it is. Does the current approach
fit the test's intent better than probing and skipping?

[ ... ]

> +	if (test__start_subtest("hash"))
> +		check_keyless(BPF_MAP_TYPE_HASH, 0, btf_fd, val_id);
> +	if (test__start_subtest("rhash"))
> +		check_keyless(BPF_MAP_TYPE_RHASH, BPF_F_NO_PREALLOC, btf_fd, val_id);


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/33385673160

  reply	other threads:[~2026-08-31 11:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 11:01 [PATCH bpf v3 0/5] bpf: Fix NULL-ptr-derefs when showing a void BTF type Jiayuan Chen
2026-08-31 11:01 ` [PATCH bpf v3 1/5] bpf: Reject key-less BTF for hash maps Jiayuan Chen
2026-08-31 12:05   ` bot+bpf-ci
2026-08-31 12:27     ` Jiayuan Chen
2026-08-31 21:01   ` Ihor Solodrai
2026-08-31 11:01 ` [PATCH bpf v3 2/5] bpf: Fix NULL-ptr-deref when showing a void BTF type Jiayuan Chen
2026-08-31 11:48   ` bot+bpf-ci
2026-08-31 12:48     ` Jiayuan Chen
2026-08-31 21:06   ` Ihor Solodrai
2026-08-31 11:01 ` [PATCH bpf v3 3/5] bpf: Fix NULL-ptr-deref in btf_var_show() Jiayuan Chen
2026-08-31 21:08   ` Ihor Solodrai
2026-08-31 11:01 ` [PATCH bpf v3 4/5] selftests/bpf: Add test for key-less BTF hash map Jiayuan Chen
2026-08-31 11:48   ` bot+bpf-ci [this message]
2026-08-31 12:54     ` Jiayuan Chen
2026-08-31 21:12   ` Ihor Solodrai
2026-08-31 11:01 ` [PATCH bpf v3 5/5] selftests/bpf: Add test for showing a void BTF type Jiayuan Chen

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=8b93223f148b0771b79336d636e7b6ddff030ffd2b3ffb264a51af6082149c01@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jiayuan.chen@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mason@kernel.org \
    --cc=memxor@gmail.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yatsenko@meta.com \
    --cc=yonghong.song@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

all inboxes | Powered by JetHome®