From: Leon Hwang <leon.hwang@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v7 08/11] selftests/bpf: Add tests to verify global percpu data
Date: Tue, 23 Jun 2026 12:04:07 +0800 [thread overview]
Message-ID: <6c0bc7ef-90b9-450d-969d-b7e0bc5932f8@linux.dev> (raw)
In-Reply-To: <20260622145733.A049A1F000E9@smtp.kernel.org>
On 22/6/26 22:57, sashiko-bot@kernel.org wrote:
[...]
>> diff --git a/tools/testing/selftests/bpf/prog_tests/global_percpu_subskel.c b/tools/testing/selftests/bpf/prog_tests/global_percpu_subskel.c
>> new file mode 100644
>> index 0000000000000..8aebd533d86b5
>> --- /dev/null
>> +++ b/tools/testing/selftests/bpf/prog_tests/global_percpu_subskel.c
> [ ... ]
>> +void test_global_percpu_data_subskel(void)
>> +{
>> + struct test_global_percpu_data *subskel = NULL;
>> + struct bpf_object *obj;
>> + int i;
> [ ... ]
>> + if (!ASSERT_OK_PTR(subskel->subskel, "subskel"))
>> + goto out;
>> + if (!ASSERT_OK_PTR(subskel->maps.percpu, "maps.percpu"))
>> + goto out;
>> + ASSERT_EQ(bpf_map__type(subskel->maps.percpu), BPF_MAP_TYPE_PERCPU_ARRAY,
>> + "percpu_map_type");
>> + ASSERT_GT(subskel->subskel->var_cnt, 0, "var_cnt");
>
> [Severity: Medium]
> Will this assertion cause the test to unconditionally fail?
>
Luckily, no.
> Looking at test_global_percpu_data.c, all defined variables are placed
> in the .percpu section. Since bpftool explicitly skips .percpu maps when
> generating subskeletons, there appear to be no non-percpu maps with BTF
> variables present.
>
> If that is the case, subskel->subskel->var_cnt will be exactly 0, causing
> this check to evaluate to ASSERT_GT(0, 0) and reliably fail the test.
>
Looking at test_global_percpu_data.c, there are 5 non-percpu global
variables, which were added in patch #11.
volatile const __u32 num_cpus = 0;
volatile const int offsetof_num;
volatile const int elem_sz;
__u32 percpu_data_sum = 0;
bool run_iter = false;
So, subskel->subskel->var_cnt will be 5.
In the generated test_global_percpu_data.subskel.h:
/* vars */
s->var_cnt = 5;
Thanks,
Leon
>> +
>> + for (i = 0; i < subskel->subskel->var_cnt; i++) {
>> + const struct bpf_var_skeleton *var;
> [ ... ]
>
next prev parent reply other threads:[~2026-06-23 4:04 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 14:35 [PATCH bpf-next v7 00/11] bpf: Introduce global percpu data Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 01/11] bpf: Drop duplicate blank lines in verifier Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 02/11] bpf: Disallow interpreter fallback for user BPF_ADDR_SPACE_CAST insn Leon Hwang
2026-06-22 15:07 ` sashiko-bot
2026-06-23 4:00 ` Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 03/11] bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 04/11] bpf: Introduce global percpu data Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 05/11] libbpf: Probe percpu data feature Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 06/11] libbpf: Add support for global percpu data Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 07/11] bpftool: Generate skeleton " Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 08/11] selftests/bpf: Add tests to verify " Leon Hwang
2026-06-22 14:57 ` sashiko-bot
2026-06-23 4:04 ` Leon Hwang [this message]
2026-06-22 15:24 ` bot+bpf-ci
2026-06-23 4:02 ` Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 09/11] selftests/bpf: Add test to verify accessing rdonly percpu_array Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 10/11] selftests/bpf: Add tests to verify verifier log for global percpu data Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 11/11] selftests/bpf: Add test to verify bpf_iter " Leon Hwang
2026-06-22 15:08 ` sashiko-bot
2026-06-23 4:05 ` Leon Hwang
2026-06-22 15:24 ` bot+bpf-ci
2026-06-23 4:04 ` Leon Hwang
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=6c0bc7ef-90b9-450d-969d-b7e0bc5932f8@linux.dev \
--to=leon.hwang@linux.dev \
--cc=bpf@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox