Re: [PATCH net-next] net: lwtunnel: use GFP_KERNEL in build_state paths

From: Ido Schimmel

Date: Sun Nov 08 2026 - 09:23:26 EST


On Fri, Nov 06, 2026 at 12:40:55PM +0100, Max Boone wrote:
> Since 3d25eabbbf67 ("ip_tunnel: Add dst_cache support in lwtunnel_state
> of ip tunnel"), build_state runs outside RCU and all its callers can
> sleep, but paths still use GFP_ATOMIC.
>
> For dst caches, that limits allocation to populated percpu pages. A
> large burst of SRv6 nexthops outruns the refill worker and will fail
> with -ENOMEM despite there being free memory:
>
> percpu: allocation failed, size=40 align=8 atomic=1, atomic alloc
> failed, no space left
>
> Batching 20000 RTM_NEWNEXTHOP under QEMU gave 10-109 failures per run
> before, none after.
>
> This commit converts the allocations reached through ops->build_state()
> and are called after the rcu_read_unlock():
>
> - ila_build_state(), ioam6_build_state(), rpl_build_state(),
> seg6_build_state(): build_state ops
> - bpf_parse_prog(): only called from bpf_build_state()
> - lwtunnel_state_alloc(): only called from build_state ops (also
> affects mpls, ip/ip6 tunnel, xfrmi and seg6_local)
>
> Signed-off-by: Max Boone <mboone@xxxxxxxxxx>
> Reviewed-by: Debabrata Banerjee <dbanerje@xxxxxxxxxx>
> Reviewed-by: Nick Hudson <nhudson@xxxxxxxxxx>

Reviewed-by: Ido Schimmel <idosch@xxxxxxxxxx>