public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@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>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 2/2] net: dsa: yt921x: Use u64_stats_t for MIB stats
Date: Tue, 3 Mar 2026 11:31:37 +0000	[thread overview]
Message-ID: <20260303113137.GA71509@kernel.org> (raw)
In-Reply-To: <20260227135057.2730254-3-mmyangfl@gmail.com>

On Fri, Feb 27, 2026 at 09:50:54PM +0800, David Yang wrote:
> 64-bit variables might not be atomic on 32-bit architectures, and could
> lead to load/store tearing. Use u64_stats_t to ensure consistency.
> 
> Signed-off-by: David Yang <mmyangfl@gmail.com>

...

> @@ -717,14 +716,29 @@ static int yt921x_read_mib(struct yt921x_priv *priv, int port)

...

> +	u64_stats_update_begin(&pp->syncp);
> +	for (size_t i = 0; i < ARRAY_SIZE(yt921x_mib_descs); i++) {
> +		u64_stats_set(&mib->stats[i],
> +			      u64_stats_read(&mib_new->stats[i]));
> +	}
> +	u64_stats_set(&pp->rx_frames, rx_frames);
> +	u64_stats_set(&pp->tx_frames, tx_frames);
> +	u64_stats_update_end(&pp->syncp);
>  
>  	return 0;
>  }

...

> @@ -782,9 +796,11 @@ yt921x_dsa_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data)
>  		if (!desc->name)
>  			continue;
>  
> -		data[j] = ((u64 *)mib)[i];
> +		data[j] = u64_stats_read(&((u64_stats_t *)mib)[i]);

Stats is available as a member of mib as an array of u64_stats_t.
So this code can avoid bypassing the type system with a cast.
And be consistent with an earlier change in this patch.

		data[j] = u64_stats_read(&mib->stats[i]);

>  		j++;
>  	}
> +
> +	mutex_unlock(&priv->reg_lock);
>  }

...

  reply	other threads:[~2026-03-03 11:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-27 13:50 [PATCH net-next v3 0/2] net: dsa: yt921x: Use u64_stats_t for MIB stats David Yang
2026-02-27 13:50 ` [PATCH net-next v3 1/2] net: dsa: yt921x: Return early for failed MIB read David Yang
2026-03-03 11:34   ` Simon Horman
2026-02-27 13:50 ` [PATCH net-next v3 2/2] net: dsa: yt921x: Use u64_stats_t for MIB stats David Yang
2026-03-03 11:31   ` Simon Horman [this message]
2026-03-03 11:40   ` Paolo Abeni

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=20260303113137.GA71509@kernel.org \
    --to=horms@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --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