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=1796429681; b=vNltznAgNXbCz4PW9gG6e4Hb9MA6/caz6DoBRyuVjLC1hsMhCi8EOYPlQN0iLVlPMXC+ 2Vd7WO2MWHqGyxALvbIKfqciztLgXtMP6lChqsepoqAOblJRirWYrpHWe78hhIB3WR1p0 kwWyegai02DzmR6+wwCV9DGzXULUo8FQKhld8CLqnx0CvJpjBI7mPhAhl/KdkJfIK/dF5 2EKX/W3eklyEPvwJf1SY1L2hEwOxMBTeM2dcw22lqUEsskk8zQiHL09USb6OGDkX91tB/ 7QYRkUUEzu0d+etIlyy3dj0/Oa4xpjpU7rzEug99SfzJfUEllNfYd6SE7KJmB4aSWUg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796429681; 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=pXoVRHnYhRTXXPles3/sYa7B1BUt2m+6AD+I3i/ld6U=; b=wRO6bRRGh3wKRJUHWiUKr2zDxtPYdq2HbULIRSc67DVYvhFcfR61JZZnwqcNCl4grYOO iRG50Brlk18ts4tUAoSbIXHSPW9qQHBaGyIoA51GqzxepGd8EXk0hNjX8mEYpcsHH3VkA eV73FlvBfNOF4XGhrHdkCFw+FPDYLPEcYY/6cuHnGFA1wogffNJ1QRe/i2bDcNzmV+RWB Kx8bn0QQy5+p4Kw3NMn6BScoMOs0/wavQsXpA4wvKYKPQA5LJsNb9p5NREftmRB/2tINs 87NjUWyzLMRxFKXjAcLNq+XDRp4/G6c70bPogjwK103nLOMFyCehPrKp9Vf1k0oVtGQ== 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=mU9RUCzQ; 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 4A5AD606A322 for ; Sat, 5 Dec 2026 00:14:41 +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=mU9RUCzQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE1BD1F0092B; Sat, 5 Dec 2026 00:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796429681; bh=pXoVRHnYhRTXXPles3/sYa7B1BUt2m+6AD+I3i/ld6U=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=mU9RUCzQW3GNivM1vEOL9H+JSnuT5Wpv09LE3nTl9ytekxDBEbck+OEyVQ4J8R6it N9madVCpzbV74MCbdyH2SGHBvU3MEl1XdaTyDwmVKPuxUbCFDg93dZOJX5/LX/Fqso J/nER3SuA+OlXVb0jdE/dYo4vIl44jTZ+rLepdkwV0j9ke3fBzRPAVYZVdDK8xumqW mSUx5pMYNBsZQrOObYah6uzPwBCh+gDhMwniQyZWso7injWh6FnnH6Ex8D90QZaNjh i3h7AieKquD8xN5ZyGfmxHNPih2xMrS+MyJal5c9cos9OXosFjXC0Z0zprHdk2YTLy OzGwO1a7hubHg== Subject: Re: [PATCH 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:14:40 +0000 Message-ID: <179642968042.3142.2861763799301446361@kernel.org> In-Reply-To: <20261203111103.379929-2-rameshsv06@gmail.com> References: <20261203111103.379929-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: 2 · Low: 1 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] test_vcan_stats passes the same way on kernels with and without the companion fix "can: vcan: use per-CPU stats to fix KCSAN… - [Medium] test_vcan_stats.sh sets `trap cleanup EXIT` (line 32) before it calls `setup` (line 33). - [Low] The new test_vcan_stats.sh runs `source $net_dir/lib.sh` (line 9, i.e. tools/testing/selftests/net/lib.sh), and net/lib.sh in turn… -- selftests: net: can: add vcan concurrent tx/stats test This adds a kselftest, test_vcan_stats. It starts four concurrent PF_CAN raw transmitters on vcan0 while another thread reads /proc/net/dev. It then checks the exact rx/tx packet and byte counter deltas. A wrapper script creates the vcan interface and deletes it afterwards. > diff --git a/tools/testing/selftests/net/can/Makefile b/tools/testing/selftests/net/can/Makefile > index 5b82e60a03e75..c2e4903b9f43b 100644 > --- a/tools/testing/selftests/net/can/Makefile > +++ b/tools/testing/selftests/net/can/Makefile > @@ -3,9 +3,10 @@ > top_srcdir = ../../../../.. > > CFLAGS += -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES) > +LDLIBS += -lpthread > > -TEST_PROGS := test_raw_filter.sh > +TEST_PROGS := test_raw_filter.sh test_vcan_stats.sh [Severity: Low] test_vcan_stats.sh sources $net_dir/lib.sh, and net/lib.sh in turn sources lib/sh/defer.sh. Should these files be listed in TEST_INCLUDES here? net/mptcp/Makefile and net/forwarding/Makefile both do this: TEST_INCLUDES := ../lib.sh $(wildcard ../lib/sh/*.sh) Only the parent net target ships net/lib.sh, through its TEST_FILES. So after "make -C tools/testing/selftests TARGETS=net/can install" the installed script can't source lib.sh. That leaves ksft_skip, check_err, log_test and tests_run undefined, and the test doesn't run. test_raw_filter.sh already has the same gap. This patch adds a second script that depends on lib.sh. > > -TEST_GEN_FILES := test_raw_filter > +TEST_GEN_FILES := test_raw_filter test_vcan_stats > > include ../../lib.mk > 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..1a4f715adead8 > --- /dev/null > +++ b/tools/testing/selftests/net/can/test_vcan_stats.c > @@ -0,0 +1,181 @@ [ ... ] > +static void *stats_reader(void *arg) > +{ > + struct net_dev_stats st; > + > + while (!atomic_load(&stop_reader)) > + read_if_stats(canif, &st); > + > + return NULL; > +} [ ... ] > + EXPECT_EQ(after.tx_packets - before.tx_packets, exp_pkts); > + EXPECT_EQ(after.tx_bytes - before.tx_bytes, exp_bytes); > + EXPECT_EQ(after.rx_packets - before.rx_packets, exp_pkts); > + EXPECT_EQ(after.rx_bytes - before.rx_bytes, exp_bytes); > +} [Severity: Medium] Can these checks ever fail because of the stats race this test seems to target? vcan_setup() sets dev->tx_queue_len = 0, so vcan gets the noqueue qdisc, and vcan does not set lltx. That means every vcan_tx() call is serialized by the txq xmit lock: write()->can_send()->dev_queue_xmit()->__dev_queue_xmit() HARD_TX_LOCK(dev, txq, cpu); dev_hard_start_xmit()->vcan_tx() All the tx and rx counter updates in vcan_tx(), and in vcan_rx() for echo mode, happen inside that one critical section. So the older plain dev->stats increments already gave exact deltas. As far as I can tell, these EXPECT_EQ checks pass the same way with or without the companion change "can: vcan: use per-CPU stats to fix KCSAN data-race in vcan_tx". That race is between a serialized writer and the lockless /proc/net/dev reader. It only shows up as a KCSAN report in dmesg. stats_reader() throws away every sample and ignores the return value of read_if_stats(). Nothing in the test looks at dmesg for KCSAN reports. Could the commit message say which defect this test is meant to catch, and whether it needs a KCSAN-enabled kernel? Alternatively, could the test check something the concurrent reader side can actually get wrong? [ ... ] > 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..1153699cb176b > --- /dev/null > +++ b/tools/testing/selftests/net/can/test_vcan_stats.sh > @@ -0,0 +1,37 @@ [ ... ] > +setup() > +{ > + ip link add name $CANIF type vcan || exit $ksft_skip > + ip link set dev $CANIF up > +} > + > +cleanup() > +{ > + ip link set dev $CANIF down > + ip link delete $CANIF > +} [ ... ] > +trap cleanup EXIT > +setup [Severity: Medium] What happens when "ip link add" fails in setup()? Two ways that can happen are vcan0 already existing, or CANIF being exported as a real CAN device such as can0. setup() then runs exit $ksft_skip. The EXIT trap is already armed, so cleanup() runs: ip link set dev $CANIF down ip link delete $CANIF Won't that take down or delete an interface this script didn't create? With CANIF=can0 the hardware CAN interface is set down. With a pre-existing vcan0, the user's interface is deleted. test_raw_filter.sh uses the same CANIF variable and guards the delete with: if [[ $CANIF == vcan* ]]; then The new script has no such guard. It also doesn't record whether it created the link, and it doesn't use a private netns. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203111103.379929-1-rameshsv06%40gmail.com