Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: xiexinet@gmail.com
Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, andrew+netdev@lunn.ch, shuah@kernel.org,
	kees@kernel.org, petr.wozniak@gmail.com, qingfang.deng@linux.dev,
	fmaurer@redhat.com, luka.gejak@linux.dev, bigeasy@linutronix.de,
	xiaoliang.yang_1@nxp.com, skhawaja@google.com,
	liuhangbin@gmail.com, stable@vger.kernel.org,
	sdf.kernel@gmail.com, lukma@denx.de, fmancera@suse.de,
	danishanwar@ti.com
Subject: Re: [PATCH net v10 4/4] selftests: net: hsr: verify GRO policy and ordered forwarding
Date: Fri, 20 Nov 2026 02:22:05 +0000	[thread overview]
Message-ID: <179514132547.3136.13495496804508264681@kernel.org> (raw)
In-Reply-To: <20261117141922.20-5-xiexinet@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · 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] The single-producer ordered cases in hsr_ordered_forwarding.sh
  can fail even when the kernel is correct.

--

selftests: net: hsr: verify GRO policy and ordered forwarding

This commit adds two HSR/PRP kselftests, and both run one shared Python
helper. hsr_gro_superpacket.sh checks the GRO policy on HSR members, the
refusal of unsupported port types, and TCP forwarding from the interlink
and from a PRP SAN. hsr_ordered_forwarding.sh checks the ordering of
local and interlink data, supervision frames, concurrent producers and a
sequence-number wrap.

> diff --git a/tools/testing/selftests/net/hsr/hsr_gro_superpacket.py b/tools/testing/selftests/net/hsr/hsr_gro_superpacket.py
> new file mode 100755
> index 0000000000000..17055d9329b3d
> --- /dev/null
> +++ b/tools/testing/selftests/net/hsr/hsr_gro_superpacket.py
> @@ -0,0 +1,1468 @@

[ ... ]

> +def ordered_send(lab, sock, producer, first, count, port, segment=0):
> +    """Send count datagrams, or UDP GSO aggregates of 16; return the payloads."""
> +    expected = []
> +    if segment:
> +        sock.setsockopt(socket.IPPROTO_UDP, 103, segment)
> +    blocks = 16 if segment else 1
> +    size = segment or 64
> +    for number in range(count):
> +        payloads = [ordered_payload(producer, first + number * blocks + n,
> +                                    size) for n in range(blocks)]
> +        body = b"".join(payloads)
> +        require(sock.sendto(body, ("239.0.0.9", port)) == len(body),
> +                "short UDP send")

[Severity: Medium]

Can the single-producer ordered cases fail on a correct kernel because
this sender is not pinned to a CPU?

ordered_send() runs in the main thread, and the main thread never calls
os.sched_setaffinity(). Only the producer threads in ordered_concurrent()
are pinned.

The frames go through the veth t0 to the interlink dil. There is no XDP,
and GRO is forced off on HSR members. So veth hands each frame to the
backlog of the CPU that sent it:

drivers/net/veth.c:veth_forward_skb() {
	return __dev_forward_skb(dev, skb) ?: xdp ?
		veth_xdp_rx(rq, skb) :
		__netif_rx(skb);
}

The netif_rx path then calls enqueue_to_backlog(skb, smp_processor_id(),
...).

Threaded backlogs are always used on CONFIG_PREEMPT_RT, and also with the
thread_backlog_napi boot option. With them, ____napi_schedule() only wakes
the per-CPU backlog thread:

net/core/dev.c:____napi_schedule() {
    ...
	if (use_backlog_threads() && thread == raw_cpu_read(backlog_napi))
		goto use_local_napi;

	set_bit(NAPI_STATE_SCHED_THREADED, &napi->state);
	wake_up_process(thread);
    ...
}

As a result, sendto() returns before the frame is processed. The same can
happen without threaded backlogs when NET_RX is deferred to ksoftirqd.

Suppose the sender migrates from CPU X to CPU Y in the middle of the loop.
The backlog threads of X and Y can then run hsr_handle_frame() for dil at
the same time. They take seqnr_lock in arrival order, so a later send can
get a lower HSR sequence number and appear earlier on dil, da and db.

The test still requires the exact send order in ordered_data():

    require([row["payload"] for row in incoming] == expected_inputs,
            "actual UDP ingress input set/order differs")

It also requires it through verify_udp(..., input_order=True) in
ordered_data(), ordered_supervision() and ordered_wrap(). ordered_wrap()
is the most exposed: it sends up to about 65k warmup datagrams plus 256
more, and all of them are checked with input_order=True.

Would pinning the sending thread to one CPU for the ordered cases, or
pinning the whole process in ordered mode, avoid this?

> +        expected.extend(payloads)
> +        # Keep capture receive queues bounded throughout long wrap warmups.
> +        if number % 8 == 0:
> +            lab.observe(0)
> +    lab.observe(0.1)
> +    return expected

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117141922.20-1-xiexinet%40gmail.com

      reply	other threads:[~2026-11-20  2:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 14:19 [PATCH net v10 0/4] net: hsr: fix super-packet forwarding Xin Xie
2026-11-17 14:19 ` [PATCH net v10 1/4] net: hsr: keep GRO disabled on HSR/PRP ports Xin Xie
2026-11-20  2:22   ` netdev-bot+sashiko
2026-11-17 14:19 ` [PATCH net v10 2/4] net: hsr: refuse forwarding devices as " Xin Xie
2026-11-20  2:22   ` netdev-bot+sashiko
2026-11-17 14:19 ` [PATCH net v10 3/4] net: hsr: segment GSO before per-frame forwarding Xin Xie
2026-11-20  2:22   ` netdev-bot+sashiko
2026-11-17 14:19 ` [PATCH net v10 4/4] selftests: net: hsr: verify GRO policy and ordered forwarding Xin Xie
2026-11-20  2:22   ` netdev-bot+sashiko [this message]

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=179514132547.3136.13495496804508264681@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bigeasy@linutronix.de \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fmancera@suse.de \
    --cc=fmaurer@redhat.com \
    --cc=horms@kernel.org \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=liuhangbin@gmail.com \
    --cc=luka.gejak@linux.dev \
    --cc=lukma@denx.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petr.wozniak@gmail.com \
    --cc=qingfang.deng@linux.dev \
    --cc=sdf.kernel@gmail.com \
    --cc=shuah@kernel.org \
    --cc=skhawaja@google.com \
    --cc=stable@vger.kernel.org \
    --cc=xiaoliang.yang_1@nxp.com \
    --cc=xiexinet@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