[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260126182928.39ab1d58@pumpkin>
Date: Mon, 26 Jan 2026 18:29:28 +0000
From: David Laight <david.laight.linux@...il.com>
To: David Yang <mmyangfl@...il.com>
Cc: netdev@...r.kernel.org, Aaron Conole <aconole@...hat.com>, Eelco
Chaudron <echaudro@...hat.com>, Ilya Maximets <i.maximets@....org>, "David
S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub
Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Simon Horman
<horms@...nel.org>, dev@...nvswitch.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v2 4/7] net: openvswitch: fix load tearing with
u64_stats
On Sat, 24 Jan 2026 00:21:36 +0800
David Yang <mmyangfl@...il.com> wrote:
> On 64bit arches, struct u64_stats_sync is empty and provides no help
> against load/store tearing. struct copying should not be considered
> tear-free. Use u64_stats_reads() instead.
Except that the compiler doesn't ever generate 'tearing accesses' for
aligned 64bit accesses on any 64bit architecture.
Similarly memcpy() won't generate problematic accesses.
The problem is purely theoretical - the C language lets the compiler
split accesses, but it doesn't.
David
>
> Signed-off-by: David Yang <mmyangfl@...il.com>
> ---
> net/openvswitch/datapath.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
> index d5b6e2002bc1..8ba94df7f942 100644
> --- a/net/openvswitch/datapath.c
> +++ b/net/openvswitch/datapath.c
> @@ -770,7 +770,8 @@ static void get_dp_stats(const struct datapath *dp, struct ovs_dp_stats *stats,
>
> do {
> start = u64_stats_fetch_begin(&percpu_stats->syncp);
> - local_stats = *percpu_stats;
> + u64_stats_reads(&local_stats, percpu_stats,
> + sizeof(local_stats));
> } while (u64_stats_fetch_retry(&percpu_stats->syncp, start));
>
> stats->n_hit += local_stats.n_hit;
Powered by blists - more mailing lists