From: netdev-bot+sashiko@kernel.org
To: rameshsv06@gmail.com
Cc: mkl@pengutronix.de, mailhol@kernel.org,
linux-can@vger.kernel.org, rameshkumar.t@phytecembedded.in,
kuba@kernel.org
Subject: Re: [PATCH v2 2/2] selftests: net: can: add vcan concurrent tx/stats test
Date: Sat, 05 Dec 2026 00:41:59 +0000 [thread overview]
Message-ID: <179643131951.3142.61176619347943128@kernel.org> (raw)
In-Reply-To: <20261203120559.421646-2-rameshsv06@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 3 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] When CAN_RAW is missing, the test is reported as PASS instead
of SKIP.
- [Medium] Nothing guarantees that the stats reader overlaps with the
transmitters, and the reader can finish with zero reads, which makes…
- [Medium] selftests: net: can: raw RET=$rc in test_vcan_stats.sh masks
failures as PASS
--
selftests: net: can: add vcan concurrent tx/stats test
This adds a kselftest that creates vcan0 in a separate network namespace.
It runs four PF_CAN raw transmitters while a second thread reads
/proc/net/dev, then checks that the counters only increase and that the
rx/tx packet and byte deltas match exactly. The test is meant to skip when
CAN_RAW or vcan is unavailable.
> 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
> @@ -0,0 +1,231 @@
[ ... ]
> +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]
The commit message says "Skip cleanly if CAN_RAW or vcan is unavailable".
Is the CAN_RAW case actually reported as a skip?
SKIP() only sets the per-test exit_code to KSFT_SKIP. test_harness_run()
then counts a skipped test as passed:
tools/testing/selftests/kselftest_harness.h:__test_passed() {
return metadata->exit_code != KSFT_FAIL &&
metadata->exit_code <= KSFT_SKIP;
}
and it finishes with:
ksft_exit(ret == 0);
That goes through ksft_exit_pass(), so the binary exits with KSFT_PASS (0)
and never with KSFT_SKIP (4).
If so, this branch in test_vcan_stats() in test_vcan_stats.sh is never
taken for the CAN_RAW case:
if ((rc == ksft_skip)); then
log_test_skip "test_vcan_stats"
else
RET=$rc
log_test "test_vcan_stats"
fi
With rc == 0, RET is set to 0 and log_test() reports PASS, even though no
frames were sent.
This case can happen in practice. net/can/config lists only CONFIG_CAN,
CONFIG_CAN_DEV and CONFIG_CAN_VCAN, and CONFIG_CAN_RAW is a separate
tristate. If CAN_RAW is disabled or the can-raw module isn't installed,
can_create() returns -EPROTONOSUPPORT. The wrapper still creates vcan0
without error in that case.
> + ASSERT_GE(probe_sock, 0)
> + TH_LOG("failed to create CAN_RAW socket: %d", errno);
> + }
> + close(probe_sock);
[ ... ]
> + for (int i = 0; i < NUM_THREADS; i++) {
> + void *res = NULL;
> +
> + pthread_join(tx[i], &res);
> + ASSERT_EQ((long)res, 0);
> + }
> +
> + atomic_store(&stop_reader, 1);
> + pthread_join(reader, NULL);
> + pthread_barrier_destroy(&start_barrier);
> +
> + ASSERT_EQ(atomic_load(&reader_err), 0);
> + EXPECT_GT(atomic_load(&reader_reads), 0UL);
[Severity: Medium]
Can this EXPECT_GT() fail spuriously if the reader thread never runs while
the frames are being sent?
stats_reader() tests the flag before its first read:
pthread_barrier_wait(&start_barrier);
while (!atomic_load(&stop_reader)) {
int ret = read_if_stats(canif, &st);
...
The barrier releases the four tx_worker() threads and the reader together,
but nothing orders them after that. Each tx_worker() does 1000 synchronous
write() calls on vcan. vcan_concurrent_tx_stats() sets stop_reader as soon
as it has joined the tx threads.
The reader may not get scheduled before that store, for example on a
single vCPU CI VM or under heavy load. Then the loop body never runs,
reader_reads stays 0, and this check fails.
A related point: even when the reader does run, nothing makes sure that any
read happens while transmits are still in progress. Could the check the
commit message describes as "checks that concurrent reads succeed
monotonically" pass when every read happened after TX had finished?
[ ... ]
> diff --git a/tools/testing/selftests/net/can/test_vcan_stats.sh b/tools/testing/selftests/net/can/test_vcan_stats.sh
> --- /dev/null
> +++ b/tools/testing/selftests/net/can/test_vcan_stats.sh
> @@ -0,0 +1,50 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +ALL_TESTS="
> + test_vcan_stats
> +"
> +
> +net_dir=$(dirname $0)/..
> +source $net_dir/lib.sh
> +
> +export CANIF=${CANIF:-"vcan0"}
> +
> +setup()
> +{
> + setup_ns ns || exit $ksft_skip
> + if ! ip -n "$ns" link add name "$CANIF" type vcan; then
> + echo "SKIP: vcan device creation not supported" >&2
> + exit $ksft_skip
> + fi
> + if ! ip -n "$ns" link set dev "$CANIF" up; then
> + echo "FAIL: failed to bring up $CANIF" >&2
> + exit $ksft_fail
> + fi
> +}
> +
> +cleanup()
> +{
> + cleanup_all_ns
> +}
> +
> +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
> +}
> +
> +trap cleanup EXIT
> +setup
> +
> +tests_run
> +
> +exit $EXIT_STATUS
[Severity: Medium]
Can this else branch hide a failing run?
RET is set to the raw exit status of ip netns exec and passed to
log_test() without being mapped to a ksft_* code. log_test() in
net/lib.sh prints FAIL for any value it does not recognise. It then
folds RET into EXIT_STATUS with ksft_exit_status_merge(), which goes
through __ksft_status_merge().
__ksft_status_merge() only has weights for ksft_xfail, ksft_pass,
ksft_skip and ksft_fail. Any other status gets an empty weight and
loses against the weight of ksft_pass, so EXIT_STATUS stays at 0. A
status of 2 is logged as XFAIL and also leaves EXIT_STATUS at 0.
So the script exits with KSFT_PASS whenever ip netns exec or the
binary returns something other than 0, 1 or 4. One example is 128
plus the signal number when test_vcan_stats is killed by a signal.
The runner then records a pass even though FAIL was printed.
test_raw_filter.sh in the same directory avoids this by passing the
status through check_err, which maps a non-zero status to ksft_fail.
Would it make sense to do the same here? That would mean setting
RET=0 at the start of test_vcan_stats(), since tests_run does not
reset it, then calling check_err on rc and keeping the explicit
ksft_skip case.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203120559.421646-1-rameshsv06%40gmail.com
next prev parent reply other threads:[~2026-12-05 0:42 UTC|newest]
Thread overview: 12+ 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-05 0:14 ` netdev-bot+sashiko
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
2026-12-03 12:50 ` Oliver Hartkopp
2026-12-05 0:41 ` netdev-bot+sashiko [this message]
2026-12-05 0:41 ` [PATCH v2 1/2] can: vcan: use per-CPU stats to fix KCSAN data-race in vcan_tx netdev-bot+sashiko
2026-12-05 0:14 ` [PATCH " netdev-bot+sashiko
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=179643131951.3142.61176619347943128@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=rameshkumar.t@phytecembedded.in \
--cc=rameshsv06@gmail.com \
/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