mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: o.rempel@pengutronix.de
Cc: robin@protonic.nl, socketcan@hartkopp.net, mkl@pengutronix.de,
	shuah@kernel.org, kernel@pengutronix.de,
	linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, fmaurer@redhat.com,
	mailhol@kernel.org, alexander.hoelzl@gmx.net,
	quchaosheng000406@163.com, penguin-kernel@I-love.SAKURA.ne.jp,
	kuba@kernel.org
Subject: Re: [PATCH can-next v2 3/9] selftests: can: add J1939 base functional tests
Date: Fri, 06 Nov 2026 05:35:19 +0000	[thread overview]
Message-ID: <179394331932.488853.13385068395595078685@kernel.org> (raw)
In-Reply-To: <20261104-j1939-selftests-v2-3-cf797c83317b@pengutronix.de>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The `bam_broadcast` test in
  tools/testing/selftests/net/can/test_j1939_base.c sends a TP_SIZE…

--

selftests: can: add J1939 base functional tests

This adds a selftest for the SAE J1939 socket interface. It opens a CAN_J1939
sender socket and a receiver socket on vcan. It checks payload integrity for
single frame, TP and ETP sizes, the boundaries between them, and single-frame
and BAM broadcast.

> diff --git a/tools/testing/selftests/net/can/test_j1939_base.c b/tools/testing/selftests/net/can/test_j1939_base.c
> new file mode 100644
> index 0000000000000..d01f4c2c186cb
> --- /dev/null
> +++ b/tools/testing/selftests/net/can/test_j1939_base.c

[ ... ]

> +static bool roundtrip_ok(FIXTURE_DATA(j1939_base) *self, size_t size)
> +{

[ ... ]

> +	errno = 0;
> +	ok = send_recv_verify_ok(self->tx, self->rx, tx_buf, size,
> +				 J1939_RECV_TIMEOUT_MS);

[ ... ]

> +/* BAM (broadcast transport). */
> +TEST_F(j1939_base, bam_broadcast)
> +{
> +	ASSERT_TRUE(pair_up_ok(self, SA_RX, J1939_NO_ADDR, PGN_PDU2, true));
> +	EXPECT_TRUE(roundtrip_ok(self, TP_SIZE));

[Severity: Low]
Is J1939_RECV_TIMEOUT_MS long enough for the whole BAM transfer in
bam_broadcast?

roundtrip_ok()->send_recv_verify_ok()->recvfrom_verify_ok() waits with a
single poll() for the fully reassembled message:

tools/testing/selftests/net/can/j1939_tests.h:recvfrom_verify_ok() {
    ...
	if (poll(&pfd, 1, timeout_ms) > 0)
		n = recvfrom(s, rx_buf, len + 1, 0, (struct sockaddr *)src,
			     &src_len);
    ...
}

The kernel paces broadcast transport at a fixed 50 ms. The first delay comes
after the BAM CM frame:

net/can/j1939/transport.c:j1939_session_tx_rts() {
    ...
	if (dat[0] == J1939_TP_CMD_BAM) {
		j1939_tp_schedule_txtimer(session, 50);
    ...
}

Every broadcast DT frame except the last one adds another 50 ms:

net/can/j1939/transport.c:j1939_session_tx_dat() {
    ...
		pdelay = j1939_cb_is_broadcast(&session->skcb) ? 50 :
			j1939_tp_packet_delay;
    ...
}

TP_SIZE is 128 bytes, which is 19 DT packets. So delivery can't finish in
less than about 50 + 18 * 50 = 950 ms. send() returns once the session is
queued, so the poll() starts at about the same time as the session. That
leaves about 1050 ms of the 2000 ms as headroom for a slow VM.

The comment in j1939_tests.h describes the timeout as a wait for one frame:

/*
 * How long to wait for an expected frame. Not a protocol timer: a guess with
 * room for a slow VM.
 */
#define J1939_RECV_TIMEOUT_MS	2000

For BAM, though, it limits the whole message, and about half of it goes to
the protocol's own pacing.

Could this fail spuriously on a loaded KASAN or lockdep QEMU-TCG runner, where
the soft hrtimers that drive the 19 packets are deferred to ksoftirqd?

The timeout also doesn't grow with the message size. If TP_SIZE were raised
above about 280 bytes (more than 40 BAM packets), wouldn't bam_broadcast fail
every time?

The unicast TP and ETP tests aren't affected, since j1939_tp_packet_delay
defaults to 0. J1939_RECV_TIMEOUT_MS, its comment, and the bam_broadcast size
are unchanged at the end of the series.

Would it make sense to scale the timeout with the number of BAM packets, or
to use a separate, longer timeout for broadcast transport?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261104-j1939-selftests-v2-0-cf797c83317b%40pengutronix.de

  reply	other threads:[~2026-11-06  5:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 16:17 [PATCH can-next v2 0/9] selftests: can: add J1939 socket and transport tests Oleksij Rempel
2026-11-04 16:17 ` [PATCH can-next v2 1/9] selftests: can: install net/lib.sh with the CAN tests Oleksij Rempel
2026-11-04 16:17 ` [PATCH can-next v2 2/9] selftests: can: add J1939 test helper header and library Oleksij Rempel
2026-11-06  5:35   ` netdev-bot+sashiko
2026-11-04 16:17 ` [PATCH can-next v2 3/9] selftests: can: add J1939 base functional tests Oleksij Rempel
2026-11-06  5:35   ` netdev-bot+sashiko [this message]
2026-11-04 16:17 ` [PATCH can-next v2 4/9] selftests: can: add J1939 socket option and metadata tests Oleksij Rempel
2026-11-06  5:35   ` netdev-bot+sashiko
2026-11-04 16:17 ` [PATCH can-next v2 5/9] selftests: can: add J1939 addressing and concurrency tests Oleksij Rempel
2026-11-06  5:35   ` netdev-bot+sashiko
2026-11-04 16:17 ` [PATCH can-next v2 6/9] selftests: can: add J1939 wire-format tests against CAN_RAW Oleksij Rempel
2026-11-06  5:35   ` netdev-bot+sashiko
2026-11-04 16:17 ` [PATCH can-next v2 7/9] selftests: can: add J1939 TP/ETP multi-frame " Oleksij Rempel
2026-11-06  5:35   ` netdev-bot+sashiko
2026-11-04 16:17 ` [PATCH can-next v2 8/9] selftests: can: cover J1939 transport abort and timeout paths Oleksij Rempel
2026-11-04 16:17 ` [PATCH can-next v2 9/9] selftests: can: check SO_J1939_PROMISC receive effect Oleksij Rempel
2026-11-06  5:35   ` netdev-bot+sashiko
2026-11-06 10:30 ` [PATCH can-next v2 0/9] selftests: can: add J1939 socket and transport tests Oleksij Rempel

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=179394331932.488853.13385068395595078685@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alexander.hoelzl@gmx.net \
    --cc=fmaurer@redhat.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=quchaosheng000406@163.com \
    --cc=robin@protonic.nl \
    --cc=shuah@kernel.org \
    --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

all inboxes | Powered by JetHome®