From: Stanislav Fomichev <s…@fomichev.me>
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 <s…@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