From: sashiko-bot@kernel.org
To: "T S Rameshkumar" <rameshsv06@gmail.com>
Cc: linux-can@vger.kernel.org,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH v2 2/2] selftests: net: can: add vcan concurrent tx/stats test
Date: Thu, 03 Dec 2026 12:37:06 +0000 [thread overview]
Message-ID: <sashiko-outbox-247769@kernel.org> (raw)
In-Reply-To: <20261203120559.421646-2-rameshsv06@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] selftests: net: can: CAN_RAW SKIP() in test_vcan_stats.c
reported as PASS
- [Medium] selftests: net: can: raw RET=$rc in test_vcan_stats.sh masks
failures as PASS
- [Medium] selftests: net: can: barrier race in stats_reader() causes
zero reader_reads
--
commit f4c5f107871d0554eacce5fe33a073ddcc6bb5a8
Author: T S Rameshkumar <rameshkumar.t@phytecembedded.in>
selftests: net: can: add vcan concurrent tx/stats test
This commit adds a kselftest (test_vcan_stats) that creates a vcan0
interface in a network namespace, transmits CAN frames from concurrent
threads while reading /proc/net/dev in parallel, and verifies monotonic
reads and exact packet and byte counter deltas.
> diff --git a/tools/testing/selftests/net/can/test_vcan_stats.c b/tools/testing/selftests/net/can/test_vcan_stats.c
> new file mode 100644
> index 0000000000000..aca72cc0995fe
> --- /dev/null
> +++ b/tools/testing/selftests/net/can/test_vcan_stats.c
[ ... ]
> +static void *stats_reader(void *arg)
> +{
> + struct net_dev_stats prev = {}, st;
> + unsigned long reads = 0;
> +
> + pthread_barrier_wait(&start_barrier);
> +
> + while (!atomic_load(&stop_reader)) {
[Severity: Medium]
Can stats_reader() exit without performing any /proc/net/dev reads and
cause EXPECT_GT(atomic_load(&reader_reads), 0UL) to fail spuriously?
pthread_barrier_wait() only synchronizes arrival, not scheduling order.
On a busy host or single-vCPU VM, all tx_worker() threads can finish
their 1000 writes to vcan0 and be joined before stats_reader() runs
again:
stats_reader tx_worker / main
pthread_barrier_wait()
pthread_barrier_wait()
tx_worker() writes all frames and exits
main joins tx_worker threads
atomic_store(&stop_reader, 1)
while (!atomic_load(&stop_reader)) <-- exits with 0 reads
EXPECT_GT(reader_reads, 0UL) fails
Using a do { ... } while (!atomic_load(&stop_reader)) loop in
stats_reader() ensures at least one read completes.
[ ... ]
> +TEST(vcan_concurrent_tx_stats)
> +{
> + struct net_dev_stats before, after;
> + pthread_t tx[NUM_THREADS], reader;
> + unsigned long long exp_pkts, exp_bytes;
> + int probe_sock, ret;
> +
> + probe_sock = socket(PF_CAN, SOCK_RAW, CAN_RAW);
> + if (probe_sock < 0) {
> + if (errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT)
> + SKIP(return, "CAN_RAW protocol not supported");
[Severity: Medium]
Does SKIP() here cause test_vcan_stats.sh to report pass instead of skip
when CAN_RAW is unavailable?
In kselftest_harness.h, __test_passed() treats KSFT_SKIP as passed, so
test_harness_run() calls ksft_exit(ret == 0) and exits with 0 instead of
KSFT_SKIP (4). test_vcan_stats.sh checks for rc == ksft_skip, so when
CONFIG_CAN_VCAN is enabled without CONFIG_CAN_RAW it falls into the else
branch and exits 0.
Probing the CAN_RAW socket in main() before test_harness_run() and
exiting with ksft_exit_skip() would return KSFT_SKIP to the wrapper.
[ ... ]
> diff --git a/tools/testing/selftests/net/can/test_vcan_stats.sh b/tools/testing/selftests/net/can/test_vcan_stats.sh
> new file mode 100755
> index 0000000000000..2d182dd47b94f
> --- /dev/null
> +++ b/tools/testing/selftests/net/can/test_vcan_stats.sh
[ ... ]
> +test_vcan_stats()
> +{
> + local rc
> +
> + ip netns exec "$ns" ./test_vcan_stats
> + rc=$?
> + if ((rc == ksft_skip)); then
> + log_test_skip "test_vcan_stats"
> + else
> + RET=$rc
> + log_test "test_vcan_stats"
> + fi
> +}
[Severity: Medium]
Can assigning the raw exit status to RET mask failures as a pass in
EXIT_STATUS?
log_test() merges RET into EXIT_STATUS via ksft_exit_status_merge(),
which only assigns weights to ksft_xfail (2), ksft_pass (0),
ksft_skip (4), and ksft_fail (1):
tools/testing/selftests/net/lib.sh:__ksft_status_merge() {
...
if [[ ${weights[$a]} -ge ${weights[$b]} ]]; then
echo "$a"
return 0
...
}
If ./test_vcan_stats crashes or is missing (for example rc=127 or 139),
weights[$rc] is empty and evaluates to 0, which loses to weights[0]=1
and leaves EXIT_STATUS at 0. An rc of 2 is also treated as xfail and
leaves EXIT_STATUS at 0.
Normalizing non-zero rc to ksft_fail (or using check_err $rc with RET=0)
avoids masking these failures.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203120559.421646-1-rameshsv06@gmail.com?part=2
next prev parent reply other threads:[~2026-12-03 12:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 11:11 [PATCH 1/2] can: vcan: use per-CPU stats to fix KCSAN data-race in vcan_tx T S Rameshkumar
2026-12-03 11:11 ` [PATCH 2/2] selftests: net: can: add vcan concurrent tx/stats test T S Rameshkumar
2026-12-03 11:23 ` sashiko-bot
2026-12-03 11:23 ` [PATCH 1/2] can: vcan: use per-CPU stats to fix KCSAN data-race in vcan_tx sashiko-bot
2026-12-03 12:05 ` [PATCH v2 " T S Rameshkumar
2026-12-03 12:05 ` [PATCH v2 2/2] selftests: net: can: add vcan concurrent tx/stats test T S Rameshkumar
2026-12-03 12:37 ` sashiko-bot [this message]
2026-12-03 12:50 ` Oliver Hartkopp
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=sashiko-outbox-247769@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=rameshsv06@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=socketcan@hartkopp.net \
/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