mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/3] amt: configurable per-tunnel limits, with bounded report work
@ 2026-11-22 23:57 Omar Ramadan
  2026-11-22 23:57 ` [PATCH net-next v3 1/3] amt: make the A-B source walk linear Omar Ramadan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Omar Ramadan @ 2026-11-22 23:57 UTC (permalink / raw)
  To: Taehee Yoo, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, Simon Horman

A relay caps one gateway tunnel at 32 group and 128 source records, both
compile-time constants. v2 made them configurable [1]. Sashiko and Paolo
pointed out that at the new ceilings a single Membership Update can
livelock the host: records are applied under tunnel->lock in softirq,
and only the packet length bounds them [2].

This version keeps the processing in the RX path and bounds it instead:

1/3 makes the A-B case of amt_lookup_act_srcs() linear. It used to
    compare every source in the group with every source in the record.
2/3 charges every group record for the passes it makes over its group
    and stops applying records once a report exceeds twice the cost of
    refreshing the tunnel's whole state. A record for a group the
    tunnel has no room for does no walk and is not charged, so a host
    joined to more groups than max_groups keeps its refreshes.
3/3 is v2, with the source hash sized from max_sources and the group
    ceiling lowered from 1024 to 512, which keeps one tunnel's worst
    case at about 4.75 MiB.

Measured cost of one Membership Update, in a UML guest (KASAN off, so
these are slower than native and only comparable with each other), at
the ceilings, three runs each. These were taken on 734bef548a96 with
v5 of the net series (an earlier version of [3]), before this series
was rebased onto net-next, and with an earlier 2/3 that also charged
records the tunnel refuses, a path neither row reaches. They have not
been re-run since [measured]:

  report                                   v2 ceilings      this series
  512 groups x 8 sources, full refresh     5.0 - 11.9 ms    4.9 - 10.3 ms
  ~7,500 empty records naming one group
  that holds 4,096 sources (64 KiB)        1.74 - 2.32 s    26 - 45 ms

The second row is the livelock: one datagram held tunnel->lock for about
two seconds. With 2/3 the report stops after its budget of 3.85M bucket
and source visits [estimated, from the code], about 120K at the default
limits. I did not manage to drive the quadratic A-B walk itself into a
measurement; its old worst case is |A| x |B|, up to 4,096 x 14,998
compares for one record [estimated].

Deferring report processing to a per-tunnel work item would also take
the work out of softirq. I have not done that here: with the work
bounded, the deferral would add a queue and its own limits without
changing the worst case much. Happy to do it if you prefer.

This depends on the net series "amt: relay tunnel lifetime, validation
and request-path hardening" [3], which fixes the source-timer vs.
teardown race Sashiko also flagged: 3/3 touches amt_newlink() next to
a line that series adds. That series is now in net-next, and this is
based on 24630ff92eff, the net-next merge of net that brought it in.

Testing: tools/testing/selftests/net/amt.sh, unmodified, on net-next
24630ff92eff with this series applied, x86_64 under virtme-ng/KVM (4
vCPUs, 4 GiB) with generic KASAN (inline), PROVE_LOCKING, PROVE_RCU and
AMT=y: all six tests pass, amt.sh exits 0, and no KASAN, lockdep or
WARNING report appeared during the run. amt.sh does not reach the new
limits, so this covers the normal paths only; the over-budget path of
2/3 is covered only by the measurements above, taken before the rebase.
Each patch builds with W=1 C=1, with IPv6=y and IPv6=n, with no new
warnings.

[1] https://lore.kernel.org/netdev/20261015231825.2852054-1-omar@blockcast.net/
[2] https://lore.kernel.org/netdev/361bbccf-6ce7-4b1f-bd55-4d8270423320@redhat.com/
[3] https://lore.kernel.org/netdev/20261110210538.217936-1-omar@blockcast.net/

v3:
- New 1/3 and 2/3.
- Based on net-next after the net series [3] was merged; 3/3 rebased
  onto it.
- 3/3: size hash_buckets from max_sources, at most 8 sources per
  bucket, 256..512; lower AMT_MAX_GROUP_LIMIT from 1024 to 512.
v2: https://lore.kernel.org/netdev/20261015231825.2852054-1-omar@blockcast.net/
v1: https://lore.kernel.org/netdev/20261014221334.2443184-1-omar@blockcast.net/

Assisted-by: LLM

Omar Ramadan (3):
  amt: make the A-B source walk linear
  amt: bound the source-state work of one Membership Update
  amt: make the per-tunnel group and source limits configurable

 drivers/net/amt.c        | 118 +++++++++++++++++++++++++++++++--------
 include/net/amt.h        |  15 +++++
 include/uapi/linux/amt.h |   8 +++
 3 files changed, 117 insertions(+), 24 deletions(-)


base-commit: 24630ff92eff08500ec4772728d4b1fa08c28f47
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-22 23:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22 23:57 [PATCH net-next v3 0/3] amt: configurable per-tunnel limits, with bounded report work Omar Ramadan
2026-11-22 23:57 ` [PATCH net-next v3 1/3] amt: make the A-B source walk linear Omar Ramadan
2026-11-22 23:57 ` [PATCH net-next v3 2/3] amt: bound the source-state work of one Membership Update Omar Ramadan
2026-11-22 23:57 ` [PATCH net-next v3 3/3] amt: make the per-tunnel group and source limits configurable Omar Ramadan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®