From nobody Thu Apr 30 17:47:44 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4g61pm5vS5z6bvsJ for ; Thu, 30 Apr 2026 17:47:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g61pm2wGNz3mG6 for ; Thu, 30 Apr 2026 17:47:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777571264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iP26oUIEiAA0dfxwgAbeG7Tf+HnjJkl+3pfAeRlH/5w=; b=OjRC4ykrVzUnl8vwuw+t0qegPSs47nXL5odtae4/bv1oTmP1a6qPxROLNDamKOsuFARUY5 04E1WJRrY8r1olaB/TXjnQqsJjgAJ3g5jsIELGpxlv+5mPAD2F8Pa43LEq9LeewjY6QHUu Gp2FlnyJ14SyKfPqACWpr4b455aopElJQpye7l9CB7zDTrlIJdkWOmw/UAWW4OyNqHH4t+ U3atAsBgpkeWx9Mpls7JsnTqo62Qb3hPw6JN/995H62dFtshH30pIjedrx4ogQXOvpbtwP 6Mz/bQOGUHV7+70f/y/OhgdvIsR/WtPKQeiFemqfRiUe26RSnwegzjR+6xTr8Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1777571264; a=rsa-sha256; cv=none; b=gqn0z+jllXIyYvKygyqTVsfl1KAZX+qVi0xnxQl/jhX8Ac/DCn0GKLMZ6zqBSRYnHYgnMO AzslvETarh+xDXlkoBIKEJdCCWuFxedvJvRkqFzyXOyO49GoVAwrnFpUkARNumM4O/RqnR NrE8DGjGpSyuUMFaBpZ/1TVG5STsvVaoylQwh22NxllT990QN0B+3QhxnNSp3WKPPCuiU5 i0bdpFmU5v2ejdVTrqnDfLPZsI91gyl5ajuoGAHfGpOH9WIXu5oJqyHS/wg5rVp9OGvbCh qWTNp3jFtfGujeCAMbqDzD9gzNX2rKnDJGIy7BKk0zEVarnOEekfrWSs/sCHsg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777571264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iP26oUIEiAA0dfxwgAbeG7Tf+HnjJkl+3pfAeRlH/5w=; b=pF60Z0oBL1qeUJEnCJedBLxJH4fTXJstYMjXC1jb6DWfBfXeLa9xwgQVdBEoZU50RtRp8t JcuJ6+1WwcxHLjvxrcP2N/rzhACjvKhz8oams5bG1OBrLDpazOOJyF/Ew/qAA4B5r8h7sy jafWk8GPuwF0Y4oBrFYso6+glKGEwC9pa1HORyxpnJuo6JZ0RxZnGNSYvAMZ110E/LwnGB gzhjDJOaSfc8bF6Og/ha2tt0N+AnsmU6CEL4xSm01Sy13QXBLOYx1j2HGP3RTKTpnlQqDh wmeYasw1MzmrhcRA8m30pXK9aLHnKaSw2hu8W7LzoTBQLPui4uaOTnx6HWsP0Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g61pm2S8qz6Cm for ; Thu, 30 Apr 2026 17:47:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 31475 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 30 Apr 2026 17:47:44 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Colin Percival Subject: git: b9a0298dda58 - stable/15 - ena: Budget rx descriptors, not packets List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: b9a0298dda58ff456add26e7cdbc0f99d48e060b Auto-Submitted: auto-generated Date: Thu, 30 Apr 2026 17:47:44 +0000 Message-Id: <69f395c0.31475.5d67034f@gitrepo.freebsd.org> The branch stable/15 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=b9a0298dda58ff456add26e7cdbc0f99d48e060b commit b9a0298dda58ff456add26e7cdbc0f99d48e060b Author: Colin Percival AuthorDate: 2026-04-17 17:40:00 +0000 Commit: Colin Percival CommitDate: 2026-04-30 17:47:07 +0000 ena: Budget rx descriptors, not packets We had ENA_RX_BUDGET = 256 in order to allow up to 256 received packets to be processed before we do other cleanups (handling tx packets and, critically, refilling the rx buffer ring). Since the ring holds 1024 buffers by default, this was fine for normal packets: We refill the ring when it falls below 7/8 full, and even with a large burst of incoming packets allowing it to fall by another 1/4 before we consider refilling the ring still leaves it at 7/8 - 1/4 = 5/8 full. With jumbos, the story is different: A 9k jumbo (as is used by default within the EC2 network) consumes 3 descriptors, so a single rx cleanup pass can consume 3/4 of the default-sized rx ring; if the rx buffer ring wasn't completely full before a packet burst arrives, this puts us perilously close to running out of rx buffers. This precise failure mode has been observed on some EC2 instance types within a Cluster Placement Group, resulting in the nominal 10 Gbps single-flow throughput between instances dropping to ~100 Mbps as a result of repeated rx overruns causing packet loss and ultimately retransmission timeouts. To correct this, switch from processing up to ENA_RX_BUDGET (256) packets to processing up to ENA_RX_DESC_BUDGET (256) descriptors (or slightly more, if we hit the limit in the middle of a packet). This ensures that, even with jumbos, we refill the ring before processing most of a ring worth of descriptors, and returns the throughput to expected levels. Note that theoretically up to ENA_PKT_MAX_BUFS (19) descriptors can be used for a single packet, in which case even 54 packets would exhaust the default rx buffer ring; it's not clear if this ever occurs in practice, but this fix will address that case as well. Reviewed by: akiyano Sponsored by: Amazon MFC after: 6 days Differential Revision: https://reviews.freebsd.org/D56479 (cherry picked from commit 0f7b8f79f67b25cb0727c7b7d604eb1eec91fef1) --- sys/dev/ena/ena.h | 4 ++-- sys/dev/ena/ena_datapath.c | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/dev/ena/ena.h b/sys/dev/ena/ena.h index f67c7002327d..b2156437f847 100644 --- a/sys/dev/ena/ena.h +++ b/sys/dev/ena/ena.h @@ -99,8 +99,8 @@ * of TCP retransmissions. */ #define ENA_TX_BUDGET 128 -/* RX cleanup budget. -1 stands for infinity. */ -#define ENA_RX_BUDGET 256 +/* RX cleanup budget, in descriptors. -1 stands for infinity. */ +#define ENA_RX_DESC_BUDGET 256 /* * How many times we can repeat cleanup in the io irq handling routine if the * RX or TX budget was depleted. diff --git a/sys/dev/ena/ena_datapath.c b/sys/dev/ena/ena_datapath.c index ab7b8a468c30..23cbf62b5143 100644 --- a/sys/dev/ena/ena_datapath.c +++ b/sys/dev/ena/ena_datapath.c @@ -575,7 +575,7 @@ ena_rx_cleanup(struct ena_ring *rx_ring) uint32_t do_if_input = 0; unsigned int qid; int rc, i; - int budget = ENA_RX_BUDGET; + int budget = (ENA_RX_DESC_BUDGET == -1) ? INT_MAX : ENA_RX_DESC_BUDGET; #ifdef DEV_NETMAP int done; #endif /* DEV_NETMAP */ @@ -684,7 +684,14 @@ ena_rx_cleanup(struct ena_ring *rx_ring) counter_u64_add_protected(rx_ring->rx_stats.cnt, 1); counter_u64_add_protected(adapter->hw_stats.rx_packets, 1); counter_exit(); - } while (--budget); + + /* + * Adjust our budget; note that we count descriptors, not + * packets, since we need to ensure we don't run out of rx + * buffers when receiving jumbos. + */ + budget -= ena_rx_ctx.descs; + } while (budget > 0); rx_ring->next_to_clean = next_to_clean; @@ -699,7 +706,7 @@ ena_rx_cleanup(struct ena_ring *rx_ring) tcp_lro_flush_all(&rx_ring->lro); - return (budget == 0); + return (budget <= 0); } static void