From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794771350; b=1DdLf5DjETbck3hDOG5k+3oOO0Pw46sUktqD2YCpfkCcamz7kLiN4SggxgKecDFQ2PIr 5qlEbjNnV7AKlS6URLaVU3EzAYKaNetCBHZcBiSlH1ia4Eygny8eTJIKMgFjAkKB3/K+q qe3WlBMhdDPS34e/kIiIFGThWdZTSzGIS12TEytpribMsL7eOgScDKUQJqhkYHcQwl/3s JQGZzxeeUhB4rxR+p7A8yV9TpgBDfXc4ohO1yupgdBliUIH29rvAWt12x6kjtZKS40PLG 7fCrdp/M2uEct4r9R0ZbdJWQQ0c6Gq55UryOsRGgOba2CtoymbsMRSHg1shwc24Kt1Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794771350; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=j+9Eww07QSnuPfPdAGrAWpz3n8x4NlApyIViVNGE2Rs=; b=alBH/IVDF9rTitR3WnuzVXCxhWOcjUVr86T0P1Mhl3Q22Aw3ZpMzgsE8/KInneB7X8cl Bnw+Duwyu7UDaj9qFHsjCH8TGdOqqWipJJZl/EvSHPHeH+Pt4JflGGiCYy6o6hBTOeBCH 91CvMSz+IquzR9TeHPXpl5TnK2FbR4glqv/FhUBTnqCXaPDAGldXTFOQA3aJKKPtlaPOT 8zGWMywc7xUxXtGEa36WzLTxXnnBOYNRtEbqJunf3NvSmfdvkV53QHmsYAcLXnLxhHbrk YvNAuo70i8egK/KoTvkIPGuPVTMBk45b7VOZVD0EsdZqxOhPwleHHbnHobigXc4llUQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass header.d=cloudflare.com header.i=@cloudflare.com header.a=rsa-sha256 header.s=google09082023 header.b=HXSN4Aab; arc=none smtp.remote-ip=209.85.218.46 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3FAC606A889 for ; Sun, 15 Nov 2026 19:35:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A3FAC606A889 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.a=rsa-sha256 header.s=google09082023 header.b=HXSN4Aab Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-c4d28f75d62so552458266b.0 for ; Sun, 15 Nov 2026 11:35:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1794771340; x=1795376140; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=j+9Eww07QSnuPfPdAGrAWpz3n8x4NlApyIViVNGE2Rs=; b=HXSN4AabSc0xFbzvP3lfjK3rXrzpQizGnweDKmW78qPo4LF3MLDWwN7erZKotV1GZS WPfaCjmK0Ijkkl+CtI2sZ/7tiuOzujdsIfgKzfSGnM+ksmsqCZTVApKVezMZZ7RIM7vv oBx2hC2ZgglhxWpdMrTdy/p7P/eYGmnlxJp7neuu/H/i/6lDYYfzPAfDq2ony1QimRuf uJuVdpS8ihHU+dqEXq92fbsDvvyVvSBTyoH886nzvz39gnp0+ppVgwVSLgJYoCqxEjG4 A9uyMMOFntHqgZ2S9EQsFmu6xxqf6mR6m1r69iLRspoV2bZdMHeCD+0GNAtesU2u91pt dVdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794771340; x=1795376140; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=j+9Eww07QSnuPfPdAGrAWpz3n8x4NlApyIViVNGE2Rs=; b=XXRqJyxnPKytwDeJCTSCxpUogdB2w2Z7Hc5VxmYKaRqMASdtw0fG4BVpzsgk7vPZfw FOMi3+E/pc/b6bWS8S4p/I27EnrE8hJpNXdTpQUbWByaJyKfKS6lHnBozPtB+x+aGLQX HDeDzSm+RtgWIB6skRiTAHbtwGCVx21mShvm42oE3NngKJeIVhi/S3fhYLxX5/59rs/j Bf0rpwCKiPTZtj9UTNieC6H3NbGc4DCiJ7qFGpamsMK1UUx1NvnQX4EXq7enmRp/J3fu 92ZxWpxVnBz6F08H0I6bwgHF3RSpp1ktIRCtHGNiO4FKXK+KOIabZyzmaNAmrqhWLqyi cYMA== X-Gm-Message-State: APuU4Z9UmX0nllFPUivq2xwqcX0HiK05l/6CAlMpn/yNGvVFWMEYGTZz 61uSMaAJFVaVQclHteo8s32MuKe6ypMBXIHRyWgp+9c6LwCJcQ3EJzFNro/i//NeuRFhqLy9Ikj yoy/mzKc= X-Gm-Gg: AYBFou2vsnMciyPUBikkKPXFWqwn21zkrxkaSAo5Ckxrppevi9cVpNTyWekTnfAGO9P NS/0MVwCauilxAJbsz/4uz6BU8/SUTKGhQAgs/pxF78QbrMKEl2BU7MXjENTnj96+MZK99DZVt+ mV46KwiZCAwGuKyeoO3vpFzWVsUCI740GPTa2fpa2djEe+QIfvj0YsfNQ3JZJun/xPrBkQhgTGl /N4HFkKEOIv5P1ce/HKuntPWDPscukX5G4p6mvYFn1M1v07r5PppzkWMgvoxfN1MHY0olokGeWk tBcKtVEWPyzPmroP8TF7l6jolgM1UyVJDC6We/JhsXVxokDg/yvNLbeezyD8PWI263lk7u49zmh tY4Le+aAKwKCCQG2rdf+iwkFTFJQEjyXgYU9pdDLVxsSHLKhncDbtAHJ+TAvWX07JHcXiBKnHp0 IIJBzkUGWh/HqtHpDlY+SoQeg0iLhXPyPHjQ2jeVUc2Gak2QHnt83frx/40UdMZtlnJ89uZzHxP Hwhkj/Nup4vpo+IBVcd1U3AXIJI2eXvO6FgltELEpz15N5Uo5ApSYFwhTNFAv7s0JDQNxAUpQKL 6Juacl+4+Xi7IHzm8/ahxlRNM4CfTSuUmrEEBx3vzwj2wdoEtsLIa1d3pg== X-Received: by 2002:a17:907:2d1e:b0:c4d:28ba:f221 with SMTP id a640c23a62f3a-c50963d46dfmr689355666b.42.1794771340127; Sun, 15 Nov 2026 11:35:40 -0800 (PST) Received: from L9JK9NPFH9 ([104.28.20.57]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c5095b24b88sm340448766b.16.2026.11.15.11.35.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 15 Nov 2026 11:35:39 -0800 (PST) From: Tianyi Gao To: netdev@vger.kernel.org Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, toke@redhat.com, lorenzo@kernel.org, horms@kernel.org, shuah@kernel.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, joe@dama.to, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, kernel-team@cloudflare.com, tianyi.gao@linux.dev, Tianyi Gao Subject: [PATCH net-next v3 2/5] veth: link RX queues to their NAPI instances Date: Sun, 15 Nov 2026 19:35:28 +0000 Message-ID: <20261115193531.57679-3-tianyi@cloudflare.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261115193531.57679-1-tianyi@cloudflare.com> References: <20261115193531.57679-1-tianyi@cloudflare.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit veth does not link its RX queues to their NAPI instances. queue-get therefore reports no napi-id for them. napi-get lists the NAPI instances of a veth, and their thread PIDs when NAPI is threaded. It does not show which RX queue each instance polls. Userspace cannot tell which NAPI thread to pin for a given queue, or which NAPI to change with napi-set. There is also no way to busy poll an AF_XDP socket bound to a veth queue. Since commit b95ed5517354 ("xsk: Bring back busy polling support in XDP_COPY"), xsk_bind() takes the NAPI ID of a copy-mode socket from rxq->napi. veth never sets rxq->napi, so the socket gets no NAPI ID. Call netif_queue_set_napi() after napi_enable(), which assigns the NAPI ID. Call it again with NULL before napi_disable(). veth is not ops locked, so netif_queue_set_napi() requires RTNL. veth enables and disables NAPI only in ndo_open, ndo_stop, ndo_bpf, ndo_set_features and ethtool's set_channels. All of them are called under RTNL. Suggested-by: Jesper Dangaard Brouer Signed-off-by: Tianyi Gao --- drivers/net/veth.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 3cbedb8bad53..470c4f95e4a1 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1064,6 +1064,8 @@ static int veth_napi_enable_range(struct net_device *dev, int start, int end) rcu_assign_pointer(rq->xdp_prog, priv->_xdp_prog); napi_enable(&rq->xdp_napi); + netif_queue_set_napi(dev, i, NETDEV_QUEUE_TYPE_RX, + &rq->xdp_napi); rcu_assign_pointer(priv->rq[i].napi, &priv->rq[i].xdp_napi); } @@ -1096,6 +1098,7 @@ static void veth_napi_del_range(struct net_device *dev, int start, int end) struct veth_rq *rq = &priv->rq[i]; rcu_assign_pointer(priv->rq[i].napi, NULL); + netif_queue_set_napi(dev, i, NETDEV_QUEUE_TYPE_RX, NULL); napi_disable(&rq->xdp_napi); rcu_assign_pointer(rq->xdp_prog, NULL); __netif_napi_del(&rq->xdp_napi); -- 2.56.0