From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796431320; b=XdlnstpthGyjSWTClsiQ9T2wCyp4EPxfWCYmT+TSLNgIn8lwax+ugDJSgr0dQY8WvD5o RhCiycaeYQ9lNiAE14BFjWgyI0wyja5ELnI7Ns/SEAzF7HIYKk9i+Z+VpHb5RqTRphLu5 7tUILGwTwXF2oOeSiV+bpz6SzWs+6v67BNejbvc47NAqC95ZwmdHvWhabalwQAVs28IZi rp3YP4salUudiOUUWH2eoA9ZAnTzAmn+mBnpnj/oCdPs2wNemBnlRnm7lFLbPurgJ3JFa zbNBJi1GeRLCnLe0tqAagoHI9O5Nid96QMNtl5K8fCcg59LUC7E8cSWJZzSfkj71AIA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796431320; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=UyXkB9D/fZacZgb9CtKUebyYmV6TTy1jEL5Io3fKASA=; b=MIEVpRduzGY3JmFiCONumtnH1coGwxxvznhoLQjf3NC6zWxDbZuuoA4peZ+r16q8cpgX yw9VtGKHzSAvqOR8fZxnOd3DZ0Z+ZSNZY+PgrkNFTt4FB7aDKaTMC4Ea3MNMB85Xk1k2F ypWacUElaJoYJc9d3x+52uPnj990l0kI768t++4XOs3L6h5nP6dWrpkIH9FcxyMGj6ovl tlEWIsALloPWeMOodMfk065qFAXyDizjOEBoL9dH7w6DGrh9pWBFNQ9AEpGvX+a2HHa+B UmqdBBMeWcYaipEQ3J+QAuWn1xkDwDbTR9ztFjBeNj3mSOQeBe3RqLewtoyucLPTuIg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SOhHQKm9; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C801B606A33A for ; Sat, 5 Dec 2026 00:42:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SOhHQKm9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E58D51F00936; Sat, 5 Dec 2026 00:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796431320; bh=UyXkB9D/fZacZgb9CtKUebyYmV6TTy1jEL5Io3fKASA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=SOhHQKm9l+eQVZAfgL81HhcBS1ydCsCJ1PMPNkjJURO81x2l5DJG0+vuRs4bhR6UQ zX7GfPrwdupXh0m4UzJwmXfT+rg2bcsPawHjk9y8zFoaF6ODUvvh15NOxrHA4SPuov XTfiO+S/9ZDuaEJHjk4ckpvsCpZ04c94uWXHwMp1eqZTMixYMqP21lmyykC0FbQLzT 4DlS6tqAPuop0qYnJ4Avj5B4kA/U31olZwQ0G7Z/hTAAV1Dy0POU3pnmLGeiFkzB0e dgYdoOO3N0OyW9ypRMV1DQW1WeZR0A4e00ArE5EdMtI4Cp7e3sCan0L1L6H2uqav0o LP2dme69OnUdg== Subject: Re: [PATCH v2 2/2] selftests: net: can: add vcan concurrent tx/stats test 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 Date: Sat, 05 Dec 2026 00:41:59 +0000 Message-ID: <179643131951.3142.61176619347943128@kernel.org> In-Reply-To: <20261203120559.421646-2-rameshsv06@gmail.com> References: <20261203120559.421646-2-rameshsv06@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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