Re: [PATCH net v2] net: fix __this_cpu_add() in preemptible code in dev_xmit_recursion_inc/dec

Jakub Kicinski
2026-04-12T16:33:49Z

On Fri, 10 Apr 2026 10:06:30 +0800 Jiayuan Chen wrote:
> dev_xmit_recursion_{inc,dec}() use __this_cpu_{inc,dec}() which requires
> the caller to be non-preemptible in order to avoid cpu migration. However,
> some callers like SCTP's UDP encapsulation path invoke iptunnel_xmit()
> from process context without disabling BH or preemption:
>
> sctp_inet_connect -> __sctp_connect -> sctp_do_sm ->
> sctp_outq_flush -> sctp_packet_transmit -> sctp_v4_xmit ->
> udp_tunnel_xmit_skb -> iptunnel_xmit -> dev_xmit_recursion_inc

Eric, weren't there also a bunch of RCU reports because of this path?
Should we perhaps take the RCU read lock here?

> + guard(migrate)();

Sorry but I detest the guard() usage. Please use migrate_disable()

Quoting documentation:

Use of ``guard()`` is discouraged within any function longer than 20
lines, ``scoped_guard()`` is considered more readable. Using normal
lock/unlock is still (weakly) preferred.