* [PATCH net-next 1/4] selftests: drv-net: kperf: support request-response tests
2026-11-23 17:41 [PATCH net-next 0/4] selftests: replace iperf with kperf and add RR Stanislav Fomichev
@ 2026-11-23 17:41 ` Stanislav Fomichev
2026-11-23 17:41 ` [PATCH net-next 2/4] selftests: drv-net: add a closed-loop request-response test Stanislav Fomichev
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Stanislav Fomichev @ 2026-11-23 17:41 UTC (permalink / raw)
To: netdev; +Cc: davem, edumazet, kuba, pabeni
Let KperfResult tell the rate of the transactions of request-response
tests and, when the client is asked for them with --time-stats 2, their
latency percentiles and maximum, as seen by the source, which sends the
requests. Request-response tests run a single flow; of more, the first
one is kept.
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
.../selftests/drivers/net/lib/py/kperf.py | 31 +++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/lib/py/kperf.py b/tools/testing/selftests/drivers/net/lib/py/kperf.py
index 8ee8c5ba2ff7..98d27d83dee2 100644
--- a/tools/testing/selftests/drivers/net/lib/py/kperf.py
+++ b/tools/testing/selftests/drivers/net/lib/py/kperf.py
@@ -7,20 +7,35 @@ import shlex
import subprocess
import uuid
from dataclasses import dataclass
+from typing import Optional
from lib.py import cmd, ksft_pr, rand_port, wait_port_listen
_SECTION_RE = re.compile(r"==\s+(Source|Target)\b")
_RATE_RE = re.compile(r"\b(Tx|Rx)\s*([0-9]+(?:\.[0-9]+)?)\s+Gbps\b")
+_RPS_RE = re.compile(r"\b([0-9]+(?:\.[0-9]+)?) RPS\b")
+_LAT_RE = re.compile(
+ r"\b(p25|p50|p90|p99|p999|p9999|max):([0-9]+(?:\.[0-9]+)?)us\b")
@dataclass
class KperfResult:
- """Aggregate throughput (Gbps) of both endpoints."""
+ """Aggregate throughput (Gbps) of both endpoints. Request-response tests
+ also tell the rate (per second) of the source, which sends the requests,
+ and with --time-stats 2 its latencies (usec).
+ """
source_throughput: float
target_throughput: float
+ rate: Optional[float] = None
+ p25: Optional[float] = None
+ p50: Optional[float] = None
+ p90: Optional[float] = None
+ p99: Optional[float] = None
+ p999: Optional[float] = None
+ p9999: Optional[float] = None
+ lat_max: Optional[float] = None
class KperfRunner:
@@ -133,6 +148,7 @@ _RATE_RE = re.compile(r"\b(Tx|Rx)\s*([0-9]+(?:\.[0-9]+)?)\s+Gbps\b")
def parse(output):
"""Parse human-readable kperf client output."""
throughput = {"Source": [], "Target": []}
+ rr = {}
section = None
for line in output.splitlines():
@@ -149,9 +165,20 @@ _RATE_RE = re.compile(r"\b(Tx|Rx)\s*([0-9]+(?:\.[0-9]+)?)\s+Gbps\b")
if (section, direction) in (("Source", "Tx"),
("Target", "Rx")):
throughput[section].append(float(value))
+ if section != "Source":
+ continue
+
+ # Request-response tests run a single flow, take the first one
+ # and ignore the rest
+ match = _RPS_RE.search(line)
+ if match:
+ rr.setdefault("rate", float(match.group(1)))
+ for name, value in _LAT_RE.findall(line):
+ key = "lat_max" if name == "max" else name
+ rr.setdefault(key, float(value))
if not all(throughput.values()):
raise ValueError("incomplete kperf result")
return KperfResult(sum(throughput["Source"]),
- sum(throughput["Target"]))
+ sum(throughput["Target"]), **rr)
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-next 2/4] selftests: drv-net: add a closed-loop request-response test
2026-11-23 17:41 [PATCH net-next 0/4] selftests: replace iperf with kperf and add RR Stanislav Fomichev
2026-11-23 17:41 ` [PATCH net-next 1/4] selftests: drv-net: kperf: support request-response tests Stanislav Fomichev
@ 2026-11-23 17:41 ` Stanislav Fomichev
2026-11-23 17:41 ` [PATCH net-next 3/4] selftests: drv-net: add a kperf stream test Stanislav Fomichev
2026-11-23 17:41 ` [PATCH net-next 4/4] selftests: drv-net: remove the iperf performance test Stanislav Fomichev
3 siblings, 0 replies; 5+ messages in thread
From: Stanislav Fomichev @ 2026-11-23 17:41 UTC (permalink / raw)
To: netdev; +Cc: davem, edumazet, kuba, pabeni
Add rr.py, which measures back-to-back transactions of a kilobyte each
way, which fits in a 1500 byte MTU, over one connection with kperf, and
reports their rate and the latency percentiles and maximum which kperf
reports.
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
.../selftests/drivers/net/perf/Makefile | 1 +
.../testing/selftests/drivers/net/perf/rr.py | 47 +++++++++++++++++++
2 files changed, 48 insertions(+)
create mode 100755 tools/testing/selftests/drivers/net/perf/rr.py
diff --git a/tools/testing/selftests/drivers/net/perf/Makefile b/tools/testing/selftests/drivers/net/perf/Makefile
index 1a90537d2726..91feb0d62a7b 100644
--- a/tools/testing/selftests/drivers/net/perf/Makefile
+++ b/tools/testing/selftests/drivers/net/perf/Makefile
@@ -3,6 +3,7 @@
TEST_PROGS := \
devmem.py \
iperf.py \
+ rr.py \
# end of TEST_PROGS
TEST_INCLUDES := \
diff --git a/tools/testing/selftests/drivers/net/perf/rr.py b/tools/testing/selftests/drivers/net/perf/rr.py
new file mode 100755
index 000000000000..1dff0c476390
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/perf/rr.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""Measure TCP request-response performance with kperf."""
+
+from lib.py import KperfRunner, NetDrvEpEnv, ksft_exit, ksft_metric, ksft_run
+
+
+# One connection, a kilobyte each way, which fits in a 1500 byte MTU, and
+# latency percentiles
+RR_ARGS = [
+ "--time", "10",
+ "--warmup", "100",
+ "--num-connections", "1",
+ "--req-size", "1024",
+ "--resp-size", "1024",
+ "--time-stats", "2",
+ "--validate", "no",
+]
+
+
+def _report(result) -> None:
+ ksft_metric("rate", result.rate, goal="higher")
+ ksft_metric("latency_p25", result.p25, goal="lower")
+ ksft_metric("latency_p50", result.p50, goal="lower")
+ ksft_metric("latency_p90", result.p90, goal="lower")
+ ksft_metric("latency_p99", result.p99, goal="lower")
+ ksft_metric("latency_p999", result.p999, goal="lower")
+ ksft_metric("latency_p9999", result.p9999, goal="lower")
+ ksft_metric("latency_max", result.lat_max, goal="lower")
+
+
+def closed_loop(cfg) -> None:
+ """Measure back-to-back transactions."""
+ with KperfRunner(cfg) as runner:
+ _report(runner.run(RR_ARGS))
+
+
+def main() -> None:
+ """Run the request-response performance tests."""
+ with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
+ ksft_run([closed_loop], args=(cfg,))
+ ksft_exit()
+
+
+if __name__ == "__main__":
+ main()
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-next 3/4] selftests: drv-net: add a kperf stream test
2026-11-23 17:41 [PATCH net-next 0/4] selftests: replace iperf with kperf and add RR Stanislav Fomichev
2026-11-23 17:41 ` [PATCH net-next 1/4] selftests: drv-net: kperf: support request-response tests Stanislav Fomichev
2026-11-23 17:41 ` [PATCH net-next 2/4] selftests: drv-net: add a closed-loop request-response test Stanislav Fomichev
@ 2026-11-23 17:41 ` Stanislav Fomichev
2026-11-23 17:41 ` [PATCH net-next 4/4] selftests: drv-net: remove the iperf performance test Stanislav Fomichev
3 siblings, 0 replies; 5+ messages in thread
From: Stanislav Fomichev @ 2026-11-23 17:41 UTC (permalink / raw)
To: netdev; +Cc: davem, edumazet, kuba, pabeni
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. kperf pins the application a few
CPUs away from the interrupts of the flow, so that the CPUs of a run do
not depend on the scheduler. One connection is bound by the CPU rather
than the line rate, so that the throughput follows changes to the cost
of the stack and the driver.
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
.../selftests/drivers/net/perf/Makefile | 1 +
.../selftests/drivers/net/perf/stream.py | 40 +++++++++++++++++++
2 files changed, 41 insertions(+)
create mode 100755 tools/testing/selftests/drivers/net/perf/stream.py
diff --git a/tools/testing/selftests/drivers/net/perf/Makefile b/tools/testing/selftests/drivers/net/perf/Makefile
index 91feb0d62a7b..b3f9dcac700b 100644
--- a/tools/testing/selftests/drivers/net/perf/Makefile
+++ b/tools/testing/selftests/drivers/net/perf/Makefile
@@ -4,6 +4,7 @@ TEST_PROGS := \
devmem.py \
iperf.py \
rr.py \
+ stream.py \
# end of TEST_PROGS
TEST_INCLUDES := \
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 000000000000..4ed9d64dfa32
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/perf/stream.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""Measure TCP stream throughput with kperf."""
+
+from lib.py import KperfRunner, KsftNamedVariant, NetDrvEpEnv, ksft_exit
+from lib.py import ksft_metric, ksft_run, ksft_variants
+
+
+@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 = [
+ "--time", "15",
+ "--num-connections", "1",
+ "--read-size", str(64 << 20),
+ "--write-size", str(64 << 20),
+ "--pin-off", "4",
+ "--validate", "no",
+ *mode_args,
+ ]
+
+ with KperfRunner(cfg) as runner:
+ result = runner.run(stream_args)
+
+ ksft_metric("throughput", result.target_throughput, goal="higher")
+
+
+def main() -> None:
+ """Run the stream performance test."""
+ with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
+ ksft_run([tcp], args=(cfg,))
+ ksft_exit()
+
+
+if __name__ == "__main__":
+ main()
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-next 4/4] selftests: drv-net: remove the iperf performance test
2026-11-23 17:41 [PATCH net-next 0/4] selftests: replace iperf with kperf and add RR Stanislav Fomichev
` (2 preceding siblings ...)
2026-11-23 17:41 ` [PATCH net-next 3/4] selftests: drv-net: add a kperf stream test Stanislav Fomichev
@ 2026-11-23 17:41 ` Stanislav Fomichev
3 siblings, 0 replies; 5+ messages in thread
From: Stanislav Fomichev @ 2026-11-23 17:41 UTC (permalink / raw)
To: netdev; +Cc: davem, edumazet, kuba, pabeni
The throughput of one iperf3 stream changes by about 10% between
back-to-back runs on the same hosts, e.g. from 90.7 to 99.6 Gbps over
four runs, as much as a regression would. stream.py measures one TCP
connection with kperf instead, remove iperf.py.
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
.../selftests/drivers/net/perf/Makefile | 1 -
.../selftests/drivers/net/perf/iperf.py | 23 -------------------
2 files changed, 24 deletions(-)
delete mode 100755 tools/testing/selftests/drivers/net/perf/iperf.py
diff --git a/tools/testing/selftests/drivers/net/perf/Makefile b/tools/testing/selftests/drivers/net/perf/Makefile
index b3f9dcac700b..898236833c42 100644
--- a/tools/testing/selftests/drivers/net/perf/Makefile
+++ b/tools/testing/selftests/drivers/net/perf/Makefile
@@ -2,7 +2,6 @@
TEST_PROGS := \
devmem.py \
- iperf.py \
rr.py \
stream.py \
# end of TEST_PROGS
diff --git a/tools/testing/selftests/drivers/net/perf/iperf.py b/tools/testing/selftests/drivers/net/perf/iperf.py
deleted file mode 100755
index 5b6f0bce2a03..000000000000
--- a/tools/testing/selftests/drivers/net/perf/iperf.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python3
-# SPDX-License-Identifier: GPL-2.0
-
-"""Measure TCP throughput with iperf3."""
-
-from lib.py import Iperf3Runner, NetDrvEpEnv, ksft_exit, ksft_metric, ksft_run
-
-
-def tcp(cfg):
- """Measure TCP throughput."""
- result = Iperf3Runner(cfg).measure()
- ksft_metric("throughput", result.throughput, goal="higher")
-
-
-def main():
- """Run the iperf performance test."""
- with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
- ksft_run([tcp], args=(cfg,))
- ksft_exit()
-
-
-if __name__ == "__main__":
- main()
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 5+ messages in thread