Re: [PATCH net-next v2 3/4] selftests: drv-net: add a kperf stream test
From: netdev-bot+sashiko
Date: Tue Dec 01 2026 - 13:10:55 EST
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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] The "zerocopy" variant of tcp() in stream.py adds "--msg-
zerocopy" and "--zerocopy-rx".
- [Low] The commit message for stream.py says it measures one TCP
connection "with the same settings as devmem.py otherwise".
--
selftests: drv-net: add a kperf stream test
This adds stream.py, a drv-net perf selftest that uses kperf to measure
the throughput of a single TCP connection. It has two variants: plain
copy, and MSG_ZEROCOPY on the sender with TCP_ZEROCOPY_RECEIVE on the
receiver.
> Add stream.py, which measures the throughput of one TCP connection with
> kperf, with the same settings as devmem.py otherwise: once over copying
> sockets, and once with MSG_ZEROCOPY on the sender and
> TCP_ZEROCOPY_RECEIVE on the receiver.
[Severity: Low]
Is "with the same settings as devmem.py otherwise" accurate?
The two tests share the kperf client options: --time 15, the 64 MiB read
and write sizes, --pin-off 4 and --validate no.
devmem.py's kperf() also sets up the device before it measures:
tools/testing/selftests/drivers/net/perf/devmem.py:kperf() {
...
_enable_hw_gro(cfg)
...
"tcp-data-split": "enabled",
...
config["hds-thresh"] = 0
defer(ethnl.rings_set, restore)
ethnl.rings_set(config)
...
"--num-rx-queues", "4",
...
}
stream.py's tcp() does none of this, so it runs with the driver's
default GRO, HDS and RSS settings. The message only mentions the change
from 4 connections to 1.
Could the message say that the device-level setup also differs? Then the
stream.py and devmem.py numbers wouldn't be read as directly comparable.
> diff --git a/tools/testing/selftests/drivers/net/perf/stream.py b/tools/testing/selftests/drivers/net/perf/stream.py
> new file mode 100755
> index 0000000000000..4ed9d64dfa320
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/net/perf/stream.py
> @@ -0,0 +1,40 @@
[ ... ]
> +@ksft_variants([
> + KsftNamedVariant("copy", []),
> + KsftNamedVariant("zerocopy", ["--msg-zerocopy", "--zerocopy-rx"]),
> +])
> +def tcp(cfg, mode_args) -> None:
> + """Measure the throughput of one TCP connection."""
> + stream_args = [
[ ... ]
> + with KperfRunner(cfg) as runner:
> + result = runner.run(stream_args)
> +
> + ksft_metric("throughput", result.target_throughput, goal="higher")
[Severity: Medium]
Does the zerocopy variant actually exercise TCP_ZEROCOPY_RECEIVE on a
device with default settings?
The variant only adds kperf flags. On the kernel side, can_map_frag()
only maps full-page frags at offset 0:
net/ipv4/tcp.c:can_map_frag() {
...
if (skb_frag_size(frag) != PAGE_SIZE || skb_frag_off(frag))
return false;
...
}
NICs normally produce frags like that only with header-data split and an
MTU large enough for page-sized payloads. stream.py sets neither.
devmem.py at least enables tcp-data-split.
With no HDS and a 1500 MTU, every payload frag fails can_map_frag().
tcp_zerocopy_receive() then maps nothing, and the receiver copies the
data instead.
Nothing here checks whether zerocopy happened. KperfRunner.parse() in
drivers/net/lib/py/kperf.py only extracts throughput, rate and latency:
return KperfResult(sum(throughput["Source"]),
sum(throughput["Target"]), **rr)
tcp() then reports only the throughput metric.
Can the "zerocopy" result come from the copy receive path and still be
labelled zerocopy? If so, a loss of TCP_ZEROCOPY_RECEIVE, or a
regression in it, would not show up in this sub-case.
If kperf fails instead of falling back when nothing can be mapped,
wouldn't this variant fail on most default setups?
Would it make sense to enable HDS (and possibly raise the MTU) for this
variant? Another option is to check that pages were actually mapped, or
that SO_EE_CODE_ZEROCOPY_COPIED was not reported.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130174609.314114-1-sdf.kernel%40gmail.com