Date: Sat, 01 Aug 2026 15:14:02 +0000 From: Arthur Kiyanovski <akiyano@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: David Arinzon <darinzon@amazon.com> Subject: git: 203735fee058 - stable/14 - ena: Batch RX statistics updates Message-ID: <6a6e0d3a.37dad.3ca7c176@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by akiyano: URL: https://cgit.FreeBSD.org/src/commit/?id=203735fee058c783a39d7f4441aad29994db493d commit 203735fee058c783a39d7f4441aad29994db493d Author: David Arinzon <darinzon@amazon.com> AuthorDate: 2026-04-16 11:22:04 +0000 Commit: Arthur Kiyanovski <akiyano@FreeBSD.org> CommitDate: 2026-08-01 15:12:05 +0000 ena: Batch RX statistics updates Move per-packet counter_enter/counter_exit pairs out of the RX processing loop and batch them into a single update after the loop completes. Previously, each received packet triggered two separate counter_enter/counter_exit blocks -- one for bytes and one for packet count. This commit accumulates totals in local variables and updates all four counters (ring and hw stats for both packets and bytes) in a single counter_enter/counter_exit block after the loop. Also move the stats update to after the refill and LRO flush so that the error path (goto update_stats) and the normal path converge at the same label, avoiding code duplication. Submitted by: David Arinzon <darinzon@amazon.com> MFC after: 2 weeks Sponsored by: Amazon, Inc. Reviewed by: cperciva Differential Revision: https://reviews.freebsd.org/D58240 (cherry picked from commit 3ba01cb4c61cc1e29c4d1d7ea4b73cdffb5ce3c2) --- sys/dev/ena/ena_datapath.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/sys/dev/ena/ena_datapath.c b/sys/dev/ena/ena_datapath.c index 4fbdb8daaf58..1ce5c2ae3e65 100644 --- a/sys/dev/ena/ena_datapath.c +++ b/sys/dev/ena/ena_datapath.c @@ -576,6 +576,8 @@ ena_rx_cleanup(struct ena_ring *rx_ring) unsigned int qid; int rc, i; int budget = (ENA_RX_DESC_BUDGET == -1) ? INT_MAX : ENA_RX_DESC_BUDGET; + uint64_t total_pkts = 0; + uint64_t total_bytes = 0; #ifdef DEV_NETMAP int done; #endif /* DEV_NETMAP */ @@ -618,7 +620,7 @@ ena_rx_cleanup(struct ena_ring *rx_ring) reset_reason = ENA_REGS_RESET_INV_RX_REQ_ID; } ena_trigger_reset(adapter, reset_reason); - return (0); + goto update_stats; } if (unlikely(ena_rx_ctx.descs == 0)) @@ -650,12 +652,7 @@ ena_rx_cleanup(struct ena_ring *rx_ring) ena_rx_checksum(rx_ring, &ena_rx_ctx, mbuf); } - counter_enter(); - counter_u64_add_protected(rx_ring->rx_stats.bytes, - mbuf->m_pkthdr.len); - counter_u64_add_protected(adapter->hw_stats.rx_bytes, - mbuf->m_pkthdr.len); - counter_exit(); + total_bytes += mbuf->m_pkthdr.len; /* * LRO is only for IP/TCP packets and TCP checksum of the packet * should be computed by hardware. @@ -680,10 +677,7 @@ ena_rx_cleanup(struct ena_ring *rx_ring) if_input(ifp, mbuf); } - counter_enter(); - counter_u64_add_protected(rx_ring->rx_stats.cnt, 1); - counter_u64_add_protected(adapter->hw_stats.rx_packets, 1); - counter_exit(); + total_pkts++; /* * Adjust our budget; note that we count descriptors, not @@ -706,6 +700,13 @@ ena_rx_cleanup(struct ena_ring *rx_ring) tcp_lro_flush_all(&rx_ring->lro); +update_stats: + counter_enter(); + counter_u64_add_protected(rx_ring->rx_stats.cnt, total_pkts); + counter_u64_add_protected(rx_ring->rx_stats.bytes, total_bytes); + counter_u64_add_protected(adapter->hw_stats.rx_packets, total_pkts); + counter_u64_add_protected(adapter->hw_stats.rx_bytes, total_bytes); + counter_exit(); return (budget <= 0); }home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a6e0d3a.37dad.3ca7c176>
