From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796174181; b=0BAmP46pFSZWW7sZFY9AhXFWUfPckrT3IdYntoUmRiiIDoENr81yIV4+MWiPsTCURDw9 58hD6UR5kZ09E6lAk9+TLhehVTtyZuRfIZOg2u/xTcj5gimTZNG8XQ19Jq+6CBJB1DSUZ RxZqp+IR+ghWfMg3WCdrHqImp0QK7C6kL2y2ngJgU5ZfGhesCDeMWPAWqdxB7wWAonF9X 4T1+1/1Hz9SeOlfyxWw5meQnR7+7Ufqx3obr1Zurj2ieY93BYjtYEReSPINcrs19oIWnq Edtzvzxz9tYpdxryAY5D+gGdfxSjs7j2iGsAEdbrPwm/PxtGMKbQTyPMtNu2axyrOGA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796174181; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=6Xhwp0GzBe/E9EV8pbxx9VKyBIAt3ForXqXPDFRh1iM=; b=iF0YO6wxCu34vBbDgYcIEYZxpH49hE6NWTIZlJgjPwJWwTW+ko66beWTksJeskjFpXeq SPQ9FB09Gyh+XY5kMKmYTwHFTiY6LhflgFESKTN8Ukhp2L0+g2xy5BKgOJAhFcgK8fwlm OSpAfFmDhGO8EwNB7zI11Rw6qo3Ue7oeeJf/efr/uHSkadTTINvewPJpUYzCwt0IlSOC/ hMaG/a0Kqj30hY2u7fOtdWyvnJwFgCRljauMHhDHOh6B/mQXRwKw/8i9ZDw3SzQKVxAF7 cZhwdT62HW2jLYAq8Wtio7ZNyDegmJH5P200eCKGO0eiH+Y6ge47AT+Y2Dl8C6DqjTA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fbbZBEny; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 361C1606A329 for ; Wed, 2 Dec 2026 01:16:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fbbZBEny Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC6F41F00896; Wed, 2 Dec 2026 01:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796174180; bh=6Xhwp0GzBe/E9EV8pbxx9VKyBIAt3ForXqXPDFRh1iM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=fbbZBEnyaaCMnKewIh+VdkKKaTpTCvJlKMx2ZVX5UTtDa7H9NYqmGFfvc4jybI6sm hlQ3Kg9RVC20FFqq8sqkGJ5noU/ItR7IKOjCK1whxF4vpKUrmLI260Xv17q27AvhP4 3mm1PZQUIv4Urc8RDbuDlI3x3HwqEGI6ng/0EkdkKx9hrsRDImcUwSTiV8Rfs0Wd8i pwUJh1Bh77ZXiyTSz4oKZC1gp7tkia2CO2Zi/TfmRuJY1373oLa5KDCS79sbknzMdD pCXozIR1hLinq6UPvEJgKPJ0YInJT0ZExOu8CeMuRDDX7EcQa/Ys7UjDNYAyFfymAn 9zg32u+olF3Ww== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH RFC net-next 10/12] net: enic: add AF_XDP zero-copy RX and TX Reply-To: sashiko-reviews@lists.linux.dev To: "Satish Kharat" Cc: bpf@vger.kernel.org In-Reply-To: <20261130-enic-xdp-rfc-p1-20261130-v1-10-3be5458c9118@cisco.com> References: <20261130-enic-xdp-rfc-p1-20261130-v1-0-3be5458c9118@cisco.com> <20261130-enic-xdp-rfc-p1-20261130-v1-10-3be5458c9118@cisco.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 01:16:20 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 6 potential issues to consider: - [High] net: enic: TX need_wakeup not restored across stop/open in enic_open() - [High] net: enic: RX stall in enic_open() when XSK fill ring is initially empty - [High] net: enic: list corruption in enic_rq_alloc_buf() via enic_xsk_buff_init() - [Medium] net: enic: per-descriptor lock and false wakeup in enic_rq_alloc_buf() - [Medium] net: enic: per-packet XSK_RX TX completion locking and enic_rq false sharing - [Low] net: enic: unconditional spin_lock_bh() in enic_xsk_rx_tx_flush() on RX poll -- commit 867968ead5e974fd4a4138cb6db78c85d73c1863 Author: Satish Kharat net: enic: add AF_XDP zero-copy RX and TX This commit adds AF_XDP zero-copy receive and transmit support to the enic driver, including UMEM pool setup, XSK RX buffer allocation and XDP action handling, zero-copy TX batching, and ndo_xsk_wakeup support. > diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/et= hernet/cisco/enic/enic_main.c > index 4c1ea75654bb0..d14bc66f4178e 100644 > --- a/drivers/net/ethernet/cisco/enic/enic_main.c > +++ b/drivers/net/ethernet/cisco/enic/enic_main.c [ ... ] > @@ -1982,9 +2002,11 @@ static int enic_open(struct net_device *netdev) > =20 > /* enable rq before updating rq desc */ > vnic_rq_enable(&enic->rq[i].vrq); > - vnic_rq_fill(&enic->rq[i].vrq, enic_rq_alloc_buf); > + err =3D vnic_rq_fill(&enic->rq[i].vrq, enic_rq_alloc_buf); > + enic_xsk_rx_refill_done(&enic->rq[i], err); > /* Need at least one buffer on ring to get going */ > - if (vnic_rq_desc_used(&enic->rq[i].vrq) =3D=3D 0) { > + if (!enic->rq[i].xsk_rx_active && > + vnic_rq_desc_used(&enic->rq[i].vrq) =3D=3D 0) { > netdev_err(netdev, "Unable to alloc receive buffers\n"); > err =3D -ENOMEM; > goto err_out_free_rq; [Severity: High] Can RX on queue i permanently stall when an XSK pool is bound without XDP_USE_NEED_WAKEUP and the fill ring is initially empty during enic_open()? When xsk_buff_alloc() returns NULL here, vnic_rq_fill() returns -ENOMEM with zero descriptors posted and enic_open() continues. Because xsk_uses_need_wakeup(erq->xsk_pool) is false, enic_rq_alloc_buf() does not set XDP_WAKEUP_RX in pool->cached_need_wakeup, and enic_open() never schedules enic->napi[i] after napi_enable(&enic->napi[i]). With no descriptors posted to the hardware RQ, no RX interrupt can fire. Userspace __xsk_recvmsg() sees (pool->cached_need_wakeup & XDP_WAKEUP_RX) =3D=3D 0 and skips ndo_xsk_wakeup, while xsk_poll() only passes XDP_WAKEUP_= TX, which in MSI-X mode schedules only the WQ NAPI. As a result, vnic_rq_fill() is never retried. Should enic_open() schedule enic->napi[i] after napi_enable() when vnic_rq_fill() fails and !enic_xsk_rx_need_wakeup(&enic->rq[i])? > diff --git a/drivers/net/ethernet/cisco/enic/enic_rq.c b/drivers/net/ethe= rnet/cisco/enic/enic_rq.c > index 350e42c556ade..f30de4757613d 100644 > --- a/drivers/net/ethernet/cisco/enic/enic_rq.c > +++ b/drivers/net/ethernet/cisco/enic_rq.c > @@ -282,6 +283,31 @@ int enic_rq_alloc_buf(struct vnic_rq *rq) > struct vnic_rq_buf *buf =3D rq->to_use; > struct page *page; > unsigned int truesize =3D len + headroom; > + struct xdp_buff *xdp; > + > + if (erq->xsk_rx_active) { > + xdp =3D buf->os_buf; > + if (!xdp) { > + /* Set before checking the fill ring so userspace cannot > + * miss need_wakeup when the ring is empty. > + */ > + if (xsk_uses_need_wakeup(erq->xsk_pool)) > + enic_xsk_set_rx_need_wakeup(erq); > + xdp =3D xsk_buff_alloc(erq->xsk_pool); > + if (unlikely(!xdp)) { > + rqstats->xsk_fill_empty++; > + return -ENOMEM; > + } > + enic_xsk_buff_init(xdp); > + } [Severity: High] Can enic_xsk_buff_init(xdp) corrupt rq->xsk_tx_done when the userspace fill ring contains duplicate chunk addresses in aligned UMEM mode? In aligned mode, xsk_buff_alloc() indexes directly into pool->heads[] by the chunk address from the fill ring, so duplicate fill-ring entries return the same struct xdp_buff pointer. If that buffer was previously transmitted via XDP_TX and completed onto rq->xsk_tx_done, a later vnic_rq_fill() popping the duplicate address reinitializes xskb->tx_done in place without unlinking it or holding rq->xsk_tx_done_lock: CPU0 (RQ NAPI) CPU1 (WQ NAPI) enic_poll_msix_rq() enic_xsk_rx_tx_flush() ... enic_free_wq_buf() enic_xsk_rx_tx_complete(xdp) list_add_tail(&xskb->tx_done, &rq->xsk_tx_done) vnic_rq_fill() enic_rq_alloc_buf() xdp =3D xsk_buff_alloc(...) enic_xsk_buff_init(xdp) INIT_LIST_HEAD(&xskb->tx_done) ... enic_poll_msix_rq() enic_xsk_rx_tx_flush() list_splice_init(&rq->xsk_tx_done, &done) list_for_each_entry_safe(...) <-- spins forever in softirq Overwriting xskb->tx_done.next to point to itself while linked on rq->xsk_tx_done causes list_for_each_entry_safe() in enic_xsk_rx_tx_flush() to loop endlessly when another entry follows xskb. [Severity: Medium] Does calling enic_xsk_set_rx_need_wakeup() before xsk_buff_alloc() on every descriptor acquire rq->xsk_wakeup_lock per packet and advertise a false XDP_RING_NEED_WAKEUP while the fill ring is non-empty? vnic_rq_fill() invokes enic_rq_alloc_buf() in a per-descriptor loop, so refilling N descriptors takes and releases spin_lock_bh(&rq->xsk_wakeup_loc= k) N + 1 times (including enic_xsk_rx_refill_done()), contending with enic_xsk_tx_service() on the WQ NAPI. It also leaves XDP_RING_NEED_WAKEUP set in shared fill-ring flags across the entire refill loop and its MMIO doorbell writes before enic_xsk_rx_refill_done() clears it, causing a concurrent userspace producer to issue unnecessary wakeup syscalls on a non-empty fill ring. Setting rx_need_wakeup only when xsk_buff_alloc() returns NULL (and rechecking xsk_pool_can_alloc() under the lock) would avoid both the per-descriptor lock and the transient wakeup flag. > diff --git a/drivers/net/ethernet/cisco/enic/enic_xdp.c b/drivers/net/eth= ernet/cisco/enic/enic_xdp.c > index dbb5f0e6c14f6..b6989a4dd79b3 100644 > --- a/drivers/net/ethernet/cisco/enic/enic_xdp.c > +++ b/drivers/net/ethernet/cisco/enic/enic_xdp.c [ ... ] > @@ -225,6 +282,345 @@ bool enic_xdp_run(struct enic *enic, struct enic_rq= *rq, [ ... ] > +bool enic_xsk_tx_service(struct enic *enic, unsigned int wq_index) > +{ [ ... ] > +out_need_wakeup: > + spin_unlock(&wq->lock); > + if (!done && xsk_uses_need_wakeup(pool)) { > + spin_lock_bh(&enic->rq[wq_index].xsk_wakeup_lock); > + xsk_clear_tx_need_wakeup(pool); > + spin_unlock_bh(&enic->rq[wq_index].xsk_wakeup_lock); > + } > + > + return done; > +} [Severity: High] Can clearing TX need_wakeup here permanently wedge AF_XDP TX if the interface goes through a stop/open cycle while the WQ NAPI is still polling? When enic_xsk_tx_service() posts a full batch (sent =3D=3D capacity), done = is false and xsk_clear_tx_need_wakeup(pool) clears XDP_RING_NEED_WAKEUP in the TX ring and XDP_WAKEUP_TX in pool->cached_need_wakeup because NAPI expects to keep polling. If a stop/open cycle then runs across all queues (for example via enic_xdp_reload_pool_swap() when binding or unbinding a pool on another queue, enic_xdp_reload(), or _enic_change_mtu()), __enic_stop() disables all NAPIs and cleans all in-flight WQ descriptors, and enic_open() re-enables the WQ NAPIs without restoring xsk_set_tx_need_wakeup(pool) or scheduling the WQ NAPI. After enic_open(), the WQ NAPI is idle with no descriptors in flight to raise a completion interrupt, and __xsk_sendmsg() and xsk_poll() see (pool->cached_need_wakeup & XDP_WAKEUP_TX) =3D=3D 0 and never call ndo_xsk_wakeup. Restoring xsk_set_tx_need_wakeup(pool) (or scheduling the WQ NAPI) for bound pools during enic_open() would prevent this stall. > + > +static void enic_xsk_schedule_napi(struct napi_struct *napi) > +{ > + if (!napi_if_scheduled_mark_missed(napi)) > + napi_schedule(napi); > +} > + > +void enic_xsk_rx_tx_complete(struct enic *enic, struct xdp_buff *xdp) > +{ > + struct enic_xsk_buff *xskb =3D enic_xsk_buff(xdp); > + unsigned int rq_index =3D xdp->rxq->queue_index; > + struct enic_rq *rq; > + > + if (WARN_ON_ONCE(rq_index >=3D enic->rq_count) || > + WARN_ON_ONCE(!list_empty(&xskb->tx_done))) > + return; > + > + rq =3D &enic->rq[rq_index]; > + spin_lock_bh(&rq->xsk_tx_done_lock); > + list_add_tail(&xskb->tx_done, &rq->xsk_tx_done); > + spin_unlock_bh(&rq->xsk_tx_done_lock); > + > + if (READ_ONCE(enic->xsk_wakeup_enabled) && > + vnic_dev_get_intr_mode(enic->vdev) =3D=3D VNIC_DEV_INTR_MODE_MSIX) > + enic_xsk_schedule_napi(&enic->napi[rq_index]); > +} [Severity: Medium] Can VNIC_WQ_BUF_XSK_RX completions be batched in enic_wq_service() the way VNIC_WQ_BUF_XSK completions are? Right now enic_free_wq_buf() calls enic_xsk_rx_tx_complete() on every completed descriptor while holding wq->lock, so each packet individually acquires spin_lock_bh(&rq->xsk_tx_done_lock) and performs an atomic cmpxchg on enic->napi[rq_index].state via enic_xsk_schedule_napi(). In addition, struct enic_rq places xsk_wakeup_lock, xsk_tx_done_lock, and xsk_tx_done right after the cacheline-aligned struct xdp_rxq_info xdp_rxq (64 bytes), putting those WQ-modified locks on the same cacheline as the read-mostly RX flags xdp_enabled, xsk_rx_active, and xdp_flush_pending. > + > +void enic_xsk_rx_tx_flush(struct enic *enic, unsigned int rq_index) > +{ > + struct enic_rq *rq =3D &enic->rq[rq_index]; > + struct enic_xsk_buff *xskb, *tmp; > + LIST_HEAD(done); > + > + spin_lock_bh(&rq->xsk_tx_done_lock); > + list_splice_init(&rq->xsk_tx_done, &done); > + spin_unlock_bh(&rq->xsk_tx_done_lock); > + > + list_for_each_entry_safe(xskb, tmp, &done, tx_done) { > + list_del_init(&xskb->tx_done); > + xsk_buff_free(&xskb->xdp); > + } > +} [Severity: Low] Should enic_xsk_rx_tx_flush() return early when list_empty(&rq->xsk_tx_done) before taking spin_lock_bh(&rq->xsk_tx_done_lock)? enic_poll() and enic_poll_msix_rq() call enic_xsk_rx_tx_flush() on every positive-budget RX NAPI poll, so without an unlocked list_empty() check every RX poll pays an atomic lock/unlock and BH disable/enable even when AF_XDP is not in use. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-enic-xdp-r= fc-p1-20261130-v1-0-3be5458c9118@cisco.com?part=3D10