BPF List
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v9 6/9] selftests/bpf: Add tests to verify global percpu data
Date: Tue, 14 Jul 2026 09:51:33 +0800	[thread overview]
Message-ID: <7db42bd1-7b00-4448-8c7e-0ca118758e28@linux.dev> (raw)
In-Reply-To: <20260713171334.6A5A71F000E9@smtp.kernel.org>

On 14/7/26 01:13, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The test `test_global_percpu_data_subskel` unconditionally asserts that `var_cnt > 0`, but the compiled BPF object contains no non-percpu global variables, meaning `var_cnt` will always be exactly 0 and the test will reliably fail.
> --
> 
> --- Patch [6]: [PATCH bpf-next v9 6/9] selftests/bpf: Add tests to verify global percpu data ---
> commit 3e1db5f1fcec57a130c30e415035e1b1944b5e17
> Author: Leon Hwang <leon.hwang@linux.dev>
> 
> selftests/bpf: Add tests to verify global percpu data
> 
> This commit introduces tests for BPF global percpu data, verifying APIs like
> bpf_map__set_initial_value() and bpf_map__initial_value(). It also adds a
> subskeleton test to ensure that the live variables of a subskeleton do not
> include those for global percpu data.
> 
>> 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
> [ ... ]
>> +	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 test unconditionally fail here?
> 
> Since all global variables in test_global_percpu_data.c are placed in .percpu
> sections:
> 
> int unused SEC(".percpu.looooooooong");
> int data2 SEC(".percpu.data");
> int data SEC(".percpu") = -1;
> 
> bpftool generates a subskeleton with a variable count of 0, because maps of type
> BPF_MAP_TYPE_PERCPU_ARRAY are skipped during subskeleton generation.
> 
> Thus, subskel->subskel->var_cnt should be exactly 0, which would cause this
> assertion to fail.
> 

Cite my reply in v7 [1]:

Looking at test_global_percpu_data.c, there are 5 non-percpu global
variables, which were added in the last patch.

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;

hmm, if the next revision is needed, will add a global data variable to
mute this Sashiko review.

[1]
https://lore.kernel.org/bpf/6c0bc7ef-90b9-450d-969d-b7e0bc5932f8@linux.dev/

Thanks,
Leon


  reply	other threads:[~2026-07-14  1:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 15:40 [PATCH bpf-next v9 0/9] bpf: Introduce global percpu data Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 1/9] bpf: Drop duplicate blank lines in verifier Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 2/9] bpf: Introduce global percpu data Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 3/9] libbpf: Probe percpu data feature Leon Hwang
2026-07-13 16:17   ` sashiko-bot
2026-07-14  1:42     ` Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 4/9] libbpf: Add support for global percpu data Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 5/9] bpftool: Generate skeleton " Leon Hwang
2026-07-13 16:48   ` sashiko-bot
2026-07-14  5:45     ` Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 6/9] selftests/bpf: Add tests to verify " Leon Hwang
2026-07-13 17:13   ` sashiko-bot
2026-07-14  1:51     ` Leon Hwang [this message]
2026-07-13 15:40 ` [PATCH bpf-next v9 7/9] selftests/bpf: Test direct reading/writing read-only percpu_array map Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 8/9] selftests/bpf: Test verifier log for global percpu data Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 9/9] selftests/bpf: Verify bpf_iter " 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=7db42bd1-7b00-4448-8c7e-0ca118758e28@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