Netdev List
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH net-next 07/11] selftests: drv-net: tc_flower_police: Test multiple policers
Date: Sat, 05 Dec 2026 00:15:32 +0000	[thread overview]
Message-ID: <179642973256.3146.13809553627644999013@kernel.org> (raw)
In-Reply-To: <20261204000521.3396802-8-mohsin.bashr@gmail.com>

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 <kuba@kernel.org>
> Signed-off-by: Mohsin Bashir <hmohsin@meta.com>

[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 <kuba@kernel.org>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Mohsin Bashir <hmohsin@meta.com>

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

  reply	other threads:[~2026-12-05  0:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  0:05 [PATCH net-next 00/11] selftests: drv-net: Test tc-flower police offload Mohsin Bashir
2026-12-04  0:05 ` [PATCH net-next 01/11] selftests: drv-net: Iperf3Runner: Support UDP and server side results Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 02/11] selftests: drv-net: Add tc-flower police offload test Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 03/11] selftests: drv-net: tc_flower_police: Test that rules do not leak Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 04/11] selftests: drv-net: tc_flower_police: Test the policed rate and its scope Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 05/11] selftests: drv-net: tc_flower_police: Test destination prefix rules Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 06/11] selftests: drv-net: tc_flower_police: Test police parameters Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 07/11] selftests: drv-net: tc_flower_police: Test multiple policers Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko [this message]
2026-12-04  0:05 ` [PATCH net-next 08/11] selftests: drv-net: tc_flower_police: Test rule removal Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 09/11] selftests: drv-net: tc_flower_police: Test policing across reconfiguration Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 10/11] selftests: drv-net: tc_flower_police: Test policing with ntuple steering Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko
2026-12-04  0:05 ` [PATCH net-next 11/11] selftests: drv-net: tc_flower_police: Test policing with RSS contexts Mohsin Bashir
2026-12-05  0:15   ` netdev-bot+sashiko

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=179642973256.3146.13809553627644999013@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mohsin.bashr@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /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