From: Jakub Kicinski <kuba@kernel.org>
To: David Yang <mmyangfl@gmail.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 2/2] net: dsa: yt921x: Protect MIB stats with a lock
Date: Mon, 5 Jan 2026 17:33:42 -0800 [thread overview]
Message-ID: <20260105173342.65654f22@kernel.org> (raw)
In-Reply-To: <20260105020905.3522484-3-mmyangfl@gmail.com>
On Mon, 5 Jan 2026 10:09:01 +0800 David Yang wrote:
> - pp->rx_frames = mib->rx_64byte + mib->rx_65_127byte +
> - mib->rx_128_255byte + mib->rx_256_511byte +
> - mib->rx_512_1023byte + mib->rx_1024_1518byte +
> - mib->rx_jumbo;
> - pp->tx_frames = mib->tx_64byte + mib->tx_65_127byte +
> - mib->tx_128_255byte + mib->tx_256_511byte +
> - mib->tx_512_1023byte + mib->tx_1024_1518byte +
> - mib->tx_jumbo;
> -
> - if (res)
> + if (res) {
> dev_err(dev, "Failed to %s port %d: %i\n", "read stats for",
> port, res);
> - return res;
> + return res;
> + }
> +
> + rx_frames = mib->rx_64byte + mib->rx_65_127byte +
> + mib->rx_128_255byte + mib->rx_256_511byte +
> + mib->rx_512_1023byte + mib->rx_1024_1518byte +
> + mib->rx_jumbo;
> + tx_frames = mib->tx_64byte + mib->tx_65_127byte +
> + mib->tx_128_255byte + mib->tx_256_511byte +
> + mib->tx_512_1023byte + mib->tx_1024_1518byte +
> + mib->tx_jumbo;
Should this not use mib_new now? (or live inside the spin lock after
copying over?)
> + spin_lock(&pp->stats_lock);
> + *mib = *mib_new;
> + pp->rx_frames = rx_frames;
> + pp->tx_frames = tx_frames;
> + spin_unlock(&pp->stats_lock);
> diff --git a/drivers/net/dsa/yt921x.h b/drivers/net/dsa/yt921x.h
> index 61bb0ab3b09a..0c9d1b6cbc23 100644
> --- a/drivers/net/dsa/yt921x.h
> +++ b/drivers/net/dsa/yt921x.h
> @@ -533,9 +533,14 @@ struct yt921x_port {
> bool isolated;
>
> struct delayed_work mib_read;
> + /* protect the access to mib, rx_frames and tx_frames */
> + spinlock_t stats_lock;
looks like spin_lock_init() is missing
prev parent reply other threads:[~2026-01-06 1:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 2:08 [PATCH net-next v3 0/2] net: dsa: yt921x: Fix MIB overflow wraparound routine David Yang
2026-01-05 2:09 ` [PATCH net-next v3 1/2] " David Yang
2026-01-05 2:09 ` [PATCH net-next v3 2/2] net: dsa: yt921x: Protect MIB stats with a lock David Yang
2026-01-05 2:51 ` Qingfang Deng
2026-01-05 23:37 ` Jakub Kicinski
2026-01-06 1:33 ` Jakub Kicinski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260105173342.65654f22@kernel.org \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mmyangfl@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox