From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796429733; b=Uy7501BOMT+Ebuih9dpmnMUf9aWgIpihHqm0l+llVix1WLBh9OzXCW0k86lV3zLrDWV6 HbgAS6T34acdpBH+XBcap9u0b84N4PTs+ZS199tsCG9IPw7aBlpIzCo52ZSJWAyq+0yjS xKbA40CGKRAk8/FIRb3S3fc5gKf+BaX9uD20j3QHNcRsAiUjxIJyAM2A4PfEXvecB0yj3 K4ioPEMOSvrfpx+HJsgxC59w+3fwbeEHqQKATWo82fQGkVs+L1rmfasXq3Cty/CNflfDG sJMr6q5X2zXIJmYPFAS9JvzCCYwcRlPc2K+30oBYM758JqVyHKASxjgh/IdBRB2Ecpg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796429733; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=7LtI3l64/CnzYDkIoz2Y8Z3RHaMTWcLkUCFLqX/22og=; b=jRadeFGkwfZRV0B9aQLocIWdyxEbqqH0XQt7/eXxxLR0qLDlw4aQqlzSo7+FzXqkhNXG P1KccxP+/w3zREo8zUv3weSeN24mBq8dTw+wh7FaqpP6ANzOk7BjC7rUuThAG2Wl8CxiO cbPnv8nIB21DE4SaVIMeqdMRFnTlUSxyfORpMTXbUuE8UEDr8SI02/M95ZoBQrqMw6YwQ yITegrJiGz5odybQKSjHFTq4Vgd1PepJOjZ1FdWI2cg9c30xPygdczrOZp3Zknl8KJmcT JhmtgYyvsGRhYLOO8WUJoPxgdDqalQHP3ZIrd+/480w26rNovhSZ/HpBYdv7b8Do4Aw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SpdL26JA; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2678606A685; Sat, 5 Dec 2026 00:15:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SpdL26JA Received: by smtp.kernel.org (Postfix) with ESMTPSA id F251C1F00A18; Sat, 5 Dec 2026 00:15:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796429733; bh=7LtI3l64/CnzYDkIoz2Y8Z3RHaMTWcLkUCFLqX/22og=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=SpdL26JAX8x5xHdkZfYLrKGaYri75j4BxmwWZJZu+D2BZnjdNibfOgsmFvWj2IVJb ur4PMwX7IokcXQdnLTD1AU9GloUspcYwyfaPeriuG+o261I6n71VLNI3C7Lr8GFVA9 vXADLSVtVLOzP0rWr4ZrdOdqEceudU19DG45HuddOOlYtt46UUUZk4woDoqQKXTN3C wpuPnW9EFgm5eLzFktpAkXDnH0AFLg8lRxnufOOdSM7HLXt0hIB1qBd6zWFdSn2xpE B3WhOuamgaL5u5JXHOc05kanUrLngDAeDHET3YDn1QaTgYdk4TdEj3/ZVJIcSdffSL 7Egyk3U5p+N6A== Subject: Re: [PATCH net-next 07/11] selftests: drv-net: tc_flower_police: Test multiple policers From: netdev-bot+sashiko@kernel.org To: mohsin.bashr@gmail.com Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sat, 05 Dec 2026 00:15:32 +0000 Message-ID: <179642973256.3146.13809553627644999013@kernel.org> In-Reply-To: <20261204000521.3396802-8-mohsin.bashr@gmail.com> References: <20261204000521.3396802-8-mohsin.bashr@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 3 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] selftests/drv-net: police_shared_action() allows a dropping rule to pass - [Low] The authorship tags contradict the From: line. - [Low] selftests/drv-net: police_shared_action() index exceeds HW policer table size - [Low] selftests/drv-net: _iperf3_flows() does not reap child or close pipes on kill -- selftests: drv-net: tc_flower_police: Test multiple policers This commit adds three tests to tc_flower_police.py: police_independent, police_shared_action and police_priority. Together they check that a device keeps separate policers apart, shares a police action across rules when asked to, and applies overlapping rules in priority order. Both flows run at the same time through a new _iperf3_flows() helper. > Signed-off-by: Jakub Kicinski > Signed-off-by: Mohsin Bashir [Severity: Low] This isn't a bug, but do these trailers match the From: line? The author is Mohsin Bashir, but the first Signed-off-by is Jakub Kicinski's, and there is no Co-developed-by tag. Documentation/process/submitting-patches.rst says the first SoB entry signals primary authorship. It also says that when a patch has more than one author, each co-author needs a Co-developed-by tag immediately followed by their Signed-off-by. If Jakub co-developed the patch, should the block look like this? Co-developed-by: Jakub Kicinski Signed-off-by: Jakub Kicinski Signed-off-by: Mohsin Bashir If Jakub is the sole author, should the From: line carry his name instead? Every patch in the series has the same trailer, from "selftests: drv-net: Iperf3Runner: Support UDP and server side results" through "selftests: drv-net: tc_flower_police: Test policing with RSS contexts", so the same change would apply to all of them. [ ... ] > diff --git a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py > --- a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py > +++ b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py > @@ -377,6 +378,108 @@ def police_params(cfg, action, expect): > raise KsftSkipEx(f"Not offloaded: {reason}") > > > +def _iperf3_flows(cfg, dsts, bw_mbit): > + runners = [Iperf3Runner(cfg, port=port, server_ip=dst) > + for dst, port in zip(dsts, rand_ports(len(dsts)))] > + servers, clients = [], [] > + try: > + for runner in runners: > + servers.append(runner.start_server(json=True)) > + for runner in runners: > + clients.append(runner.start_client(background=True, > + duration=MEASURE_SEC, omit=1, > + udp_mbit=_payload_mbit(bw_mbit), > + length=UDP_PAYLOAD)) > + for proc in clients: > + proc.process(terminate=False, timeout=MEASURE_SEC + 15) > + for proc in servers: > + proc.process(terminate=False, fail=False, timeout=5) > + except CmdExitFailure as ex: > + out = f"{ex.cmd.stderr} {ex.cmd.stdout}" > + raise KsftFailEx(f"iperf3 failed: {out}") from ex > + finally: > + for proc in clients + servers: > + if proc.ret is None: > + try: > + proc.process(terminate=True, fail=False, timeout=5) > + except subprocess.TimeoutExpired: > + proc.proc.kill() > + return [_rx_mbit(server.stdout) for server in servers] > + > + > +def police_independent(cfg): > + """ > + Check that two rules with their own police actions each enforce their > + own rate. > + """ > + _setup_clsact(cfg) > + rule1, dst1 = _dst_ip_rule(cfg) > + rule2, dst2 = _dst_ip_rule(cfg) > + > + _check_baseline_rate(cfg) > + _add_filter(cfg, rule1, _police(RATE_MBIT // 4), pref=10) > + _add_filter(cfg, rule2, _police(RATE_MBIT // 2), pref=11) > + > + got1, got2 = _iperf3_flows(cfg, [dst1, dst2], OFFERED_MBIT // 2) > + _check_rate(got1, RATE_MBIT // 4, "first filter") > + _check_rate(got2, RATE_MBIT // 2, "second filter") > + > + > +def _skip_rejected(cfg, err, pref, what): > + if _filter_info(cfg, pref) is not None: > + raise KsftFailEx(f"Rejected {what} left behind") > + ksft_pr(err) > + raise KsftSkipEx(f"{what} not offloaded") > + > + > +def police_shared_action(cfg): > + """ > + Check that two rules sharing a police action index are limited together > + to a single rate. > + """ > + _setup_clsact(cfg) > + rule1, dst1 = _dst_ip_rule(cfg) > + rule2, dst2 = _dst_ip_rule(cfg) > + while True: > + index = random.randint(1000, 60000) [Severity: Low] Does this leave the killed process behind? proc.process(terminate=True, ...) ends up in cmd._process_terminate(). That function calls self.proc.communicate(timeout=timeout) before it closes self.proc.stdout and self.proc.stderr and sets self.ret. When communicate() raises subprocess.TimeoutExpired, none of that happens. proc.proc.kill() then only sends SIGKILL. Nothing waits for the child afterwards. It stays a zombie, and its pipes stay open until the objects are garbage collected. The deferred teardown of the test addresses and the clsact qdisc can then race with the dying iperf3 process. Later test cases in the same run also keep the leaked descriptors. Would it be better to follow the kill with proc.proc.wait(), or with another proc.process(terminate=False, fail=False) call? The kperf helpers in drivers/net/lib/py already handle their kill path that way. [Severity: Low] Will this index work on devices that map the police action index straight onto a hardware policer slot? The kernel hands act->tcfa_index to drivers as flow_action_entry.hw_index, and some in-tree drivers use it directly. ocelot_flower_parse_action() computes pol_ix from a->hw_index plus vcap_pol.base, and returns -EINVAL once that reaches vcap_pol.max, which is 191 on VSC7514. enetc_psfp_parse_clsflower() uses entryp->hw_index as the flow meter index. random.randint(1000, 60000) never picks anything below 1000. On such hardware the first _add_filter() in police_shared_action() would be rejected, and the test would bail out before the shared rule is even tried. That can happen even if the device supports shared policers just fine. Could the first rule be installed without an explicit index, and the index the kernel assigned be read back for the second rule? For example, _filter_info() on pref 10 could provide it, if it exposes the action index. Or would probing for a free index starting from a low value be simpler? > + if cmd(f"tc actions get action police index {index}", > + fail=False).ret: > + break > + > + _check_baseline_rate(cfg) > + _add_filter(cfg, rule1, _police(RATE_MBIT, extra=f"index {index}"), > + pref=10) > + added, err = _try_filter(cfg, rule2, f"action police index {index}", > + pref=11) > + if not added: > + _skip_rejected(cfg, err, 11, "Shared police action") > + > + total = sum(_iperf3_flows(cfg, [dst1, dst2], OFFERED_MBIT // 2)) > + _check_rate(total, RATE_MBIT, "aggregate of shared action") > + > + > +@ksft_variants([ > + KsftNamedVariant("slow_first", 10, 20, RATE_MBIT // 2), > + KsftNamedVariant("fast_first", 20, 10, RATE_MBIT), > +]) > +def police_priority(cfg, slow_pref, fast_pref, expect): > + """ > + Check that of two rules with the same match, the one with the lower > + priority value decides, whichever of them is installed first. > + """ > + _setup_clsact(cfg) > + rule, dst = _dst_ip_rule(cfg) > + _check_baseline_rate(cfg) > + > + _add_filter(cfg, rule, _police(RATE_MBIT // 2), pref=slow_pref) > + added, err = _try_filter(cfg, rule, _police(RATE_MBIT), pref=fast_pref) > + if not added: > + _skip_rejected(cfg, err, fast_pref, "Second rule with the same match") > + > + got = _iperf3(cfg, dst, OFFERED_MBIT) > + _check_rate(got, expect, "rule with the lower pref") > + > + > def main() -> None: > """Ksft boilerplate main.""" > with NetDrvEpEnv(__file__, nsim_test=False) as cfg: [Severity: Medium] Can this check pass when one of the two rules is not forwarding anything? _iperf3_flows() is called with OFFERED_MBIT // 2, so each flow offers 100 Mbit/s. That is already the full RATE_MBIT of the shared policer. Only the sum of the two measured rates is compared against RATE_MBIT. Suppose the device mis-programs the second rule, the one created with "action police index N", and drops all of its traffic. The first flow alone then delivers about 100 Mbit/s, and _check_rate() is satisfied. The same holds the other way round. That looks like exactly the kind of breakage a shared-action test should catch. Would it make sense to also check that each value returned by _iperf3_flows() carries a meaningful share of the rate? Alternatively, each flow could offer less than RATE_MBIT * (1 - TOLERANCE). The policer is still oversubscribed in aggregate, but a single flow can no longer reach the limit on its own. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204000521.3396802-1-mohsin.bashr%40gmail.com