From: Stanislav Fomichev <sdf.kernel@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Subject: [RFC net-next v2 5/5] selftests: drv-net: measure devmem performance with kperf
Date: Mon, 5 Oct 2026 13:11:14 -0700 [thread overview]
Message-ID: <20261005201115.2690830-6-sdf@fomichev.me> (raw)
In-Reply-To: <20261005201115.2690830-1-sdf@fomichev.me>
Add a separate udmabuf-backed devmem performance test using KperfRunner.
Keep correctness cases in drivers/net/hw. Skip the test when kperf or
/dev/udmabuf is missing, and fail it when the kperf run fails.
Example metric output:
# # ktap-metric-policy-json: {"display_label":"Gbps","name":"throughput","regression":{"better":"higher","compare":"p50","relative_tolerance":0.05},"summarize":"p50"}
# # ktap-metric-policy-json: {"name":"tcp.retransmits","summarize":"max"}
# # ktap-metric-json: {"host":"remote","name":"throughput","time":29.786267,"type":"scalar","value":389.29900000000004}
# # ktap-metric-json: {"host":"remote","name":"tcp.retransmits","time":29.786286,"type":"scalar","value":698}
# # ktap-metric-json: {"host":"local","name":"throughput","time":29.786289,"type":"scalar","value":388.772}
# # ktap-metric-json: {"host":"local","name":"tcp.retransmits","time":29.78629,"type":"scalar","value":0}
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
.../drivers/net/hw/performance/Makefile | 5 +-
.../drivers/net/hw/performance/config | 3 +
.../drivers/net/hw/performance/devmem.py | 99 +++++++++++++++++++
3 files changed, 106 insertions(+), 1 deletion(-)
create mode 100755 tools/testing/selftests/drivers/net/hw/performance/devmem.py
diff --git a/tools/testing/selftests/drivers/net/hw/performance/Makefile b/tools/testing/selftests/drivers/net/hw/performance/Makefile
index 5d53ef548306..27afdace92e6 100644
--- a/tools/testing/selftests/drivers/net/hw/performance/Makefile
+++ b/tools/testing/selftests/drivers/net/hw/performance/Makefile
@@ -1,6 +1,9 @@
# SPDX-License-Identifier: GPL-2.0
-TEST_PROGS := iperf.py
+TEST_PROGS := \
+ devmem.py \
+ iperf.py \
+ #
TEST_INCLUDES := \
$(wildcard ../lib/py/*.py ../../lib/py/*.py) \
diff --git a/tools/testing/selftests/drivers/net/hw/performance/config b/tools/testing/selftests/drivers/net/hw/performance/config
index 6450f34933e6..111e9b58610d 100644
--- a/tools/testing/selftests/drivers/net/hw/performance/config
+++ b/tools/testing/selftests/drivers/net/hw/performance/config
@@ -1 +1,4 @@
CONFIG_IPV6=y
+CONFIG_NET_DEVMEM=y
+CONFIG_SYNC_FILE=y
+CONFIG_UDMABUF=y
diff --git a/tools/testing/selftests/drivers/net/hw/performance/devmem.py b/tools/testing/selftests/drivers/net/hw/performance/devmem.py
new file mode 100755
index 000000000000..033485f926e4
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/hw/performance/devmem.py
@@ -0,0 +1,99 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""Measure udmabuf-backed devmem TCP throughput with kperf."""
+
+from os import path
+import sys
+
+sys.path.insert(0, path.join(path.dirname(path.abspath(__file__)), ".."))
+
+from lib.py import cmd, defer, ethtool, EthtoolFamily, KperfRunner
+from lib.py import ksft_disruptive, ksft_exit, ksft_run, KsftSkipEx
+from lib.py import NetDrvEpEnv
+
+
+UDMABUF_LIMIT = "/sys/module/udmabuf/parameters/size_limit_mb"
+UDMABUF_SIZE_MB = 2048
+
+
+def _set_udmabuf_limit(host) -> None:
+ current = cmd(f"cat {UDMABUF_LIMIT}", host=host).stdout.strip()
+ if int(current) >= UDMABUF_SIZE_MB:
+ return
+
+ cmd(f"echo {UDMABUF_SIZE_MB} > {UDMABUF_LIMIT}", host=host, shell=True)
+ defer(cmd, f"echo {current} > {UDMABUF_LIMIT}", host=host, shell=True)
+
+
+def _enable_hw_gro(cfg) -> None:
+ features = ethtool(f"-k {cfg.ifname}", json=True)[0]
+ hw_gro = features["rx-gro-hw"]
+ if not hw_gro["active"]:
+ if hw_gro["fixed"]:
+ raise KsftSkipEx("Test requires rx-gro-hw support")
+ ethtool(f"-K {cfg.ifname} rx-gro-hw on")
+ defer(ethtool, f"-K {cfg.ifname} rx-gro-hw off")
+
+
+@ksft_disruptive
+def kperf(cfg) -> None:
+ """Measure udmabuf-backed devmem performance with kperf."""
+ runner = KperfRunner(cfg)
+
+ for name, host in (("local", None), ("remote", cfg.remote)):
+ if cmd("test -c /dev/udmabuf", host=host, fail=False).ret:
+ raise KsftSkipEx(f"Test requires /dev/udmabuf on the {name} host")
+ _set_udmabuf_limit(host)
+
+ # kperf reprograms the RSS indirection table for its queues.
+ defer(ethtool, f"-X {cfg.ifname} default")
+
+ _enable_hw_gro(cfg)
+
+ ethnl = EthtoolFamily()
+ rings = ethnl.rings_get({"header": {"dev-index": cfg.ifindex}})
+ restore = {
+ "header": {"dev-index": cfg.ifindex},
+ "tcp-data-split": rings.get("tcp-data-split", "unknown"),
+ }
+ config = {
+ "header": {"dev-index": cfg.ifindex},
+ "tcp-data-split": "enabled",
+ }
+ # Memory providers require a zero threshold where the driver has one.
+ if "hds-thresh" in rings:
+ restore["hds-thresh"] = rings["hds-thresh"]
+ config["hds-thresh"] = 0
+ defer(ethnl.rings_set, restore)
+ ethnl.rings_set(config)
+
+ devmem_args = [
+ "--time", "15",
+ "--num-connections", "4",
+ "--read-size", str(64 << 20),
+ "--write-size", str(64 << 20),
+ "--pin-off", "4",
+ "--num-rx-queues", "4",
+ "--dmabuf-rx-size-mb", str(UDMABUF_SIZE_MB),
+ "--dmabuf-tx-size-mb", str(UDMABUF_SIZE_MB),
+ "--validate", "no",
+ "--devmem-rx",
+ "--devmem-tx",
+ "--devmem-rx-memory", "host",
+ "--devmem-tx-memory", "host",
+ ]
+
+ with runner:
+ runner.run(client_args=devmem_args, report=True)
+
+
+def main() -> None:
+ """Run the devmem performance test."""
+ with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
+ ksft_run([kperf], args=(cfg,))
+ ksft_exit()
+
+
+if __name__ == "__main__":
+ main()
--
2.53.0-Meta
prev parent reply other threads:[~2026-10-05 20:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 20:11 [RFC net-next v2 0/5] selftests: net: add performance metric reporting Stanislav Fomichev
2026-10-05 20:11 ` [RFC net-next v2 1/5] selftests: net: py: add timestamped metric output Stanislav Fomichev
2026-10-05 20:11 ` [RFC net-next v2 2/5] selftests: net: py: add metric policy output Stanislav Fomichev
2026-10-05 20:11 ` [RFC net-next v2 3/5] selftests: drv-net: add an iperf performance test Stanislav Fomichev
2026-10-05 20:11 ` [RFC net-next v2 4/5] selftests: drv-net: add a kperf runner Stanislav Fomichev
2026-10-05 20:11 ` Stanislav Fomichev [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=20261005201115.2690830-6-sdf@fomichev.me \
--to=sdf.kernel@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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