From: sashiko-bot@kernel.org
To: "Puranjay Mohan" <puranjay@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v13 5/6] selftests/bpf: add usage example for cpu time counter kfuncs
Date: Sat, 18 Apr 2026 15:17:46 +0000 [thread overview]
Message-ID: <20260418151746.B44BFC19424@smtp.kernel.org> (raw)
In-Reply-To: <20260418131614.1501848-6-puranjay@kernel.org>
Sashiko AI review found 1 potential issue(s):
- [Medium] Incorrect and redundant file descriptor validation in BPF skeleton test.
--
commit 0a7806f6db918db501677b21fa0e15ae508d1ada
Author: Vadim Fedorenko <vadim.fedorenko@linux.dev>
selftests/bpf: add usage example for cpu time counter kfuncs
This commit adds a selftest example demonstrating how to measure the
latency of BPF kfuncs or helpers using the time stamp counter and how
to convert the measured values into nanoseconds.
> diff --git a/tools/testing/selftests/bpf/prog_tests/test_cpu_cycles.c b/tools/testing/selftests/bpf/prog_tests/test_cpu_cycles.c
> new file mode 100644
> index 0000000000000..067307f0c4c29
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/test_cpu_cycles.c
[ ... ]
> +static void cpu_cycles(void)
> +{
> + LIBBPF_OPTS(bpf_test_run_opts, opts);
> + struct test_cpu_cycles *skel;
> + int err, pfd;
> +
> + skel = test_cpu_cycles__open_and_load();
> + if (!ASSERT_OK_PTR(skel, "test_cpu_cycles open and load"))
> + return;
> +
> + pfd = bpf_program__fd(skel->progs.bpf_cpu_cycles);
> + if (!ASSERT_GT(pfd, 0, "test_cpu_cycles fd"))
> + goto fail;
Is it necessary to validate the file descriptor here? The BPF skeleton API
guarantees that after a successful open_and_load(), all programs and maps
are created with valid file descriptors, making this validation redundant.
Additionally, if a file descriptor check were needed, shouldn't it use
ASSERT_GE rather than ASSERT_GT? 0 is technically a valid file descriptor,
so if pfd evaluated to 0, this test would falsely fail.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260418131614.1501848-1-puranjay@kernel.org?part=5
next prev parent reply other threads:[~2026-04-18 15:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-18 13:15 [PATCH bpf-next v13 0/6] bpf: add cpu time counter kfuncs Puranjay Mohan
2026-04-18 13:15 ` [PATCH bpf-next v13 1/6] bpf: adjust BPF JIT dependency to BPF_SYSCALL Puranjay Mohan
2026-04-18 13:46 ` sashiko-bot
2026-04-18 13:16 ` [PATCH bpf-next v13 2/6] bpf: add bpf_get_cpu_time_counter kfunc Puranjay Mohan
2026-04-18 14:24 ` sashiko-bot
2026-04-18 13:16 ` [PATCH bpf-next v13 3/6] bpf: add bpf_cpu_time_counter_to_ns kfunc Puranjay Mohan
2026-04-18 14:03 ` bot+bpf-ci
2026-04-18 14:54 ` sashiko-bot
2026-04-18 13:16 ` [PATCH bpf-next v13 4/6] selftests/bpf: add selftest to check bpf_get_cpu_time_counter jit Puranjay Mohan
2026-04-18 15:08 ` sashiko-bot
2026-04-18 13:16 ` [PATCH bpf-next v13 5/6] selftests/bpf: add usage example for cpu time counter kfuncs Puranjay Mohan
2026-04-18 15:17 ` sashiko-bot [this message]
2026-04-18 13:16 ` [PATCH bpf-next v13 6/6] bpf, arm64: Add JIT support " Puranjay Mohan
2026-04-18 14:03 ` bot+bpf-ci
2026-04-18 16:06 ` sashiko-bot
2026-04-20 4:03 ` Xu Kuohai
2026-04-20 9:45 ` Puranjay Mohan
2026-04-20 10:16 ` Will Deacon
2026-04-20 10:44 ` Marc Zyngier
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=20260418151746.B44BFC19424@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=puranjay@kernel.org \
--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