From: Stanislav Fomichev <s…@fomichev.me> 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 should run one connection; of more, the first value kperf reports for each metric is kept. Signed-off-by: Stanislav Fomichev <s…@fomichev.me> --- v1: https://lore.kernel.org/netdev/2026…@fomichev.me/ --- .../selftests/drivers/net/lib/py/kperf.py | 33 +++++++++++++++++-- 1 file changed, 31 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..3092d3c56b7f 100644 --- a/tools/testing/selftests/drivers/net/lib/py/kperf.py +++ b/tools/testing/selftests/drivers/net/lib/py/kperf.py @@ -2,6 +2,8 @@ """Run and parse kperf network performance measurements.""" +from __future__ import annotations + import re import shlex import subprocess @@ -13,14 +15,29 @@ 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). They should run one + connection: of more, the first value kperf reports for each is kept. + """ source_throughput: float target_throughput: float + rate: float | None = None + p25: float | None = None + p50: float | None = None + p90: float | None = None + p99: float | None = None + p999: float | None = None + p9999: float | None = None + lat_max: float | None = None class KperfRunner: @@ -133,6 +150,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 +167,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 one connection, keep the first + # value kperf reports for each metric + 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