From nobody Tue Nov 10 15:51:46 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 4jPB3Q3nZnz6yfwq for ; Tue, 10 Nov 2026 15:51:46 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jPB3Q3J0Kz4V7r for ; Tue, 10 Nov 2026 15:51:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794325906; 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=OPwUmxFPohMzQEZrjUcOvCFXVcfE6aRHQ8CqJyt3WZk=; b=NpJFOITKqZLWAANtPhbOnRmEWerX4nMlbAoDujqKzRckERGLUTUkG/LtuMpZIDWjmO8XlQ nysVH3HRN+A2bHAmpNrtQQUe+EFdDos6Z8uCijrekDwfwW1VSnBT30DAjLUfW0Dk1aBTsN Q6/eLZ6CZHIiDYmXvcgU07RaNnoPj61lFvYSJYykgGOpcMtIJif8DOqU1GS4XzjzdIgeWa HB9tA0issNOf9V0EjlrTttV6MCMAL4GRmwUQSkRN2IzXlld3vRCsM3cvCRbc0bM9BvKOwL DYHOM5ocU8j7hSxASIxj9HLVvCSxtiCI2dzLZk5YhkI/HaPs5k/dVQrZChWtdA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794325906; b=blgWRtuTVu1CuBVAmazkAl6aS6b95gxS5nJ+vWRlPwoSKMBFqWIRbpVIuauQWdE9tQvvya /Soy12WptQwZpF1QP5F5zgHB3h5TWVlgMsfytzmkUi2wWsfNGHtETnzsa+JtoL+XMJI4h+ mcvECUhEVMdCXgE1jWP8h4MsdQth8TKAxHZgHDtpqsC4WikA/mMjx/O1KJmcWlTkV1WjrX /44jiTgVDI4jYKJbGDs86klHML6oQIzP5iXFlE7+n2TVrzBQee1jXP9KYANd8wzEsCq51C ekgFhJvGGWQMWC/82nOna5TQRkwVMx6R18t4tcANYNPS3Dd3uXj8S2MB45WFdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794325906; 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=OPwUmxFPohMzQEZrjUcOvCFXVcfE6aRHQ8CqJyt3WZk=; b=dd6jDN8fWLmG7rhD8cBcbM75d2PicAohvIcFdGJXDuKBS2OewKcvT5ZGNil7ht8ifQo+qn Uc+UD9hdkuRhWh2BYzwMKeIALGcjfG1fI0Wc+PrE5EfcJtn+JcO08nGuBk3ufUcOTWtWQy IE5PALb+Mr2CWKODFjXhLWTH2S2Xs2C+UfRL948Jbw7h4+DgZHXpss6kHHejm397brbwt/ 2KWq+2+ktIPOjy0qYn1WGccVCm9DY20m0q+Bdz6nuJv1rTwiNqEPAB6JFXi5uT4arN8jKR NrrWazBsB0CwNWMR8vSq9cLqUFARPReqswNUlhP09aKYmUqJWKPZsjkRlsgybA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jPB3Q2yKHzbR6 for ; Tue, 10 Nov 2026 15:51:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 7b76 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 10 Nov 2026 15:51:46 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Gallatin Subject: git: 44df82b11c53 - main - iflib: simplify TXQ_AVAIL List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gallatin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 44df82b11c535ae50b1e5888a361a2bd15d4182b Auto-Submitted: auto-generated Date: Tue, 10 Nov 2026 15:51:46 +0000 Message-Id: <6af33d92.7b76.c90bc45@gitrepo.freebsd.org> The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=44df82b11c535ae50b1e5888a361a2bd15d4182b commit 44df82b11c535ae50b1e5888a361a2bd15d4182b Author: Andrew Gallatin AuthorDate: 2026-11-10 15:37:00 +0000 Commit: Andrew Gallatin CommitDate: 2026-11-10 15:37:00 +0000 iflib: simplify TXQ_AVAIL Simply the TXQ_AVAIL() macro to avoid using get_inuse(txq->ift_size, txq->ift_cidx, txq->ift_pidx, txq->ift_gen) and instead define it in terms of txq->ift_in_use. Note that in_use is equivalent, because it is updated at the same time as cidx/pidx and gen, and under the same serialization. The advantage is that its cheaper due to using one read and no branches, and safer, since unlocked reads get an atomic snapshot of availability, but an unlocked read of multiple counters can produce inconsistent results. Reviewed by: kbowling, kgalazka Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D61279 --- sys/net/iflib.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 8ab5ecb32b4e..7f1e16b183ac 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -409,7 +409,7 @@ struct iflib_txq { qidx_t ift_cidx; qidx_t ift_cidx_processed; qidx_t ift_pidx; - uint8_t ift_gen; + uint8_t ift_spare0; uint8_t ift_br_offset:1, ift_defer_mfree:1, ift_sparse_check:1, @@ -475,7 +475,7 @@ struct iflib_txq { uint16_t ift_wdog_armed; uint8_t ift_closed; uint8_t ift_update_freq; - uint8_t ift_spare0[2]; /* pad to the next pointer boundary */ + uint8_t ift_spare1[2]; /* pad to the next pointer boundary */ struct iflib_filter_info ift_filter_info; bus_dma_tag_t ift_buf_tag; iflib_dma_info_t ift_ifdi; @@ -516,6 +516,7 @@ struct iflib_fl { qidx_t ifl_rxd_idxs[IFLIB_MAX_RX_REFRESH]; } __aligned(CACHE_LINE_SIZE); +#ifdef INVARIANTS static inline qidx_t get_inuse(int size, qidx_t cidx, qidx_t pidx, uint8_t gen) { @@ -534,9 +535,9 @@ get_inuse(int size, qidx_t cidx, qidx_t pidx, uint8_t gen) return (used); } +#endif -#define TXQ_AVAIL(txq) ((txq->ift_size - txq->ift_pad) -\ - get_inuse(txq->ift_size, txq->ift_cidx, txq->ift_pidx, txq->ift_gen)) +#define TXQ_AVAIL(txq) (txq->ift_size - txq->ift_pad - txq->ift_in_use) #define MAX_TX_DESC(ctx) MAX((ctx)->ifc_softc_ctx.isc_tx_tso_segments_max, \ (ctx)->ifc_softc_ctx.isc_tx_nsegments) @@ -2915,7 +2916,7 @@ iflib_stop(if_ctx_t ctx) txq->ift_processed_prev = 0; txq->ift_outstanding_prev = 0; txq->ift_wdog_armed = 0; - txq->ift_in_use = txq->ift_gen = txq->ift_no_desc_avail = 0; + txq->ift_in_use = txq->ift_no_desc_avail = 0; txq->ift_npending = txq->ift_db_pending = 0; txq->ift_rs_pending = 0; if (sctx->isc_flags & IFLIB_PRESERVE_TX_INDICES) @@ -3959,7 +3960,6 @@ defrag: ndesc = pi.ipi_new_pidx - pi.ipi_pidx; if (pi.ipi_new_pidx < pi.ipi_pidx) { ndesc += txq->ift_size; - txq->ift_gen = 1; } if (pi.ipi_flags & IPI_TX_INTR) @@ -4031,11 +4031,10 @@ out_with_error: static void iflib_tx_desc_free(iflib_txq_t txq, int n, struct mbuf **m_defer) { - uint32_t qsize, cidx, gen; + uint32_t qsize, cidx; struct mbuf *m, **ifsd_m; cidx = txq->ift_cidx; - gen = txq->ift_gen; qsize = txq->ift_size; ifsd_m =txq->ift_sds.ifsd_m; @@ -4061,11 +4060,9 @@ iflib_tx_desc_free(iflib_txq_t txq, int n, struct mbuf **m_defer) } if (__predict_false(++cidx == qsize)) { cidx = 0; - gen = 0; } } txq->ift_cidx = cidx; - txq->ift_gen = gen; } static __inline int