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=1796444275; b=vFOya7nZRERAoUekGuE7gD8PimTrB+NC9MWf/B9xgfkoEuyZ+DcvDiV/lhlN0KC92PuK Y16r/EngAwU5ietebEsBJGWopQnybCSdTBxq7H0b7fWUQlkKhkO2oMC6YKnQz4Gns/4u9 bDBFJMXyVsLvA4T0k0qlja5CTMvsBfZo4hWXDQUQ3A5qrdJ16o7WrmSFUQbSOrYgfJb1A ekF4UhWGLMT/6EFLHM6w6TfKUi95m27y/FKiOoioPnNboMFJK1fVZk0vXAOoiE2XrnieQ KoLXSuqCJnusqKYy5j27Pke9BCLeGvQSp+vACFbLkYXDQo6qUsGeQHHGIytrYXff+nQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796444275; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=teCwfFg3PH2zrFT3DrQ7mtJsXASm6mCpdBEUBl4k93g=; b=Le5YoZBfMvYKqBcOmRNj6rk1u36OIXT0F4V0se481/cC2lUSG9SkdsIXI6sg9qvNhuC2 n/H9HIo/mtVciqzLZFg5pSURitUWKnEuD4Von10MfxiHX/gZb0kzFVdmCeGpZT8M2MPrB SmT8/cWa+4La/E2T38T+oMU44SKuTZ8dh5/Dsn3zcCDJFumTm2YYQw58EQLvofFls5Zf3 U0HZWrwKBhbAwL/N63ArCAXFEeK16GUQOgotudvw7nIZPPRHzwNKVTxC0is6xawmWxVKU 97DMeNIkR/rZHhS+YViAXi4scy1YVI+hDs7TYbv0ADRDSZK5geFqzXdh8CgdxBfKexQ== 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=b6bWanBQ; 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 39E6A606A33F; Sat, 5 Dec 2026 04:17:55 +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=b6bWanBQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id D02921F00936; Sat, 5 Dec 2026 04:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796444274; bh=teCwfFg3PH2zrFT3DrQ7mtJsXASm6mCpdBEUBl4k93g=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=b6bWanBQzJep/K+nw3pv9Rb4Lf0QzU/GaRIGQU342SSgJTMHlD3Kg5o/Oykusj8+b qMvRsZDsNhadotjbr9YjJiUMofmlRmZR2hbOoceVCtSgY8CCEt+Ps/UsChpLXxWxeK IK8D9T41Hmb6f/Tyhry74S+K7rA9y3vLbx3dFsnJQB07wHGl1Hnf/yN+GIf9O/Ey90 gWBoWkaVb34rk3SdVTlCSRbwSgcUmyjf3ZDJqufY+/IE8S/e09P3hjasSFsQug3m6q 4h6scQAvQQPDguErLKP5/ozDg0EhOdzGs789KaxA1BoKR/Ow3Te6aZ8PH7TdFFahla ksnSuS3ZuLxQg== Subject: Re: [PATCH net-next v19 1/4] hinic3: Add ethtool statistic ops part(1/2) From: netdev-bot+sashiko@kernel.org To: gongfan1@huawei.com Cc: wudi234@huawei.com, tengpeisen@huawei.com, netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, andrew+netdev@lunn.ch, ioana.ciornei@nxp.com, maxime.chevallier@bootlin.com, mohsin.bashr@gmail.com, dimitri.daskalakis1@gmail.com, hramamurthy@google.com, larysa.zaremba@intel.com, vadim.fedorenko@linux.dev, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, zhoushuai28@huawei.com, wulike1@huawei.com Date: Sat, 05 Dec 2026 04:17:53 +0000 Message-ID: <179644427340.3146.10918636683400261151@kernel.org> In-Reply-To: <8fd1e9db6fe4efea06e2ce3ff82e01009cd21bee.1796348433.git.gongfan1@huawei.com> References: <8fd1e9db6fe4efea06e2ce3ff82e01009cd21bee.1796348433.git.gongfan1@huawei.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 1 · Low: 3 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] hinic3_send_one_skb() (drivers/net/ethernet/huawei/hinic3/hinic3_tx.c) now reads the free… - [Medium] hinic3_tx_poll() (drivers/net/ethernet/huawei/hinic3/hinic3_tx.c) computes the per-… - [Low] This patch makes hinic3_rx_poll() (drivers/net/ethernet/huawei/hinic3/hinic3_rx.c) the first writer of… - [Low] hinic3: concurrent txq_stats.syncp updates and unmarked u64 stats accesses - [Low] hinic3: commit message omits rx_errors change in hinic3_get_stats64() -- hinic3: Add ethtool statistic ops part(1/2) This commit adds per-queue TX/RX software counters and firmware-backed vport and physical port statistics to hinic3, and exposes them through ethtool -S. TX packet and byte accounting moves to hinic3_tx_poll() and is counted as wire packets/bytes. The tx stop paths now use the return values of netif_subqueue_try_stop() and netif_subqueue_maybe_stop(). > diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c > index ad6b65fce9c9e..8154a6bff9282 100644 > --- a/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c > +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c [ ... ] > @@ -580,8 +611,13 @@ int hinic3_rx_poll(struct hinic3_rxq *rxq, int budget) > > nr_pkts++; > num_lro = RQ_CQE_STATUS_GET(status, NUM_LRO); > - if (num_lro) > + if (num_lro) { > num_wqe += hinic3_get_sge_num(rxq, pkt_len); > + rx_packets += num_lro; > + } else { > + rx_packets++; > + } > + rx_bytes += pkt_len; > > rx_cqe->status = 0; > > @@ -604,5 +640,24 @@ int hinic3_rx_poll(struct hinic3_rxq *rxq, int budget) > if (unlikely(oom)) > hinic3_rx_oom_schedule(rxq->netdev, rxq->q_id); > > + u64_stats_update_begin(&rxq->rxq_stats.syncp); > + rxq->rxq_stats.packets += rx_packets; > + rxq->rxq_stats.bytes += rx_bytes; > + u64_stats_update_end(&rxq->rxq_stats.syncp); > return poll_again ? budget : nr_pkts; > } [Severity: Low] This isn't a bug, but the commit message doesn't mention this change. Before this patch, rxq_stats.packets and rxq_stats.bytes were only zeroed in hinic3_rxq_clean_stats(). This makes hinic3_rx_poll() the first code that writes them. hinic3_net_dim() in hinic3_irq.c feeds the same fields to DIM: dim_update_sample(irq_cfg->total_events, rxq->rxq_stats.packets, rxq->rxq_stats.bytes, &sample); adaptive_rx_coal defaults to 1 in hinic3_main.c. So since b35a6fd37a00 ("hinic3: Add adaptive IRQ coalescing with DIM"), DIM has been sampling zeros by default. With this patch it starts adapting, which changes the default interrupt moderation behaviour. hinic3_get_stats64() also stops reporting zero RX packets and bytes. Could the commit message describe the RX accounting change? That includes the LRO rule (packets counted as num_lro, bytes counted as the coalesced pkt_len, unlike the wire bytes rule described for TX) and the resulting DIM behaviour change. Would it also make sense to split out the DIM fix with a Fixes: tag, so that it can reach stable? [ ... ] > diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c > index f92568f0f00b7..04086947b0bc5 100644 > --- a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c > +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c [ ... ] > @@ -531,41 +544,54 @@ static netdev_tx_t hinic3_send_one_skb(struct sk_buff *skb, [ ... ] > offload = hinic3_tx_offload(skb, &task, &queue_info, txq); > num_sge = skb_shinfo(skb)->nr_frags + 1; > /* assume normal wqe format + 1 wqebb for task info */ > wqebb_cnt = num_sge + 1; > + pkt_len = skb->len; > > - if (unlikely(hinic3_wq_free_wqebbs(&txq->sq->wq) < wqebb_cnt)) { > + free_wqebb = hinic3_wq_free_wqebbs(&txq->sq->wq); > + if (unlikely(free_wqebb < wqebb_cnt)) { > if (likely(wqebb_cnt > txq->tx_stop_thrs)) > txq->tx_stop_thrs = min(wqebb_cnt, txq->tx_start_thrs); > > - netif_subqueue_try_stop(netdev, txq->sq->q_id, > - hinic3_wq_free_wqebbs(&txq->sq->wq), > - txq->tx_start_thrs); > - > + if (!netif_subqueue_try_stop(netdev, txq->sq->q_id, > + free_wqebb, > + txq->tx_start_thrs)) { > + u64_stats_update_begin(&txq->txq_stats.syncp); > + txq->txq_stats.busy++; > + u64_stats_update_end(&txq->txq_stats.syncp); > + } > return NETDEV_TX_BUSY; > } [Severity: High] Can this lose a TX queue wakeup? netif_subqueue_try_stop() evaluates get_desc again after stopping the queue, so that it can catch completions that ran concurrently: netif_tx_stop_queue(txq); smp_mb__after_atomic(); ... if (unlikely(get_desc >= start_thrs)) { netif_tx_start_queue(txq); include/net/netdev_queues.h documents this requirement: @get_desc must be a formula or a function call, it must always return up-to-date information when evaluated! free_wqebb is a local snapshot taken before the stop. The second check therefore compares a stale value and can no longer see a concurrent hinic3_tx_poll(). For example: CPU0 (hinic3_send_one_skb) CPU1 (hinic3_tx_poll) free_wqebb = hinic3_wq_free_wqebbs() (< wqebb_cnt) hinic3_wq_put_wqebbs() netif_subqueue_completed_wake() queue not stopped yet, no wake netif_tx_stop_queue() smp_mb__after_atomic() free_wqebb >= tx_start_thrs (stale, false) return NETDEV_TX_BUSY If CPU1 completed the last in-flight WQEs, no later completion runs to wake the queue, and it stays stopped. hinic3_tx_timeout() does not wake the queue either, and it does nothing when sw_pi == hw_ci. Would passing hinic3_wq_free_wqebbs(&txq->sq->wq) directly, as the old code did, restore the re-check? The netif_subqueue_maybe_stop() call after the WQE is posted has the same pattern. There, the doorbelled packet's completion should still wake the queue, so the effect is limited to unneeded stops. [ ... ] > @@ -782,6 +832,29 @@ bool hinic3_tx_poll(struct hinic3_txq *txq, int budget) > bytes_compl += tx_info->skb->len; > pkts++; > > + gso_segs = skb_is_gso(tx_info->skb) ? > + max_t(u32, skb_shinfo(tx_info->skb)->gso_segs, 1) : 1; > + wire_packets += gso_segs; > + if (skb_is_gso(tx_info->skb)) { > + u32 wire_len = tx_info->skb->len; > + > + gso_packets++; > + gso_bytes += tx_info->skb->len; > + gso_wire_packets += gso_segs; > + > + /* Only TCP GSO repeats a TCP header per segment. */ > + if (skb_shinfo(tx_info->skb)->gso_type & > + (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { > + hdr_len = skb_transport_offset(tx_info->skb) + > + tcp_hdrlen(tx_info->skb); > + wire_len += (gso_segs - 1) * hdr_len; > + } [Severity: Medium] Does this compute the wrong hdr_len for UDP tunnel TSO skbs? The driver advertises NETIF_F_GSO_UDP_TUNNEL and NETIF_F_GSO_UDP_TUNNEL_CSUM in features and hw_enc_features. For a VXLAN TCP GSO skb, gso_type contains both SKB_GSO_UDP_TUNNEL and SKB_GSO_TCPV4/6, and skb->transport_header points at the outer UDP header. tcp_hdrlen() would then read doff from inside the VXLAN header instead of the inner TCP header. hinic3_tso() already handles this case by switching to the inner headers: if (skb->encapsulation) { ... ip.hdr = skb_inner_network_header(skb); l4.hdr = skb_inner_transport_header(skb); As written, txq_stats.bytes and gso_wire_bytes look wrong for tunnel TSO traffic. txq_stats.bytes is reported as tx_bytes by hinic3_get_stats64(). gso_wire_bytes is exported as qstats hw-gso-wire-bytes by the later patch "hinic3: Add per-queue netdev-genl stats" in this series. Should this use skb_inner_transport_offset() + inner_tcp_hdrlen() when skb->encapsulation is set? This also doesn't match this part of the commit message: the repeated TCP header length is added to the byte count. [ ... ] > @@ -789,9 +862,37 @@ bool hinic3_tx_poll(struct hinic3_txq *txq, int budget) > > hinic3_wq_put_wqebbs(&txq->sq->wq, wqebb_cnt); > > - netif_subqueue_completed_wake(netdev, q_id, pkts, bytes_compl, > - hinic3_wq_free_wqebbs(&txq->sq->wq), > - txq->tx_start_thrs); > + if (!netif_subqueue_completed_wake(netdev, q_id, pkts, bytes_compl, > + hinic3_wq_free_wqebbs(&txq->sq->wq), > + txq->tx_start_thrs)) { > + wake = 1; > + } > + > + u64_stats_update_begin(&txq->txq_stats.syncp); > + txq->txq_stats.bytes += wire_bytes; > + txq->txq_stats.packets += wire_packets; > + txq->txq_stats.gso_bytes += gso_bytes; > + txq->txq_stats.gso_packets += gso_packets; > + txq->txq_stats.gso_wire_bytes += gso_wire_bytes; > + txq->txq_stats.gso_wire_packets += gso_wire_packets; > + txq->txq_stats.wake += wake; > + u64_stats_update_end(&txq->txq_stats.syncp); > > return pkts == HINIC3_TX_POLL_WEIGHT; > } > + > +void hinic3_txq_get_stats(struct hinic3_txq *txq, > + struct hinic3_txq_stats *stats) > +{ > + struct hinic3_txq_stats *txq_stats = &txq->txq_stats; > + unsigned int start; > + > + do { > + start = u64_stats_fetch_begin(&txq_stats->syncp); > + stats->busy = txq_stats->busy; > + stats->skb_pad_err = txq_stats->skb_pad_err; > + stats->offload_cow_skb_err = txq_stats->offload_cow_skb_err; > + stats->map_frag_err = txq_stats->map_frag_err; > + stats->unknown_tunnel_pkt = txq_stats->unknown_tunnel_pkt; > + } while (u64_stats_fetch_retry(&txq_stats->syncp, start)); > +} [Severity: Low] Is it safe for the xmit path and the NAPI completion path to share txq->txq_stats.syncp as writers? hinic3_send_one_skb(), hinic3_tx_map_skb(), hinic3_tx_csum() and hinic3_xmit_frame() update txq->txq_stats.syncp under the netdev_queue _xmit_lock, while hinic3_tx_poll() updates it from hinic3_poll() in softirq without holding that lock. include/linux/u64_stats_sync.h requires writers on the same syncp to be mutually exclusive. Otherwise a lost seqcount update can leave 32-bit readers spinning forever. The Kconfig dependency on 64BIT makes the seqcount compile away, and the two paths touch disjoint fields, so this is latent today. That also means syncp provides no protection on the supported builds. The counters are plain u64 updated with ++ and += in hinic3_send_one_skb(), hinic3_tx_poll() and hinic3_rx_poll(), and read locklessly by hinic3_get_stats64(), hinic3_txq_get_stats() and hinic3_rxq_get_stats(). Those are plain C data races that KCSAN will flag, and nothing stops the compiler from tearing the accesses. Would it make sense to give the submit and completion paths separate u64_stats_sync instances, and to convert the queue counters to u64_stats_t with u64_stats_inc(), u64_stats_add() and u64_stats_read()? The per-queue netdev-genl stats added later in this series read the same fields, so they would need the same treatment. [ ... ] > diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c b/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c > --- a/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c > +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c > @@ -816,8 +816,7 @@ static void hinic3_get_stats64(struct net_device *netdev, > start = u64_stats_fetch_begin(&rxq_stats->syncp); > bytes = rxq_stats->bytes; > packets = rxq_stats->packets; > - errors = rxq_stats->csum_errors + > - rxq_stats->other_errors; > + errors = rxq_stats->other_errors; > dropped = rxq_stats->dropped; > } while (u64_stats_fetch_retry(&rxq_stats->syncp, start)); > stats->rx_packets += packets; [Severity: Low] This isn't a bug, but the commit message doesn't mention this change. hinic3_get_stats64() used to report csum_errors + other_errors as rx_errors. This patch drops csum_errors from rx_errors, and it is the same patch that adds the first csum_errors writer in hinic3_rx_csum(). Commit 0f00324913b4 ("hinic3: Read the queue counters once per u64_stats retry loop") kept rx_errors as the sum and left the checksum error accounting to the commit that adds the writer, so this is where the decision is actually made. Frames that fail the hardware checksum are still passed up with CHECKSUM_NONE rather than dropped, so leaving them out of rx_errors may well be intended. Could the commit message describe the rx_errors change and say where hardware checksum failures are reported instead? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796348433.git.gongfan1%40huawei.com