public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: mmyangfl@gmail.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	davem@davemloft.net, andrew@lunn.ch, edumazet@google.com,
	pabeni@redhat.com, david.laight.linux@gmail.com,
	olteanv@gmail.com, dan.carpenter@linaro.org
Subject: Re: [net-next,v4,2/2] net: dsa: yt921x: Use u64_stats_t for MIB stats
Date: Thu,  8 Jan 2026 19:59:04 -0800	[thread overview]
Message-ID: <20260109035904.2904127-1-kuba@kernel.org> (raw)
In-Reply-To: <20260108004309.4087448-3-mmyangfl@gmail.com>

This is an AI-generated review of your patch.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: dsa: yt921x: Use u64_stats_t for MIB stats

This patch converts the MIB statistics from plain u64 to u64_stats_t and
adds a u64_stats_sync seqcount to provide atomicity on 32-bit architectures
while remaining lock-free on 64-bit architectures.

> diff --git a/drivers/net/dsa/yt921x.h b/drivers/net/dsa/yt921x.h
> index 61bb0ab3b09a..17fee83952c2 100644
> --- a/drivers/net/dsa/yt921x.h
> +++ b/drivers/net/dsa/yt921x.h

[ ... ]

> @@ -533,9 +535,13 @@ struct yt921x_port {
>  	bool isolated;
>
>  	struct delayed_work mib_read;
> +	struct u64_stats_sync syncp;
>  	struct yt921x_mib mib;
> -	u64 rx_frames;
> -	u64 tx_frames;
> +	u64_stats_t rx_frames;
> +	u64_stats_t tx_frames;
> +
> +	/* only used by read routine to avoid huge allocations on the stack */
> +	struct yt921x_mib mib_new;
>  };

The new syncp field requires u64_stats_init() to be called before use.
Looking at yt921x_mdio_probe(), the port initialization loop only sets
pp->index and calls INIT_DELAYED_WORK() but does not call
u64_stats_init(&pp->syncp).

On 32-bit architectures, u64_stats_init() calls seqcount_init() which
initializes the lockdep tracking. Without this initialization, builds
with CONFIG_DEBUG_LOCK_ALLOC may have lockdep issues.

For reference, the xrs700x DSA driver does this correctly in
xrs700x_alloc_port_mib():

    mutex_init(&p->mib_mutex);
    u64_stats_init(&p->syncp);

Should u64_stats_init(&pp->syncp) be added to the port initialization
loop in yt921x_mdio_probe()?

      reply	other threads:[~2026-01-09  3:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-08  0:43 [PATCH net-next v4 0/2] net: dsa: yt921x: Fix MIB overflow wraparound routine David Yang
2026-01-08  0:43 ` [PATCH net-next v4 1/2] " David Yang
2026-01-09  3:56   ` [net-next,v4,1/2] " Jakub Kicinski
2026-01-08  0:43 ` [PATCH net-next v4 2/2] net: dsa: yt921x: Use u64_stats_t for MIB stats David Yang
2026-01-09  3:59   ` 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=20260109035904.2904127-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=dan.carpenter@linaro.org \
    --cc=davem@davemloft.net \
    --cc=david.laight.linux@gmail.com \
    --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