[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260126113523.3663baee@pumpkin>
Date: Mon, 26 Jan 2026 11:35:23 +0000
From: David Laight <david.laight.linux@...il.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Jakub Kicinski <kuba@...nel.org>, David Yang <mmyangfl@...il.com>,
netdev@...r.kernel.org, Lino Sanfilippo <LinoSanfilippo@....de>, Andrew
Lunn <andrew+netdev@...n.ch>, "David S. Miller" <davem@...emloft.net>,
Paolo Abeni <pabeni@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] net: alacritech: Use u64_stats_t with
u64_stats_sync properly
On Mon, 26 Jan 2026 11:11:09 +0100
Eric Dumazet <edumazet@...gle.com> wrote:
> On Mon, Jan 26, 2026 at 12:23 AM Jakub Kicinski <kuba@...nel.org> wrote:
> >
> > On Fri, 23 Jan 2026 02:51:07 +0800 David Yang wrote:
> > > On 64bit arches, struct u64_stats_sync is empty and provides no help
> > > against load/store tearing. Convert to u64_stats_t to ensure atomic
> > > operations.
> >
> > Eric, could you comment if this matters? I expect David may send a
> > non-trivial number of these, I want to make sure we're making good
> > use of everyone's time here. 64b accesses are not torn on 64b arches,
> > and never used for control flow.
>
> I added u64_stats_add()/u64_stats_inc() back in 2019, and never bothered
> sending dozens of patches.
>
> Presumably compilers could be really dumb back then, I am not sure
> this is still the case today.
>
gcc still generates 'crap code' for var_64 += var_32 on x86-32.
Basically it zero-extends then does a 64bit add rather than
using 'adc $0, %reg_hi', the extra register is likely to force
a spill to stack.
But that is 'fixed' by using add_u64_u32().
Oh and you really don't want to support adding a signed 32bit value
for one place that wants to do a subtract.
David
Powered by blists - more mailing lists