Re: [PATCH net-next v3 3/3] amt: make the per-tunnel group and source limits configurable

From: Omar Ramadan

Date: Tue Nov 24 2026 - 02:26:05 EST


On Mon, 23 Nov 2026 23:57:44 +0000, netdev-bot+sashiko@xxxxxxxxxx wrote:
> Do these new ceilings also raise the per-packet work a remote gateway can
> cause under tunnel->lock by roughly 32x?

Yes. At 512 groups and 4096 sources the budget of 2/3 allowed 3,850,240
bucket and source visits per Update, 32 times the 120,320 at the
defaults, and the caps were argued from memory only.

v4 caps the budget at what one report as large as the device's MTU can
cost: a host splits its report to the MTU, so a report names at most
mtu / 8 groups. On a 1500-byte stream link (relay MTU 1460) that is
416,256 visits at the ceilings, 3.5 times the default; the largest
legitimate report there costs about 348,000. The defaults keep the 120,320. A report
larger than the relay's own MTU, from a gateway on a jumbo link to a
relay on a standard one, has the records past the bound ignored at high
limits; the commit message says so.

Measured in a UML guest (KASAN off, so only the ratio means anything),
v3 and v4 booted alternately on one machine, at the ceilings: the
report you describe, ~7,500 empty records naming one group that holds
4,096 sources, takes 8.2-8.9 ms in v3 and 1.3-1.6 ms in v4 on a
1500-byte stream link (119 records applied against 13), and 5.3-5.7 ms
with the stream link at 65535. A full refresh is not slower.

Teardown at the ceilings walks 512 * 256 bucket heads in v4, once per
tunnel.

> With hash_buckets at AMT_HSIZE_MAX, do the per-group and per-tunnel
> allocations end up just over 4 KiB?

Yes. v4 keeps hash_buckets at AMT_HSIZE (256): pahole gives 200 bytes
for amt_group_node and 168 for amt_tunnel_list, so with 256 heads both
stay in kmalloc-4k. At 4096 sources in one group a chain averages 16
entries, which only makes a lookup longer. One tunnel at the ceilings
then holds about 2 MiB of group nodes and 0.75 MiB of source nodes, and
max_tunnels multiplies that; v4's comment on the caps says so instead
of "a few MiB".

I will send v4.

pw-bot: cr

--
Omar