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=1796114184; b=3/TAJFX6tXr7keBZWjcZMiHBf+1cF2xwYtFstn7YvM7eUl+GHiK5CRje9ZVVgsTK54ed UsCgnImOaYIG9mtGOYyKHHiz8M6pyc4cUjq0OTuv3yfAP8hOU06D+5UStkWZCTs8/gtGQ SKZ14VfGOfnxcS62+z89Pi4w9lHGfrH/d4UJSDokoKMHiKsCKbMGTiiCSGBhyhzJXqvN0 hOFf3ffUfrv5n9ADW2bjNTUyz+g/GqIsO9UKWSseFCj3XlNewiD1pGkOcxfV5/GD6KAyM MiT8ABh3mYtTofTW5003mz1Fig1dTSBVRnNgr2Jjt0euwvvWrliREMIzNDSG1UGEmwA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796114184; 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=rjaz9jv7zKw7NwZsOb03boUNoD7hAlufdPhpVO0NzF0=; b=SRs60z1l3n703siWKZ5g/eL0zJBrR4G4KcCn/5hfHE+xJKwJEztx5lNqsDvHUEGzlCnK FOEbv6C1WodDnUHbgQ0wNuOzkBk6Z0tX4X3/psfUlLPbgO16mwZWWWIJ18P7HNReCjvgO Ty4g0GkeQluItx2qcOVc64fH/9/hmBNdjw0HTWF4sZPd0Jz4ntu7xoqZfEfto4zn9Smak CKo7bUNUP8tRnt5fYjYrpNemiJHLMzP0IK3mg3Z12PUqlfUCGCyQB9TEoVrZGXoaJGb5x k3fuhcPJ6k4VbtrVZsmyYF3pCPxeP69MURu+wNdGPsZpOOW0TsyAyI4C78SovQ17JqA== 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=KUVgPgKy; 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 D63CB606A31A for ; Tue, 1 Dec 2026 08:36:24 +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=KUVgPgKy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A8141F00893; Tue, 1 Dec 2026 08:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796114184; bh=rjaz9jv7zKw7NwZsOb03boUNoD7hAlufdPhpVO0NzF0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=KUVgPgKy6NIBGXdMa0SfXh3MxCWGZdREYN6KWfPlLeVm4fSCbeD9we9nUHccvp/6E eVIE9hjYO1mGakojiIA6DwesMyi35J9aGWqFIxvwngP72+OYHZhvFc+ZwEIDnhLgn5 EIRp4jB7j7B6Ll3ZBbYv5hpVIfmV4S8ByhAmZhPdb0t7B90Fjkp7lgyZGFitPGZ0Zt 3TaHRLbIvBZhWBtB13/O6H+Q/7t4URq++srToRe8xciPf0hA6iLhCRu2/1bBhu6Rfc 8sgoWIlxMk+wabxRFceSGKXsecEPthTBoDwW9gd0vGbtqhpxLOzIJ7xNBes0L4X3Qo mFDR6Wpl+8V/g== Subject: Re: [PATCH net-next v2 1/3] net: libwx: preserve queue stats across reconfiguration From: netdev-bot+sashiko@kernel.org To: mengyuanlou@net-swift.com Cc: netdev@vger.kernel.org, jiawenwu@trustnetic.com, duanqiangwen@net-swift.com, linglingzhang@net-swift.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Date: Tue, 01 Dec 2026 08:36:23 +0000 Message-ID: <179611418308.3146.8210544015669457449@kernel.org> In-Reply-To: <20261130083407.78429-2-mengyuanlou@net-swift.com> References: <20261130083407.78429-2-mengyuanlou@net-swift.com> X-sashiko-severity: Medium 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 3 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 2 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). - [Medium] wx_get_stats64() (drivers/net/ethernet/wangxun/libwx/wx_lib.c:3147-3148) reads… - [Low] The new TX stop counter and the existing wake counter do not count the same events, so wake can be larger than stop. - [Low] This feature patch also carries an unannounced fix for an existing bug. -- net: libwx: preserve queue stats across reconfiguration When queue vectors are freed, this patch keeps the per-ring packet, byte and error counters in new qstats_base_* accumulators, protected by hw_stats_lock. It also splits the ring u64_stats_sync into napi_syncp and xmit_syncp, initializes both, and moves the rx/tx error counters under the seqcounts. A new stop_queue counter is added next to restart_queue, and the pair is reported as retained stop/wake counters. > diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c > index 10f095fb7085c..2868232792588 100644 > --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c > +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c [ ... ] > @@ -1021,12 +1039,18 @@ static int wx_maybe_stop_tx(struct wx_ring *tx_ring, u16 size) > /* We need to check again in a case another CPU has just > * made room available. > */ > - if (likely(wx_desc_unused(tx_ring) < size)) > + if (likely(wx_desc_unused(tx_ring) < size)) { > + u64_stats_update_begin(&tx_ring->xmit_syncp); > + ++tx_ring->tx_stats.stop_queue; > + u64_stats_update_end(&tx_ring->xmit_syncp); > return -EBUSY; > + } > > /* A reprieve! - use start_queue because it doesn't call schedule */ > netif_start_subqueue(tx_ring->netdev, tx_ring->queue_index); > + u64_stats_update_begin(&tx_ring->xmit_syncp); > ++tx_ring->tx_stats.restart_queue; > + u64_stats_update_end(&tx_ring->xmit_syncp); > > return 0; > } [Severity: Low] Can tx wake end up larger than tx stop here? On the reprieve path, netif_stop_subqueue() has already stopped the queue because the ring was full, and netif_start_subqueue() restarts it. That increments restart_queue but not stop_queue. wx_ring_get_tx_stats() then reports: stats->tx.stop = ring->tx_stats.stop_queue; stats->tx.wake = ring->tx_stats.restart_queue + restart_queue_napi; wx_free_q_vector() folds both values into qstats_base_tx_stats, so each reprieve adds a wake with no matching stop. The comment on struct wx_tx_retained_stats says these counters are "named after what netdev-genl reports". The later patch "net: wangxun: expose queue stats via netdev-genl" reports them as tx-stop and tx-wake through wx_get_queue_stats_tx() and wx_get_base_stats(). netdev.yaml defines tx-stop as the number of times the driver paused accepting new tx packets because the queue was full, and the reprieve path does pause the queue. Other drivers that use netif_subqueue_maybe_stop(), such as fbnic, count neither a stop nor a wake for the reprieve result, so the two counters stay paired. The commit message states "the reprieve path only adds a wake". Should the reprieve either count a stop as well, or not be counted as a wake? [ ... ] > @@ -2182,6 +2208,8 @@ static int wx_alloc_q_vector(struct wx *wx, > > /* apply Tx specific ring traits */ > ring->count = wx->tx_ring_count; > + u64_stats_init(&ring->napi_syncp); > + u64_stats_init(&ring->xmit_syncp); > > ring->queue_index = txr_idx; > ring->reg_idx = wx_get_reg_idx(wx, txr_idx, false); [Severity: Low] This isn't a regression, but these u64_stats_init() calls, and the one added for RX rings, seem to also fix an existing bug. Before this patch, ring->syncp was never initialized. The rings come from kzalloc_flex() in wx_alloc_q_vector(), and there is no u64_stats_init() anywhere under drivers/net/ethernet/wangxun at the baseline. On 32-bit SMP kernels with CONFIG_DEBUG_LOCK_ALLOC, the first u64_stats_update_begin(&ring->syncp) in wx_clean_rx_irq() or wx_clean_tx_irq() runs seqcount_acquire() on a zeroed lockdep_map. That prints "INFO: trying to register non-static key" and turns lockdep off. The baseline also updated the 64-bit rx_stats/tx_stats counters (non_eop_descs, csum_err, csum_good_cnt, alloc_rx_buff_failed, rsc_*, restart_queue, tx_busy) outside any syncp section. wx_update_stats() read them without fetch_begin/retry, so 32-bit readers could see torn values. Could the initialization and the move under the seqcount go into a separate patch with a Fixes: tag? That would let them go to net and stable instead of riding along with this feature change. [ ... ] > @@ -3087,39 +3146,42 @@ void wx_get_stats64(struct net_device *netdev, > > num_rx_queues = READ_ONCE(wx->num_rx_queues); > num_tx_queues = READ_ONCE(wx->num_tx_queues); > + /* Pair with kfree_rcu() in wx_free_q_vector(). */ > rcu_read_lock(); > + /* wx_free_q_vector() folds a ring into the base values under the same > + * lock, so the snapshot cannot mix a ring with its retained value. > + * The lock has to span the ring walk: the base values are read after > + * it, and a ring folded in between would be counted twice. > + */ > + spin_lock(&wx->hw_stats_lock); [Severity: Medium] Can the queue counts read here be stale by the time hw_stats_lock is taken? num_rx_queues and num_tx_queues are read before the lock. The ring walk and the qstats_base_* values are only consistent under the lock. The new counts and ring pointers are also published without hw_stats_lock: wx_set_num_queues() sets the counts, then wx_alloc_q_vector() calls rcu_assign_pointer(). Consider a /proc/net/dev reader, which holds only RCU and not RTNL: CPU1 wx_get_stats64() num_tx_queues = READ_ONCE(wx->num_tx_queues); /* 4 */ CPU2 (ethtool -L 8 under RTNL) wx_clear_interrupt_scheme() wx_free_q_vectors() /* folds rings 0..3 into qstats_base_* */ wx_init_interrupt_scheme() wx_set_num_queues() /* 8 */ wx_alloc_q_vectors() /* publishes rings 0..7 */ open, traffic flows on rings 4..7 CPU1 resumes spin_lock(&wx->hw_stats_lock); walks only i < 4, then adds the full qstats_base_* The reader leaves out the live counters of rings 4..7. Its rx/tx packets and bytes can then be lower than an earlier snapshot. The same happens if CPU1 reads 0 just after wx_free_q_vectors(). The commit message says the ordering "keeps base plus live rings invariant at every instant" and that "a reader which pairs the counts with the base values cannot skip a ring". wx_get_stats64() is unchanged later in the series. wx_update_stats() already reads the counts after spin_lock(). Would moving these two READ_ONCE() calls after spin_lock(&wx->hw_stats_lock) be enough to make wx_get_stats64() match that claim? [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130083407.78429-1-mengyuanlou%40net-swift.com