[PATCH net-next v2 7/9] tun: use napi_consume_skb() in tun_put_user
From: Jon Kohler
Date: Tue Nov 25 2025 - 14:19:28 EST
With build_skb paths now utilizing the local NAPI SKB cache, switch to
using napi_consume_skb() in tun_put_user. This ensures the local SKB
cache is refilled on read, improving memory locality and performance,
especially when RX and TX run on the same worker thread (e.g., vhost
workers). As napi_consume_skb() also performs deferred SKB freeing,
SKBs allocated on different CPUs benefit as well.
Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
Cc: Nick Hudson <nhudson@xxxxxxxxxx>
Signed-off-by: Jon Kohler <jon@xxxxxxxxxxx>
---
drivers/net/tun.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 27c502786a04..b48a66b39e0a 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2155,7 +2155,9 @@ static ssize_t tun_put_user(struct tun_struct *tun,
dev_sw_netstats_tx_add(tun->dev, 1, skb->len + vlan_hlen);
preempt_enable();
- consume_skb(skb);
+ local_bh_disable();
+ napi_consume_skb(skb, 1);
+ local_bh_enable();
return total;
--
2.43.0